English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux badblocks命令

Linux Command大全

Linux badblocks命令用于检查磁盘装置中损坏的区块。

执行指令时须指定所要检查的磁盘装置,及此装置的磁盘区块数。

语法

badblocks [-svw][-b <区块大小>][-o <输出文件>][磁盘装置][磁盘区块数][起始区块]

参数说明

  • -b<区块大小> 指定磁盘的区块大小,单位为字节。
  • -o<输出文件> 将检查结果写入指定的输出文件。
  • -s 在检查过程中显示进度。
  • -v 显示详细的执行信息。
  • -w Perform write tests during the check.
  • [Disk Device] Specifies the disk device to be checked.
  • [Number of Disk Blocks] Specifies the total number of blocks of the disk device.
  • [Start Block] Specifies which block to start checking from.

Online Examples

View the current hard disk information of the system.

# fdisk -l

For example, the displayed information is as follows:

Disk /dev/sda: 298.9 GB, 298999349248 bytes
255 heads, 63 sectors/track, 36351 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         262     2104483+  82  Linux swap / Solaris
/dev/sda2   *         263       32898   262148670   83  Linux
/dev/sda3           32899       36351    27736222+  83  Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes
64 heads, 32 sectors/track, 40960 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Scan the hard disk through the command.

# badblocks -s -v /dev/sdnx

In this case, n represents the hard disk device name, and x represents the partition number corresponding to the hard disk. For example, to check "/dev/sda2",execute the following command:

# badblocks -s -v /dev/sda2
Checking blocks 0 to 30681000
Checking for bad blocks (read-only test): 306809600674112/ 306810000000
30680964
30680965
30680966
30680967
30680968
30680969
30680970
30680971
30680972
30680973
...
done
Pass completed, 37 Bad blocks found. Among them, “37 Bad blocks found indicates that the hard disk exists37Bad Blocks.

Linux Command大全