IT 공부내용 정리/Linux

터미널 명령어 - badblocks 파일이 깨지거나 저장에 문제가 있다면

따뜻한 차가움 2025. 3. 31. 10:31

사용 버전 : Linux 우분투(레드햇 계열) 24.04.01 LTS 버전
사용한 시스템 지역/언어 : 대한민국/한글

man badblocks 원문

더보기

BADBLOCKS(8)                System Manager's Manual               BADBLOCKS(8)

NAME
       badblocks - search a device for bad blocks

SYNOPSIS
       badblocks  [  -svwnfBX  ]  [ -b block_size ] [ -c blocks_at_once ] [ -d
       read_delay_factor ] [ -e max_bad_blocks ] [ -i input_file ] [  -o  out‐
       put_file  ] [ -p num_passes ] [ -t test_pattern ] device [ last_block ]
       [ first_block ]

DESCRIPTION
       badblocks is used to search for bad blocks on a device (usually a  disk
       partition).   device  is  the  special file corresponding to the device
       (e.g /dev/hdc1).  last_block is the last block to be checked; if it  is
       not  specified,  the  last  block  on  the device is used as a default.
       first_block is an optional parameter specifying the starting block num‐
       ber for the test, which allows the testing to start in  the  middle  of
       the  disk.   If it is not specified the first block on the disk is used
       as a default.

       Important note: If the output of badblocks is going to be  fed  to  the
       e2fsck or mke2fs programs, it is important that the block size is prop‐
       erly  specified,  since  the block numbers which are generated are very
       dependent on the block size in use by the file system.  For  this  rea‐
       son,  it is strongly recommended that users not run badblocks directly,
       but rather use the -c option of the e2fsck and mke2fs programs.

OPTIONS
       -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.

       -d read delay factor
              This parameter, if passed and non-zero, will cause bad blocks to
              sleep between reads if there were no errors encountered  in  the
              read  operation; the delay will be calculated as a percentage of
              the time it took for the read  operation  to  be  performed.  In
              other  words,  a value of 100 will cause each read to be delayed
              by the amount the previous read took, and  a  value  of  200  by
              twice the amount.

       -e max bad block count
              Specify a maximum number of bad blocks before aborting the test.
              The  default  is 0, meaning the test will continue until the end
              of the test range is reached.

       -f     Normally, badblocks will refuse to do a read/write or a  non-de‐
              structive  test  on  a device which is mounted, since either can
              cause the system to potentially crash  and/or  damage  the  file
              system  even if it is mounted read-only.  This can be overridden
              using the -f flag, but should almost never be used  ---  if  you
              think you're smarter than the badblocks program, you almost cer‐
              tainly  aren't.  The only time when this option might be safe to
              use is if the /etc/mtab file is incorrect, and the device really
              isn't mounted.

       -i input_file
              Read a list of already existing  known  bad  blocks.   Badblocks
              will  skip  testing these blocks since they are known to be bad.
              If input_file is specified as "-", the list will  be  read  from
              the  standard input.  Blocks listed in this list will be omitted
              from the list of new bad blocks produced on the standard  output
              or in the output file.  The -b option of dumpe2fs(8) can be used
              to retrieve the list of blocks currently marked bad on an exist‐
              ing file system, in a format suitable for use with this option.

       -n     Use  non-destructive read-write mode.  By default only a non-de‐
              structive read-only test is done.  This option must not be  com‐
              bined 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 displays 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).

       -p num_passes
              Repeat  scanning  the disk until there are no new blocks discov‐
              ered in num_passes consecutive scans of the disk.  Default is 0,
              meaning badblocks will exit after the first pass.

       -s     Show the progress of the scan by writing  out  rough  percentage
              completion  of  the  current badblocks pass over the disk.  Note
              that badblocks may do multiple test passes  over  the  disk,  in
              particular if the -p or -w option is requested by the user.

       -t test_pattern
              Specify  a test pattern to be read (and written) to disk blocks.
              The test_pattern may either be a numeric  value  between  0  and
              ULONG_MAX-1  inclusive,  or  the  word "random", which specifies
              that the block should be filled with a random bit pattern.   For
              read/write (-w) and non-destructive (-n) modes, one or more test
              patterns  may  be specified by specifying the -t option for each
              test pattern desired.  For read-only mode only a single  pattern
              may  be specified and it may not be "random".  Read-only testing
              with a pattern assumes that the specified pattern has previously
              been written to the disk - if not, large numbers of blocks  will
              fail  verification.  If multiple patterns are specified then all
              blocks will be tested with one pattern before proceeding to  the
              next pattern.

       -v     Verbose  mode.   Will write the number of read errors, write er‐
              rors and data- corruptions to stderr.

       -w     Use write-mode test. With this option, badblocks scans  for  bad
              blocks  by  writing  some  patterns  (0xaa, 0x55, 0xff, 0x00) on
              every block of the device, reading every block and comparing the
              contents.  This option may not be combined with the  -n  option,
              as they are mutually exclusive.

       -B     Use buffered I/O and do not use Direct I/O, even if it is avail‐
              able.

       -X     Internal  flag  only  to be used by e2fsck(8) and mke2fs(8).  It
              bypasses the exclusive mode in-use device safety check.

