Linux badblocks command
Linux badblocks command to check the disk device for bad blocks.
Shall specify the disk device to be inspected, and the number of blocks this disk device during instruction execution.
grammar
badblocks [-svw][-b <区块大小>][-o <输出文件>][磁盘装置][磁盘区块数][启始区块]
Parameter Description:
- Block size -b <block size> specified disk, in bytes.
- -o <output file> output file is written to the specified result of the check.
- -s displays the progress during the examination.
- -v Displays detailed information when executed.
- -w In the inspection, test writing is performed.
- [Disk device] to check the specified disk device.
- The total number of blocks [disk block number] Specifies the disk device.
- [Starting blocks] Specifies the block from which to start checking.
Examples
Display the current hard disk information.
# fdisk -l
For example, the following information is displayed:
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
Command scans the hard disk.
# badblocks -s -v /dev/sdnx
Where n represents the hard disk device name, x indicates the corresponding hard disk partition number. For example, you need to check the "/ 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.其中,“37 bad blocks found”表示硬盘存在37个坏块。