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

12,328

Solution 1

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.

Solution 2

BEST ADVICE (rather than solution)

If the hard drive is currently stable, and not deteriorating, then a low-level format will map any "bad sectors" to be unused. The BIOS, HDD controller, and OS should be able to handle any "slow deterioration" after that.

What you are describing could be more serious, and/or a bad controller.

I would strongly suggest getting the laptop checked out, or (at least) getting a test tool that will stress test the drive and show it "stable" or still getting worse ..

Share:
12,328

Related videos on Youtube

Jorge Castro
Author by

Jorge Castro

Updated on September 18, 2022

Comments

  • Jorge Castro
    Jorge Castro almost 2 years

    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?

    • TheXed
      TheXed about 12 years
      To me it sounds like more then maybe just bad blocks, the OS should be smart enough itself to know to ignore them when installing... maybe there is something wrong with the read write head, or the bearings on the platters... I don't know you didn't specify if it is SSD or not, so I am assuming it isn't the only way to fix these two problems would be to install a new hard drive... This would make sense why Windows Crashed, and couldn't be recovered though...
  • jokerdino
    jokerdino about 12 years
    An anonymous user says: "I've used irrational John's advice and install had finished. Now SMART shows 2 bad blocks less than before. Everything looks fine. If anything bad is hapens I let you know. Thanks a lot."