Ubuntu – How to install Ubuntu on a hard drive with bad blocks

11.10formathard drivelaptop

I have a problem with my laptop,in which I'd had windows xp. That XP crashed and I couldn't restore it with the Install CD. So, I placed Ubuntu 11.10 install on a Pendrive, searched for some bad blocks(less than 500), hard drive had a entire format and everything looks fine but the progress bar hangs about 20% and the install didn't finish over night? What should I do?

Best Answer

After writing the digression below, it occurred to me that I should probably also mention why I wrote it.

Any form of sector write or read error on a drive should be viewed as a potential warning. The drive could be failing. Certainly if a drive is reporting as many as 500 bad blocks, I would dig deeper into this before installing anything on the drive.

As I mentioned below, you can use Ubuntu Disk Utility from a Live CD/USB to examine the drive's SMART attributes. If the drive only has few pending reads, you can fill the drive with zeros to force the sectors to be remapped and then do another Ubuntu install.

But watch the drive carefully for further signs of failure and don't save anything critical on it unless it is also backed up. If the drive continues to show sector errors, consider shopping for a replacement drive. Soon.

Just my opinion of course, for whatever it's worth.


These days it is hard to be certain what the phrase bad blocks actually means. In the pre-deluvian days of computing ... say 15 years or more ago ... it could refer to a list the operating system kept of sectors on a hard drive which the drive reported to be, well, bad.

All relatively recent drives now do this sort of tracking internally in their firmware and operating systems no longer need to track such things.

This Wikipedia article on Bad Sectors seems to be a reasonable overview. The key points being:

  1. While the hard drive will automatically attempt to remap a bad sector, it typically only does this when a write fails. Read errors are reported to the OS and logged in the drive's S.M.A.R.T. data, but the sector is not remapped.
  2. The standard way to force the drive to remap all bad sectors is to write to every byte on the drive. Typically one fills all the sectors with 0x00.
  3. If a drive has reported one or more bad sectors, it is possible that the drive may be approaching failure. The drive's S.M.A.R.T. data should be examined, especially the following S.M.A.R.T. attributes
       0x05 Reallocated Sectors Count (How many sectors were remapped)
       0xC5 Current Pending Sector Count (How many sectors waiting to be remapped)

You can use an Ubuntu Live CD or USB to do these things.

After booting the Live CD/USB, open the Disk Utility application either with the GUI by searching for it with Dashor by running the command palimpsest & in a terminal. Select the disk in the left sidebar and then use the SMART Status function to retrieve and view the drive's S.M.A.R.T. attributes.

The dd command command can be used from a terminal window in a Live CD/USB session to fill a drive with zeros. For example, the command below will write 0x00 to every sector on drive /dev/sda

sudo dd if=/dev/zero bs=1M of=/dev/sda

Of course, depending on the size of the drive this could take many hours to complete.

If you are curious, there are many more "tricks" one can use with dd. Have a look at the answers to this question on serverfault. I especially like this trick for periodically displaying the progress of a dd command.

Related Question