How to Fix Bad Sectors in Linux

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.

Bad sectors are a physical problem on the hard drive. Every operating system has it's own specific tools you can use to fix bad sectors. The best way to repair the hard drive is to boot another system and scan the hard drive while it's not in use. You can also boot the system in single user mode and run a scan if no other system is available. The "e2fsck" program is ideal to check the file system and use the "badblocks" program to check the hard drive. Don't run the "badblocks" program directly unless you know the exact block size.

Advertisement

Step 1

Download and burn Ubuntu to a DVD. If you have another Linux system or Live CD that can access the hard drive, you may skip this step.

Video of the Day

Step 2

Restart the computer and boot from the DVD or alternate system.

Advertisement

Step 3

Open a terminal window.

Step 4

Type "fdisk -l" (without the quotation marks) to see the hard drive and partition device names. This displays the hard drives and partitions on your system. Make a note of the hard drive or partition you want to scan for the "e2fsck" command. Please note the parameter after the command is a lower-case "L."

Advertisement

Step 5

Type the following command: sudo e2fsck -cfpv /dev/sdb2. Replace "sdb2" with your actual device name, this can be an entire drive, such as "sda" or a partition, such as "sda1."

Advertisement

The parameters have the following meanings: "c" searches for bad blocks and adds them to the list, "f" forces a check on the file system, "p" repairs anything that can be safely repaired and "v" is verbose mode so you can see the command progress.

Advertisement

The "e2fsck" command can take a long time to run, even several hours on a particularly large drive.

Step 6

Exit the terminal after the "e2fsck" command is finished.

Step 7

Remove the DVD/CD if any and reboot the system. Your file system is up to date with any bad sectors and will avoid them; any repairable issues have been fixed.

Video of the Day

Advertisement

Advertisement

references & resources