How to repair bad sectors on hard drive.

A while ago a friend of mine brought a laptop with a vista system that would not boot, i took out the hard drive and checked the smart data. Over 1000 bad sectors! (note- I just witnessed a new record, 2088 bad sectors.) It’s a miracle the hard still knew it had Windows on it. But how did this happen? Let’s go back to the start.

In the beginning, God created the chicken….   No No No that’s too far.

My friend was having trouble booting into his laptop sometimes, so I taught him the power of safe mode and restore. It went well until finally it just would not boot no matter what. But this happened because they never did a check disk. Windows comes with a great and powerful utility called. Check Disk (I think i don’t really remember).  Let’s let Microsoft explain how to use it.

To check the hard disk drive integrity in Windows: (If you can still even use your computer)
  1. Double-click My Computer, and then right-click the hard disk drive you want to check.
  2. Click Properties, and then click Tools.
  3. In Error-checking, click Check now.

Easy peasy right? Windows Vista/7 is the same thing really, but if you don’t believe me, read this. also, windows XP may ask you to reboot.

You can also, remove the bad Hard drive, slave it over to another working computer, and use Disk check on that drive.

But let’s go to the extreme, this is what you’re supposed to do on a regular basis, or at least whenever you don’t shutdown your computer properly. But if you can’t boot into your system, then it’s time for Linux to the rescue.

Use Ubuntu’s Disk Utility tool to view the hard drive’s smart data. for example.

Ubuntu in this case has fsck tool thingie that checks your hard drive for errors and such, even fixes them, there’s a gui for that too you know. Warning, the following will erase everything on your hard drive, but it will leave it nice and usable.

Plug that bad hard drive in and boot your Ubuntu.
Now open up Gparted.
Unmount that drive.
Delete that partition.
Create a new ext3 partition.
Now apply man apply! This will take around ten minutes maybe, after those ten minutes you will have a new ext3 partition, useless for windows but useful for us to check for errors.

Now, while still being in GParted.

Right click the newly creates EXT3 partition and click check. This will take forever depending on the size of your disk. Go do laundry, watch some Lost reruns and figure out the meaning of life. When you are done, your computer should be done too.

Then, delete the partition.
Format it as EXT2
Read what Jocko said below

Jocko said ”

If it’s an ext2 file system, this should do it:
If the filesystem is already mounted, unmount it by:

sudo umount /dev/hdXY

(if it’s your / or /home file system you may need to do it from a live cd)
Then start the check by:

sudo e2fsck -fpC 0 /dev/hdXY

the “-f” option will force a check even if the filesystem is marked as clean, “-p” will repair any errors and “-C 0″ will give you a progress bar in the terminal.”

PS also make sure the hard drive is formated as ext2 for this to work. this will take a long time if there are many errors, also make sure you press y to yes and fix all the errors, i did this i wished i had added the -y switch to answer default yes to all the questions but ended up using a mini mag flashlight as my -y switch. i only wish i had a camera right now.

(Update) Mehh this took too long i used this command.

sudo e2fsck -fyC 0 /dev/hdXY so far so good.
this is all the help i found, it was enough for me, it’s enough for you.

Note: This is not a real solution for badly damaged hard drive sectors, the real solution is to buy a new one, but this will work if you are cheap and don’t care much about reliability.

(Extra Notes!)

The sectors on Hard drives are stored in lists on a G List and P List, the G list the the bad sectors that keep Growing on there and are stored away for non-use. The P List is the list of bad sectors that came with your drive. Go figure.

You can also use one of my favourite utilies to check the SMART data on your computer.


About Zerin

But can you show me the source code?

