
Retrieve the name of the device
Retrieve bad blocks from a disk: badblocks
Check and repair a Linux file system: fsck
Mark bad sectors as 'unusable' sectors: fsck and badblocks
Retrieve bad blocks from a disk: badblocks
Check and repair a Linux file system: fsck
Mark bad sectors as 'unusable' sectors: fsck and badblocks
Retrieve the name of the device
To get the name of the device you want to test, you can use the 'fdisk -l' command as root (or sudo 'command') as for all the following commands. Another way is to look in the '/etc/fstab' file. For the rest of this article the disk name will be '/dev/sdX'.Retrieve bad blocks from a disk: badblocks
This command line utility is used to find sectors of a device that can not be used due to permanent damage, like physical damage. You can run it in read only mode (default), or in read/write non destructive (preserve data) mode.#read only badblocks -sv /dev/sdX #read/write non destructive partition need to be unmounted badblocks -nsc /dev/sdX
Check and repair a Linux file system: fsck
fsck must be run on an unmounted device (umount /dev/sdX) if it is not needed by your system. You can also run it on the system device.To check all the partitions now:
shutdown -Fr now
touch partitionMountpointPath/forcefsck
fsck -t ext3 /dev/sdXn
fsck -at ext3 /dev/sdXn
tune2fs -c 10 /dev/sdXn
Mark bad sectors as 'unusable' sectors: fsck and badblocks
Fsck can use badblocks to find the bad blocks and add it to the bad block inode to mark it as unusable. We can ask for a simple read only test '-c', or a non destructive read/write test '-cc'.fsck -cct ext3 /dev/sdXn