Ubuntu – How to fix the hard-drive Bad Sector

fsckhard drive

I tried to fix my hard drive using Ubuntu but I encountered an error message and didn't know how to proceed. I need to fix my bad sectors

fsck /dev/sdb  
fsck from util-linux 2.20.1  
e2fsck 1.42.5 (29-Jul-2012)  
fsck.ext2: Permission denied while trying to open /dev/sdb  
You must have r/w access to the filesystem or be root  

Best Answer

A bad sector on a drive is a sign of permanent damage to the drive. Unless you have reason to believe that your drive marked these sectors as bad incorrectly, you cannot "fix" them.

It means that a part of your drive is damaged to the extent that it can no longer reliably be read from and/or written to.

Your system can continue to use the drive by marking that sector as unusable, but you might consider a drive replacement anyway, as a bad sector can be a sign that more sectors, or the whole drive, might fail soon.

While there may be ways to force the drive to un-mark a sector as bad, allowing you to use it again, this is likely not a good idea. The sector may stay good, but it will just as likely become bad again. Some data may be lost or corrupted depending on how it fails.

Now, as for the error message you've pasted in your question (as of my writing this), that error has nothing to do with bad sectors. It means that you don't have access to the drive. Being sudo can give you access, so:

sudo fsck /dev/sdb

However, this is still probably not what you want, because /dev/sdb refers to the entire drive, whereas fsck is designed to work on filesystems, which are usually (but not always, and you may have an exception here) placed in partitions. If the above didn't work, you may instead have wanted to do this to the 1st partition on that drive:

sudo fsck /dev/sdb1

You can get a list of partitions per drive with:

sudo fdisk -l
Related Question