Thursday, November 26, 2009

The incredible shrinking harddisk

A harddisk in my home server was giving S.M.A.R.T. warnings of imminent doom, so I ordered a new harddisk, a Seagate ST31000528AS Barracuda 1TB.

I had read about some issues with bad firmware in their prior models (7200.11), but figured that was a one off that could happen to any vendor.

Received the harddisk a few days ago, plugged it in, booted an iso with GParted and proceeded to copy the partitions of the old disk to the new disk.. everything was going smoothly.

... until ...

After the copy, disconnected the old disk and plugged the new one in the first SATA port. That's when the troubles started. The disk wouldn't boot, which after thinking about it, was to be expected as I forgot to put a bootloader on it, doh! So back to GParted, but when the kernel started spewing errors, something about sectors being out of range. That's when I noticed that the disk was now detected as a 33Mb, instead of the somewhat larger 1TB it should be.

Rebooting didn't help, changing the SATA port, booting a different kernel, nothing helped.

Now here's what happened... for some reason, the team that made the BIOS of the motherboard, figured it would be a good idea to reserve some space on the harddisk to dump their crap on.. but apparently math skills are optional when applying for that position and hence they messed up the code that reserves the area (probably thought we wouldn't be using 1Tb disks any time soon). So instead of setting aside a modest sized area, the code almost grabbed the entire disk.

The reservation is done by setting the Host Protected Area of the disk.

Luckily with a recent hdparm (like the one you can find on a live CD of Fedora12 or Ubuntu 9.10), you can view/set the HPA boundary. After correcting it, my disk was back to normal... I'm still not sure why the BIOS isn't 'fixing' the disk again after a restart.. so I'm a bit worried that I'll loose data if one of the days the BIOS decides to screw me over again. Probably best to look for a BIOS update before trusting my data on the disk.


For those that are wondering.. the motherboard is a Gigabyte 965P-S3 (and finding the correct BIOS file would be so much easier if Gigabyte didn't make more than 1 revision of the motherboard or if they would at least mention how you can discover the difference between rev 1 and rev 3.3). Anyway, if you don't remember which motherboard you have, you can use the dmidecode utility or lshw if you have it installed. (or if your kernel is recent enough, you can look in /sys/devices/virtual/dmi/id)

More details and what other issues that can cause your disk to shrink are explained in this nice blog post: http://blog.atola.com/restoring-factory-hard-drive-capacity/

No comments: