Chinaunix首页 | 论坛 | 博客
  • 博客访问: 42668
  • 博文数量: 16
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-09 17:43
文章分类
文章存档

2011年(1)

2009年(13)

2008年(2)

我的朋友

分类: LINUX

2009-03-30 17:26:16

badblocks命令详解

NAME
       badblocks - search a device for bad blocks #检测设备的坏道
                                                 

SYNOPSIS
       badblocks [ -svwnf ] [ -b block-size ] [ -c blocks_at_once ] [ -i
       input_file ] [ -o output_file ] [ -p num_passes ] [ -t test_pattern ]
       device [ last-block ] [ start-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.
       start-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.

       badblocks被用于在一个设备上寻找坏道(通常是一个磁盘分区上工作)。设备在磁盘中相当一个特殊文件(例如: /dev/hdc1)。
       last-block 是将被最终检测的区块;如果没有特别指定,那么设备上的最终区块就会被赋予默认值。start-block是一个在检测中
                   任选的用于指定起始区块号的参数,这个参数可以让检测从磁盘的中间部位开始。默认情况下,它不是特指磁盘上第一个被使用的区块。

       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 filesystem. For this reason,
       it is strongly recommended that users not run badblocks directly, but
       rather use the -c option of the e2fsck and mke2fs programs.

                  特别注意:如果badblocks的输出是由e2fsck或者是mke2fs程序产生的,那么特别指定区块大小是非常重要的,
        因为被生成的区块数是十分依靠文件系统的区块大小的。因此,特别推荐的是用户不要直接运行badblocks,而是使用
       e2fsck或者是mke2fs的参数 -c 。

OPTIONS
       -b block-size
              Specify the size of blocks in bytes. The default is 1024.#特别指定区块大小(单位:bytes)。默认值是1024。

       -c number of blocks
              is the number of blocks which are tested at a time. The default
              is 64. # 一次性检测区块的数目。默认值是64。

       -f     Normally, badblocks will refuse to do a read/write or a non-
              destructive test on a device which is mounted, since either can
              cause the system to potentially crash and/or damage the filesys-
              tem 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. # 通常情况下,badblocks会拒绝在 可读/可写 或者是 没有被毁坏的挂载
                                     磁盘上进行检测,即使可能导致系统潜在冲突并且/或者破坏文件系统,以只读模式挂载时,也不
                          进行检测。你可以使用 -f 参数来忽略以上的默认设置,但是一般来说还是不应该被使用——除非
                     你认为你比badblocks巧妙,不过通常不是这样的。仅仅当 /etc/mtab 文件损坏,并且磁盘真
                     的没有被挂载,使用这个参数才是比较安全的。
                     

       -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 filesystem, in a format suitable for use with this option.#从文
                         件中读取读取已知的坏道。Badblocks会跳过已知的坏道。如果input_file被特殊指定了“-”
                     ,那么列表就会被按照标准输入模式读取。在这个列表中列出的区块会被标准输出或者输入文件忽略。
                     在适当的情况下,可以使用dumpe2fs中的-b 参数可以恢复现有的文件系统中当前列表中标识为损坏
                     的区块。
              

       -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).# 把坏道列表写入指定的文件。没有指定这个参数的时,
              badblocks会以标准输出显示坏道列表。这中文件格式同样可以被e2fsck或mke2fs的
                -l 参数使用。


       -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.# 重复扫描磁盘直到
                没有在num_passes中找到新的此磁盘区块。默认值是0,表示badblocks会在第一次检测
                    通过后退出。
                  

       -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.# 指定一个用来读取的(写入的)磁盘区块测试模式。测试模式可以是在
                     0到ULONG_MAX-1(包含)的数值,或者是“random”,也就是指定区块大小是由一个随机
                   产生的数字模式填充。在 可读/可写(-w)和无损坏(-n)模式中,通过使用-t参数来指定一个
                                    或多个来完成每个希望的检测模式。在只读模式中,只能指定一个测试模式而且不能是“random”
                                    。只读测试是假定指定模式已经写入磁盘的模式——如果不是,大量的区块就会确认失败。如果指定
                   了多重模式,那么所有的区块会每测试完成一个模式后,再进入到下一个模式。

       -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.# 使用
                    无损坏 读/写 模式。默认情况下无损坏 读/写 模式会被完成。这个参数不可以和-w参数一起使用,
                   因为他们是相互抵制的。

       -s    Show the progress of the scan by writing out the block numbers
              as they are checked.# 显示进程已经检测的区块。

       -v     Verbose mode.# 详细模式。

       -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.# 使用可写模式检测。使用这个参数后,badblocks
                                     会在设备的每个区块中写入一些模式(0xaa, 0x55, 0xff, 0x00)来进行坏道检测,读取
                   每个区块并且比较目录。这个参数不可以和-n参数一起使用,因为他们是相互抵制的。
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.# 永远不要在已经存在文件系统的设备上使用-w参数。这个参数会
        删除数据!如果你希望在已经存在文件系统的设备上使用可写测试,那么使用-n参数来代替它。这样会
        比较慢,但是这样可以保护你的数据。
阅读(6355) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~