WARNING
       Never use the -w option on a device containing an existing file system.
       This option erases data!  If you want to do write-mode  testing  on  an
       existing  file system, use the -n option instead.  It is slower, but it
       will preserve your data.

       The -e option will cause badblocks to output a possibly incomplete list
       of bad blocks. Therefore it is recommended to  use  it  only  when  one
       wants to know if there are any bad blocks at all on the device, and not
       when the list of bad blocks is wanted.

AUTHOR
       badblocks  was  written  by  Remy  Card <Remy.Card@linux.org>.  Current
       maintainer  is  Theodore  Ts'o  <tytso@aluhttp://m.mit.edu>.   Non-destructive
       read/write test implemented by David Beattie <dbeattie@softhome.net>.

AVAILABILITY
       badblocks  is  part  of  the  e2fsprogs  package  and is available from
       http://e2fsprogs.sourceforge.net.

SEE ALSO
       e2fsck(8), mke2fs(8)

E2fsprogs version 1.47.0         February 2023                    BADBLOCKS(8)

man badblocks 번역기 번역본

더보기

Badblocks (8) 시스템 관리자의 설명서 Badblocks (8)

이름
       BADBLOCKS- 잘못된 블록을 검색하십시오

개요
       badblocks [-svwnfbx] [-b block_size] [-c blocks_at_once] [-d
       read_delay_factor] [-e max_bad_blocks] [-i input_file] [-o out-
       put_file] [-p num_passes] [-t test_pattern] 장치 [last_block]
       [First_Block]

설명
       Badblocks는 장치에서 불량 블록을 검색하는 데 사용됩니다 (일반적으로 디스크
       분할).   장치는 장치에 해당하는 특수 파일입니다
       (예 : /dev /hdc1).  Last_Block은 확인해야 할 마지막 블록입니다. 그렇다면
       지정되지 않으면 장치의 마지막 블록은 기본값으로 사용됩니다.
       First_Block은 시작 블록 번호를 지정하는 선택적 매개 변수입니다.
       테스트를 위해 BER, 테스트가 중간에 시작할 수 있습니다.
       디스크.   지정되지 않은 경우 디스크의 첫 번째 블록이 사용됩니다.
       기본값으로.

중요한 참고 사항 : Badblocks의 출력이
       E2FSCK 또는 MKE2FS 프로그램, 블록 크기가 소품 인 것이 중요합니다.
       생성 된 블록 숫자는 매우
       파일 시스템에서 사용하는 블록 크기에 따라  이 rea-
       아들, 사용자가 직접 Badblocks를 실행하지 않는 것이 좋습니다.
       오히려 E2FSCK 및 MKE2FS 프로그램의 -C 옵션을 사용하십시오.

옵션
       -B block_size
              바이트의 블록 크기를 지정하십시오.  기본값은 1024입니다.

-C 블록 수
              한 번에 테스트되는 블록 수입니다.  기본값
              64입니다.

