cp: error reading … Input/output error … failed to extend …


이런 오류 메세지가 뜬다면, 하드디스크의 배드섹터를 의심해봐야 함



논리적 배드섹터의 경우 Zero-fill (하드디스크 모든 영역의 자기값을 0 으로 채움) 작업을

통해서 증상을 없앨 수 있다...


솔직히 이 방법으로 치료가 되는지 모르겠지만, 배드섹터가 너무 많다고 할 경우엔 하드디스크를 교체하는게 답이다.




1) 해당 증상이 있는 하드디스크의 언마운트


만약 OS가 설치된 하드디스크에서 에러가 발생한다면, 부팅 장치(Live CD나.. USB) 를 통해 접근해야한다.


mount된 디렉토리를 umount 하고자 할 때, 만약 특정 사용자 & 프로세스가 해당 디렉토리를 사용하고 있으면

"device is busy" 메세지가 발생하며 umount 가 되지 않는다.

이 경우 umount를 위해 해당 프로세스를 강제로 kill 하는 방법


# fuser -ck 마운트디렉토리

ex) fuser -ck /home/hostway

위 명령으로 프로세스를 kill 하고 umount를 재시도하면 정상적으로 mount가 해제 됩니다.

 

* 해당 디렉토리를 사용하는 사용자가 누구인지 확인하고 싶을 때

# fuser -cu /home/hostway



2) 터미널에 다음 명령어를 입력하여 현재 리눅스 머신에 연결된 모든 저장장치를 표시한다.


    sudo fdisk -l (소문자 'L' 이다)


3) 배드블럭 검사 시작, 시간이 매우 오래 걸리는 작업 (2TB 기준으로 어쨋든 하루동안은 못쓴다고 보면 된다)


배드블럭을 검사하는 명령어는 다음과 같다.


sudo badblocks -v /dev/sdx (/dev/sda, /dev/sdb, ... /dev/sdx) (이대로 수행하게되면 영겁의 세월이 걸린다)



       -b block-size

              Specify the size of blocks in bytes.  The default is 1024.


       -c number of blocks

              is the number of blocks which are tested at a time.  The default is 64


       -n     Use  non-destructive  read-write mode.  By default only a non-destructive read-only test is

              done.  This option must not be combined with the -w option, as they are mutually exclusive.


       -o output_file

              Write the list of bad blocks to the specified file.  Without this  option,  badblocks  dis‐

              plays  the list on its standard output.  The format of this file is suitable for use by the

              -l option in e2fsck(8) or mke2fs(8).



badblocks -svn -b 512 -c 65536 -o /tmp/badblocks_output.txt /dev/sdb1


출력으로 나오는 결과 값의 뜻은 다음과 같다.

0/0/0  ::: <number of read errors>/<number of write errors>/<number of corruption errors>.



4) output 파일을 이용해 fsck.ext4 -fpv -L ./badblocks_output.txt /dev/sdb1


fsck.ext4 를 쓰거나 하드디스크 포맷에 맞춰 ext3, ext2 등을 쓸 수도 있고, e2fsck 를 쓸 수도 있다.


badblocks 명령어로 출력된 파일을 이용해 배드블록의 위치에서 치료



5) 그래도 치료가 안된다 싶으면 dcfldd 를 설치해서 Zero-fill 포맷


    sudo apt-get install fsck.ext4 dcfldd


    sudo dcfldd if=/dev/zero of=/dev/sdb1



6) 여전히 똑같은 증상이면 하드디스크 초기 불량의 가능성이 있음.


급하지 않다면 교체를 하는것이 여러모로 정신 건강에 좋다.




'IT > Linux' 카테고리의 다른 글

Nginx 설치하기  (0) 2016.02.11
Bash 단축 키  (0) 2016.01.26
우분투(Ubuntu) htaccess 활성화 하기  (0) 2016.01.18
우분투(Ubuntu) 포트 열기 및 사이트 여러개 띄우기  (0) 2016.01.12
서버 재설치, 삽질삽질삽질  (0) 2015.08.30