10

My hard disk has developed more than 1200 bad sectors and it is failing to install any operating system. I am using ubuntu 12.04 through my pen drive. I need to zero fill my hard disk. Please advice.

user161420
  • 101
  • 1
  • 1
  • 3

2 Answers2

9

Well you have a lot of bad sectors. My advise is to replace the drive. But if you still want to mark those bad sectors, then you can use fsck. fsck is used to check and optionally repair one or more Linux file systems. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo fsck /dev/sd*  (replace * with your device ID)

Note: When dealing with any hard drive issue please make sure that you have a current backup of all you information.

The "fsck" command stands for "file system check"; it scans the disk for bad sectors and labels the ones that aren't working.

If you want to zero out the drive, just follow Piskvor's answer.

Mitch
  • 107,631
  • 3
    That's not what fsck does; it checks and restores improperly unmounted filesystems (i.e. data structures). Bad sectors are hardware errors on the underlying disk. – Piskvor left the building May 24 '13 at 12:33
  • 1
    @Piskvor The "fsck" command stands for "file system check"; it scans the disk for bad sectors and labels the ones that aren't working. – Mitch May 24 '13 at 12:36
  • 3
    Interesting. I apologize, you are right after all: this is one of fsck's functions - although fsck can't repair or reallocate the bad sectors, it can mark them as bad in the FS, so that the FS will not even try to use these sectors. Even though this doesn't solve the underlying problem, it can sidestep it (for a small number of bad sectors). – Piskvor left the building May 24 '13 at 12:46
  • 1
    @Piskvor Don't apologize, we're all here learning from each others. – Mitch May 24 '13 at 12:56
3

To answer your specific question: sudo dd if=/dev/zero of=/dev/sdX will overwrite disk /dev/sdX with zeroes. Use with caution; there is no "undo" for this.

To address the underlying problem: if your hard disk has this many errors, it will fail catastrophically in the very near future, and you will lose anything that's written on it; replace it with a working one ASAP. Overwriting it with zeroes will not eliminate the bad sectors, and only postpones the problem.

Elder Geek
  • 36,023
  • 25
  • 98
  • 183