Posted on April 20, 2011, in Computers and Internet, Linux Stuff, Windows. Bookmark the permalink. 29 Comments.

  1. Sherief El Hamalawy

    i’m having a problem that my disk contains 4 bad sectors, and it’s causing the windows sometimes to hang and the harddisk keeps making sounds as if it’s knocking.. linux mint disk utilities tells me that i have 4 bad sectors but i can’t fix these..
    1- is there a way or a tool to fix them if they’re logical bad sectors ( in linux )
    2-and if physical.. is there a way to mark them to prevent future reads or writes on them
    3- does physical bad sectors really spread by time.. i have this laptop since early last year and it only has 4 bad sectors, would that make sense?

    thank you for this nice tutorial

    • If the hard drive is making knocking sounds that may be normal, but to an extent, as they get older, they do become louder as the head of the hard drive becomes worn out. especially the small laptop drives. Four bad sectors is nothing too bad. Since the Linux Mint Utilities knows that there are four bad sectors, it means that your hard drive also knows about them, and won’t use those sectors again, (that’s is it’s way o fixing them, by ignoring them and not using them). if you believe your windows issues is caused by those bad sectors, you would have to tell Windows to relocate whatever data might still be on those sectors and use other sectors. This is done with a disk check within Windows, and when it reboots, it will take care of scan for you. If you still see Errors and hangs with your Windows installation, I would recommend Re-installing if it is necessary, First, you could try the steps i did in the tutorial (with scanning with using the terminal and fsck) and then re-install, that way windows will not right on those sectors again. but if it still causes noticeable errors and you are sure it’s the hard drive, your best bet is replacing it, not too expensive nowadays. Online hard drives can be like 50$ online for SATA, older IDE you might have trouble finding new.

      (Quick note. Some people always tell me that if your hard drives starts to have some bad sectors, the do “spread” and create more. I’ve only seen this happen once, but it makes sense, since there is nothing you can do about your hard drive dying, and bad sectors is part of old age.)

  2. gurudev nayak

    i have an 160 gb hard disk and i created a 135gb extended partition and in that extended partitiion i created a 122.5gb logical drive which i formatted with ext3 filesystem using gparted program in puppylinux that i have installed on my hard drive .after the format gparted showss 2.11gb out of 122.5gb as used .then i right clicked on that drive and checked the drive as you mentioned.after 1hour 40minutes the check completed and gparted refreshed to show that 2.11gb was used out of 122gb which means no bad sectors ,but i suspected that and ran pmount(a utility to mount drives in puppy)and mounted the new 122gb ext3 drive and in pmount it shows that 114 gb is free out of 122gb which means 6gb in the drive is bad assuming 2.1gb used by ext3 filesystem.
    my question is :
    1>you said that after check is completed i should delete the ex3 partition and format it as ext2,but by doing that wont all this drive checking go to waste meaning will the sectors marked as bad by the check be lost,will the new ext2 partition have those bad sectors as free space or have they been safely left out?
    2>can i delete the partition create a fat32 or ntfs filesystem instead of ext2?will the filesystem ignore bad sectors found in ext3 partition that i deleted?

    • From what I remember. Your hard drive’s SMARTGlist and Plist should keep track of the bad sectors no matter what file system you format it. So if you change it to EXT2 or FAT32, it should be kept track of. But to be safe, if you performed a check on that file system, maybe you could use it with that file system. Just to be safe.

      When I mentioned format to EXT3, then check, then Format to EXT2. This was my way of being paranoid and checking for errors, especially on a hard drive that had no data and me having plenty of time at school to try this. So all in all. I’m not sure if it would keep track of them after a format, but it should. I’m insistent of that. Let me know if you’ve learned otherwise.

      I hope whatever you’re trying to do works out well for you.

      (note_ I learned that it wasn’t the SMART Data that keeps track of the HD’s bad sectors, but the G-list and P-List, some info on those here

  3. GUYS.. can you tell me how to fix the bad sectors? i know it cause of the auto restart,hangs,freezes, and sometimes shutdown..

    • If you can get into your computer, even for just a short period of time, do what I mentioned in my blog.

      “To check the hard disk drive integrity in Windows: (If you can still even use your computer)
      Double-click My Computer, and then right-click the hard disk drive you want to check.
      Click Properties, and then click Tools.
      In Error-checking, click Check now.”

      But if you think your drive is about to expire, cause bad sectors are usually a sign of that. Then you might want to pull it out, plug it into a second computer as a second drive and use that has a tool to check your Hard Drive’s SMART status and see if it’s worth saving the drive or your DATA instead.

  4. well my problem sounds annoying ……..i have a 500 gb WD and it has bad sectors , if u check 4 errors it says no errors …… i tried HDD regenerator and scan 4 bad sectors it found none buh de perfomance of de HDD tells me its has bad sectors i had wanted to regenerate it buh did not ve de lincise key…..i tried linux mint sacn the disk n found sum bad sectors fomatted with ext 3 buh styll has the same behaviour it had be 4 its slow very slow

  5. I had 297 bad sectors on my harddrive. with Windows, Linux Mint 13 and Ubuntu 12 the computer would constantly lock up every few min for about 15 seconds then work fine again. very frustrating. thought it was the ram so I replaced it with no change.
    Temp fixed it using your method via live disk linux mint 13
    it wouldnt work with the script you gave had to change it to

    sudo e2fsck -fycC 0 /dev/sda1

    Harddrive is useable again thanks to you.
    of course this is only a temporary fix and ill be replacing the HDD asap.
    but for short term this works well.

    Thanks Again!

  6. I have 27 GB of bad sectors on an OCZ Revodrive 3 CAUSED by check disk, do not use check disk on a revodrive.

  7. I’m sorry, but I have to disagree. God created the egg ;)

  8. I have 16376 bad sectors on my hard drisk right now. until about an hour ago it was running (just), even with these. Now booting linux off a USB. If I format the hard drive and do a full clean install is it gonna be worth it, or will I get a day’s use then death again?

  9. I am appreciated this useful info. I have 25 years deal with comp but did not know this important and simple trick (chkdsk)

  10. Hi! This may be a stupid question, but where can I download Ubuntu’s Disk Utility tool?

  11. Hi!!
    i’v 2047 bad sector on my HDD and smart status is “DISK FAILURE IS IMMINENT”.
    Attributes-reallocated sector unit
    at present i can install ubuntu on my HDD but not windows.

    currently i’m using ubuntu live cd….gave badblock command and wait for 135hrs but it is still processing so made it stop.

    my deleted all partitions using windows disk and dont know whether it is NTFS or FAT32 or ext4…no idea…

    i want to make my HDD reusable….need ur help.

    thnx in advance.

  12. also i tried the way you showed above…but as i’m running ubuntu with live cd G parted partition editior is just scanning all devices and showing nothing…..i also tried to make partition(my whole HDD is unallocated right now) with disk utility but it is showing error saying “Daemon is inhibited”.

    needed ur help.

  13. Your hard drive is dead. I’m sorry.

  14. Sometimes we face a difficult situation when we accidentally deleted our data from computer,memory cards or pen drives through bad sector and want to get it back. Try Kernel for windows data recovery software to recover deleted, inaccessible data files from hard disk partitions.

  15. Hard drive bad sector and Fix bad sector of hard disk is a very interesting field to have discussion upon. I have tried and researched on Kernel for Windows Data Recovery Software and found it very advanced feature than others. So try it……! url :

  16. Hello, thanks for the information. I have a question.
    I bought today external hard drive 1T WD my passport.
    I used HDDscan and found ~4000 bad sectors (reading test).
    Is it normal for a new hard drive?
    Should I ask the seller to give me another one?

    • Hi there Miller, I would recommend you use other tools as well, to confirm that there truly is that many bad sectors on your external hard drive. Something that can also read the SMART data from your hard disk will tell you a little more about it’s history. Even if drives are new, I’ve never seen that many on a “new” one. If it is under warranty I would get it replaced, but check to see if it’s making lots of noise, if the head is moving all over the place making grinding noises then that hard drive is dying. If it purrs and whirs discreetly then it’s fine. but don’t trust only one source of information.

  17. Richard Vermeulen

    I have 4 tricks to fix a bad harddrive.

    1 – First scan the harddrive, if the boot sectors are okay, but some part on the first to middle is bad but the middle-end of harddrive is good, then you can do this:

    Make 3 partitions, 1 small that will get Windows on it. 2nd that has the bad sectors and 3rd that has the good sectors. Format all 3 partitions. Then use the 1st and 3rd partition. Rename partition 2 to “BAD partition” or so. I did this on a desktop harddrive that had a lot of bad sectors on the middle, By using this trick, i still can use the harddrive

    2 – if your harddrive has bad sectors at the end, then you can use the SETMAX command. Simply make the harddrive to think its smaller. Example: I have a 40 gig harddrive, but the last 2 gig has lots bad sectors. Then I use the SETMAX command to set the harddrive to 38 gig. The 2 gig is then not recognised anymore, not even in Windows XP.

    3 – sometimes its not the platter of the harddrive, but the circuit board. If you have 2 identical harddrives, you can change the circuit board. Sometimes that works.

    4 – If you harddrive is making a ticking noise, and does not even get recognised by any program -> is dead. you can try the last solution – > let it fall on the carpet for some times. Then test it again. Sometimes the heads of your harddrive are stuck on the platter disks. When you let the drive drop on the carpet, the heads can get unstuck again. And then your hd might work again. Use trick number 4 only as a last resort !!!

    Greetings from Richard Vermeulen

  18. Hi Richard Vermeulen ,

    I need some help regarding my HDD.

    I’m using HP Pivilon dv6t 3200 CTO Entertainment Laptop

    Recently I faced one issue with my laptop like NOT able to boot into windows anymore, and getting blue screen error.

    I have no chance to boot into windows , so installed Ubuntu as dual boot on my laptop.
    And once after i’m into the Ubuntu OS , I’ve check the disk-utility.. and observed that my hdd has few bad sectors.

    Then with the help of magic partition , I observed that 76.60GB out of 500GB was BAD.

    So, 76.60GB was bad disk it seems.

    Out of 4 tricks , I guess option 1 would help me , am i right ?

    But can you help me on how to start with it ?

    Do I need to boot with any OS again , and format ? How to start ?


    • That’s pretty bad, I would recommend replacing the hard drive and saving all your data. But if you want to it cheap and risky, Fresh install and keep using that drive until it won’t boot anymore. I’ve personally seen Ubuntu work on drives that Windows won’t boot/install. But it won’t last long if data corruption continues. Not only that but your OS will run slower on a drive with more bad sectors because of seek times and bit reallocation.

  19. hello i need a help, im formatting my hard disk and this what it says Error opening /dev/sda: Device or resource busy (udisks-error-quark, 0)

    and when im gonna install linux mint os it says, Error informing the kernel about modifications to partition /dev/sda1 — Device or resource busy. This means Linux won’t know about any changes you made to /dev/sda1 until you reboot — so you shouldn’t mount it or use it in any way before rebooting

    problem with my hard disk..i really need your help dude..thanks!

  20. Thanks for your nice bad sector post
    Always wondered if that was fixable on a deep level.
    Gonna try it on the next one that comes up with bad sectors.
    Moot for me now, spend three afternoons every week
    dismantling perfectly good HDDs…
    Our e-Waste facility gets all the good stuff
    that Americans are so good as wasting.
    At least it stays outta th’ landfill, but discouraging.

  1. Pingback: How To Check Your Hard Drive For Bad Sectors | Health Deal

  2. Pingback: How To Check For Bad Sectors Linux | CamHR

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s