Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to fix my hard drive using Ubuntu but I found that message and didn't know what to do with.... 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  
share|improve this question
The text you've pasted doesn't seem related to your question - can you clarify? – thomasrutter Jan 14 '13 at 2:39

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 I'd generally recommend a drive replacement anyway, as often a bad sector can be a sign that more sectors, or the whole drive, may fail soon.

In fact, you can often force the drive to un-mark a sector as bad, and that sector will be usable again. However, it may stay like this, or it may become bad again, which is why this is not a good idea.

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
share|improve this answer
Its probably just a bad block. It can't read the data, is all. After remapping the block the drive is likely good for another three years. So goes my experience. – Zan Lynx Jan 27 '15 at 20:53
A HDD with a bad sector is much, much more likely to fail at any moment than one which has never had a bad sector. How many drives is your experience based on? I would still call it a bigger gamble. – thomasrutter Jan 27 '15 at 23:45
More likely? Sure. But it isn't immediately doomed. So much depends on why that block went bad. Like I said, I've had drives that slowly remap a few bad blocks over their lifetime and just keep working. – Zan Lynx Jan 28 '15 at 0:00
it isn't immediately doomed - you have no way of knowing or guaranteeing that. In some cases it might be. So much depends on why that block went bad - it would be impossible to reliably find out the why, without opening it up and effectively destroying it. As I said it's always an increased risk. If you are absolutely fine with such a risk I have no problem with that. Most of the time, maybe even >90% of the time, the drive won't quickly fail after a bad sector is found and in some cases it might even last for years after. Keep good backups and any future failure won't hurt as much. – thomasrutter Jan 28 '15 at 0:50

I have answered the same question already.

In short: Boot a rescue system and use

badblocks -svn /dev/sda

to have the hard disk controller replace bad blocks by spare blocks.

Read more details here:

share|improve this answer
If you already answered this question you should vote to close it as a duplicate instead of re-answering it. – iharob Jun 13 '15 at 15:12
You probably want to use this indirectly with fsck's -c option. AFAIK using badblocks standalone will never change the behaviour of anything, it will only report on where the bad blocks are. Of course, the drive firmware might transparently modify its behaviour when put under the usage patterns characteristic of badblocks, but surely this would be drive dependent? – amoe Nov 11 '15 at 14:13
As a new user you first need to gain "reputation" before being allowed to do certain activities on this site. So it was not possible to duplicate this. Still the question deserved an answer. As bad blocks are an issue of the physical disk (check out SMART values, the filesystem is not directly affected. It might suffer corruption due to data loss. So doing a fsck is a good idea as well. As original question was about how to "repair" bad blocks this was the answer. – user228505 Feb 1 at 2:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.