-D 지연 계수를 읽습니다
              이 매개 변수는 전달되고 0이 아닌 경우 불량 블록을 유발합니다.
              오류가 발생하지 않은 경우 읽기 사이의 수면
              작동 읽기; 지연은의 백분율로 계산됩니다
              읽기 작업을 수행하는 데 걸리는 시간.  ~ 안에
              즉, 100의 값은 각 읽기가 지연됩니다.
              이전 읽기가 취한 금액과 200의 값으로
              양의 두 배.

-e 최대 불량 블록 수
              테스트를 중단하기 전에 최대 불량 블록 수를 지정하십시오.
              기본값은 0이므로 테스트가 끝까지 계속됩니다.
              테스트 범위에 도달했습니다.

-F 일반적으로 Badblocks는 읽기/쓰기 또는 비 de-를 거부합니다.
              장착 된 장치의 구조 테스트, 어느 쪽이든
              시스템이 잠재적으로 충돌하거나 파일을 손상시킬 수 있습니다.
              읽기 전용으로 장착되어 있어도 시스템.  이것은 재정의 될 수 있습니다
              -f 플래그를 사용하지만 거의 사용되지 않아야합니다.
              Badblocks 프로그램보다 똑똑하다고 생각합니다.
              정교하게는 그렇지 않습니다.  이 옵션이 안전 할 수있는 유일한 시간
              /etc /mtab 파일이 잘못된 경우에 사용됩니다.
              장착되지 않았습니다.

-i input_file
              이미 존재하는 알려진 나쁜 블록 목록을 읽으십시오.   Badblocks
              이 블록이 나쁜 것으로 알려져 있기 때문에이 블록을 건너 뛸 것입니다.
              input_file이 "-"로 지정되면 목록은
              표준 입력.  이 목록에 나열된 블록은 생략됩니다
              표준 출력에서 ​​생성 된 새로운 나쁜 블록 목록에서
              또는 출력 파일에서.  dumpe2fs (8)의 -B 옵션을 사용할 수 있습니다
              현재 존재하지 않는 블록 목록을 검색하려면
              이 옵션과 함께 사용하기에 적합한 형식의 파일 시스템.

-비파괴적인 읽기 쓰기 모드를 사용하십시오.  기본적으로만이 아닌 것만
              구조적 읽기 전용 테스트가 수행됩니다.  이 옵션은 com-
              상호 배타적이므로 -w 옵션이 빙글 둡니다.

-o output_file
              잘못된 블록 목록을 지정된 파일에 작성하십시오.  없이
              이 옵션 인 BadBlocks는 표준 출력에 목록을 표시합니다.
              이 파일의 형식은 -L 옵션에서 사용하기에 적합합니다.
              E2FSCK (8) 또는 MKE2FS (8).

-p num_passes
              새로운 블록이 없을 때까지 디스크 스캔을 반복하십시오.
              num_passes 디스크의 연속 스캔.  기본값은 0이고
              즉, 첫 번째 패스 후에 Badblocks가 종료됩니다.

-거친 비율을 기록하여 스캔 진행 상황을 보여줍니다.
              현재 BADBLOCKS가 디스크를 통과합니다.  메모
              그 나쁜 블록은 디스크를 통해 여러 테스트 패스를 수행 할 수 있습니다.
              특히 사용자가 -p 또는 -w 옵션을 요청하는 경우.

-t test_pattern
              디스크 블록에 읽거나 쓸 테스트 패턴을 지정하십시오.
              test_pattern은 0 사이의 숫자 값 일 수 있습니다.
              ULONG_MAX-1 포함 또는 "랜덤"이라는 단어
              블록은 임의의 비트 패턴으로 채워야합니다.   을 위한
              읽기/쓰기 (-w) 및 비파괴 (-n) 모드, 하나 이상의 테스트
              패턴은 각각의 -t 옵션을 지정하여 지정할 수 있습니다.
              원하는 테스트 패턴.  읽기 전용 모드의 경우 단일 패턴 만
              지정 될 수 있으며 "무작위"가 아닐 수 있습니다.  읽기 전용 테스트
              패턴으로 지정된 패턴이 이전에
              디스크에 기록되었습니다. 그렇지 않다면 많은 블록이
              실패 검증.  여러 패턴이 지정되면 모두
              블록은 하나의 패턴으로 테스트되기 전에
              다음 패턴.

