I’ll be logged in as root.
Step 1 – Show your HDD with the following command.
fdisk -l Disk /dev/sda: 500.1 GB, 500106780160 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976771055 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0000aa64 Device Boot Start End Blocks Id System /dev/sda1 * 2048 968404991 484201472 83 Linux /dev/sda2 968407038 976769023 4180993 5 Extended /dev/sda5 968407040 976769023 4180992 82 Linux swap / Solaris Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x93911043 Device Boot Start End Blocks Id System /dev/sdc1 2048 1953525167 976761560 83 Linux Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 81 heads, 63 sectors/track, 765633 cylinders, total 3907029168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0xe337e54a Device Boot Start End Blocks Id System /dev/sdb1 2048 3907029167 1953513560 83 Linux Disk /dev/sdd: 1999.7 GB, 1999696297984 bytes 228 heads, 56 sectors/track, 305894 cylinders, total 3905656832 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x729ee5dd Device Boot Start End Blocks Id System /dev/sdd1 2048 3905656831 1952827392 83 Linux
Step 2 – You have to choose the HDD partition and run the test with the following command.
root@mail:/# sudo badblocks -v /dev/sda1 > /home/mslavov/bad-sectors.txt Checking blocks 0 to 484201471 Checking for bad blocks (read-only test): done Pass completed, 25 bad blocks found. (1/0/0 errors)
Step 3 – After that, we need to feed the file into the FSCK command to mark these bad sectors as ‘unusable’ sectors.
sudo fsck -l /home/mslavov/bad-sectors.txt /dev/sda1
or also you can use this commad for ext2,3,4 filesystem.
sudo fsck -t ext4 -l /home/mslavov/bad-sectors.txt /dev/sda1