Electronics with passion: amplifiers and power supplies, FET's and vacuum tubes..
computer

BIOS’es hang on 4K sector HDD

One would think that whatever we put on the hard drive - the BIOS should start and let us configure the system parameters. WRONG. With the new "Advanced Format" (the name (c)WDC) 4096 bytes sector technology it's no longer the truth. I tried two mobos (desktop dg33tl & a server one) with what one would name "properly aligned partitions" on WD20EARS - both ceased on booting, even entering the BIOS menu was impossible.

On one hand we want properly aligned partitions on our new tech drives: the write speed penalty for not doing so might be severe. It was 2 times slower in the quick tests I ran. IBM folks report up to 10 times worse writing performance in such case for certain conditions.
On the other hand the machine must boot, right?

A small investigation I conducted showed that the BIOS'es went wonky in particular on the first partition starting not on the "cylinder" boundary. Needless to say that those 255 heads and 63 sectors per track were artificial data these days. But saying so does not help.

Here is the solution I found. It seems to be a really good one, almost no compromises for Linux users and alike. Windows gurus will have to either utilise some GNU tools before installing their preferred environment, or be creative and use something else - please drop me a note shall you find another type of a workaround for this 4Ksector/BIOS issue.

1) Let's create the first partition that would please the BIOS. I adhere to basics, hence fdisk.

fdisk /dev/sdX
o
n
p
1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): +120M
w

2) Then we are free to add whatever aligned partitioning we wanted. Let's start same fdisk but in the more natural sector based mode and not utilizing mystic DOS compatibility:

fdisk -uc /dev/sdX

Below is what it gave on my drive after all calculations were done:

Device    Boot Start        End     Blocks Id System
/dev/sdc1   *     63     257039    128488+ 83 Linux
/dev/sdc2     258048   33292287   16517120 83 Linux
/dev/sdc3   33292288 3902834687 1934771200 8e Linux LVM
/dev/sdc4 3902834688 3907029167    2097240 82 Linux swap / Solaris

There was some simple math behind. Actually every partition except the first one starts on 1MiB boundary, or 2048 512-bytes sectors. That's actually today's commonly suggested practice, and it gives us alignment to 8 sectors naturally.

At the end of the day I've got BIOS that was booting happily. The first partition was not aligned to 4K sectors, but I would not care less. Because I am using it for /boot only, thus not performing much writes on it. Reading speed was still Ok, I assume due to the internal disk cache. Other partitions are all aligned well and very little of the disk space wasted.

Make sure that while formatting your partitions you use appropriate block sizes for the file system. In my case I did the following:

mkfs -t ext3 /dev/sdX1
- it's not aligned anyhow, let ext3 utility use the best at its discretion;

mkfs -t ext3 -b 4096 /dev/sdX2

- here we definitely want 4096 bytes blocks to be utilized.

For the sake of completeness I must mention that the "solution" to the 4K partitions alignment being proposed widely on the Net:

fdisk -H 224 -S 56 /dev/sdX

- did not work for me. Not sure I am in a mood now to dig further why was that.

For the astute mind readers: there is the -b option supported by fdisk. Most probably it will work for you... once your HDD reports its physical sector size correctly.

The 4K HDD sector issues and complications are discussed in details at kernel.org.

PS. Shall you find this article talking about the things you need but not giving you the recipe you were looking for - do not hesitate and drop me a note, I'll try to be more specific then.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.