-V 장점 모드.   읽기 오류 수를 쓰고 er- 쓰기
              STDERR에 대한 RORS 및 데이터 손상.

-W 쓰기 모드 테스트를 사용합니다. 이 옵션을 사용하면 BadBlocks가 BAD를 스캔합니다
              일부 패턴 (0xaa, 0x55, 0xff, 0x00)을 작성하여 블록
              장치의 모든 블록, 모든 블록을 읽고
              내용물.  이 옵션은 -n 옵션과 결합되지 않을 수 있습니다.
              그들은 상호 배타적이기 때문에.

-B 버퍼링 된 I/O를 사용하고 직접 I/O를 사용하지 않더라도 -
              할 수 있는.

-X 내부 플래그는 E2FSCK (8) 및 MKE2FS (8)에 의해서만 사용됩니다.  그것
              독점 모드 인 사용 장치 안전 점검을 우회합니다.

경고
       기존 파일 시스템이 포함 된 장치에서 -w 옵션을 사용하지 마십시오.
       이 옵션은 데이터를 지 웁니다!  당신이 an에서 쓰기 모드 테스트를하고 싶다면
       기존 파일 시스템은 대신 -n 옵션을 사용하십시오.  느리지 만
       데이터를 보존합니다.

-e 옵션은 Badblocks가 불완전한 목록을 출력하게됩니다.
       나쁜 블록의. 따라서 하나만 사용하는 것이 좋습니다.
       장치에 전혀 나쁜 블록이 있는지 알고 싶어하지만
       나쁜 블록 목록이 원할 때.

작가
       BadBlocks는 Remy Card <remy.card@linux.org>에 의해 작성되었습니다.  현재의
       관리자는 theodore ts'o <tytso@aluhttp://m.mit.edu>입니다.   비파괴
       David Beattie <dbeattie@softhome.net>에 의해 구현 된 읽기/쓰기 테스트.

유효성
       BadBlocks는 E2FSProgs 패키지의 일부이며
       http://e2fsprogs.sourceforge.net.

참조하십시오
       E2FSCK (8), MKE2FS (8)

E2FSProgs 버전 1.47.0 2023 년 2 월 Badblocks (8)

 

형태 : badblocks [옵션] [저장소]

기능 : [저장소]의 badblock을 탐지하고

 

[옵션]

-v : 검사 과정을 자세히 출력한다.

-n : 비파괴 검사를 진행한다. 기존데이터를 읽고 검사 후 원래 데이터로 복원시킴

-w : 파괴 검사를 진행한다. 데이터를 덮어쓰면서 검사함. 자신의 파일에 오류가 생길 수 있음.

-o [파일명] : badblocks 명령이 찾은 badblock에 대한 기록을 파일로 출력한다.

-i [파일명] : 기존에 찾은 badblock을 확인해서 해당 block에 대한 검사를 건너뛴다.

 

badblock : 저장장치에 손상되거나 읽기/쓰기가 불가능한 block

 

badblocks는 저장소의 오류를 찾아내는 명령어이다.

윈도우에서는 불량섹터라고 부르기도 하며 문제를 일으키는 대상으로 파일을 정상적으로 저장하지 못하기에 사실상 용량이 줄어든다고 볼 수 있다. 해당 위치를 시스템적으로 고칠 수 있다면 좋지만, 해결되지 않을 경우 장치를 바꿔줘야하기에 지속적인 점검을 하는 것이 좋다.

 

옵션중에 n w 는 읽기-쓰기 방식의 검사를 진행하며 해당 옵션을 사용하지 않을 경우 읽기 방식의 검사를 진행한다.

기본적으로는 방을 돌아다니면서 눈으로 외관검사만 하는 것이고

n옵션은 물건 위치를 바꿨다가 원위치 시키는 것

w옵션은 새로운 물건을 배치해보는 것이라고 생각해볼 수 있다.