In case you were wondering, Linux is STILL not ready for prime time

March 7, 2011

It’s better, but its behavior when adding a new 2TB disk drive is classic Unix-stupid.

I ran the fancy-GUI program for formatting the drive, everything is looking good, I click “GO” and it proceeds to tell me (as it formats the drive) that I chose my partition alignment poorly, and performance will suck. “Repartitioning is recommended”. Oddly enough, merely repartioning the disk a second time (which is what I was doing in the first place, RIGHT?), DOES NOT MAKE IT BETTER.I am creating a 2 TERABYTE partition. If the utility “wasted” the 3584 bytes necessary to align my partition, I would NEVER NOTICE. But NO, in classic Unix fashion, it cannot do the right thing for me, it has to respect my choice, and then tell me how stupid I was to make that choice, and DOES NOT TELL ME HOW TO NOT BE STUPID. *I* am supposed to RTFM. Of course, TFM was written long before the days of 4096-byte sector disks that report 512-byte block size, so it is kinda clueless on this particular problem. (This disk quirk, by-the-way, exists to keep some Windows users happy, because an older Windows does not cope with big disk blocks.)

So instead, Google. Google tells me many things, but in particular, it says “fdisk -u”. O-KAY. I am fdisk-ing away, and the first thing I notice, is that no matter how hard I try, I can only get a terabyte of this piece of junk. Eventually, I try something I noticed mentioned several times, which is to manually specify the sector size. Still can’t have a big partition, AND when I am done, it turns out that the maximum partition size, was only 250G — 8 times smaller than the max. Hmmmmm. Sounds like someone’s not doing their math right.

That’s not what I wanted, but at this point, if I can get an aligned partition, I am happy to “waste” space on a boot partition (since I need a recovery story, that is A-OK with me). But I am thinking, you know, with a little cleverness, I can burn a little less space on my boot partition. So I try again, this time telling it to give me “+80G” space. And I get an 11G partition — just about 80/8. Looks like the same error, again.

So, one more time, I run fdisk, demanding a 4k sector, and then I tell it that I want a +640G partition. And lo, I get an “86GB” partition. The difference between 80, and 86, is that one program’s G = 10-to-the-9th, and the other program’s G = 2-to-the-30. 86G(1) = 80G(2). And if you override the sector size to fdisk, you must multiply the size by the same factor (i.e., 4096/512=8).

Whoops, not quite right, this time misaligned by 2048. TRY AGAIN!!!!!

Now I ask you, does this sound ready for the average person to use?

OH! I bet you were wondering, how I actually did it?

Step one, is to create a small partition (or two) using fdisk, being sure it is aligned. I created two. Transcript appears further below. (Note: 2048 is a multiple of 8; so the first one starts ok. 150996992 is 8 less than a multiple of 1000, therefore also a multiple of 8.)

Then, fire up the GUI “gparted”, and set the type of the partitions appropriately (e.g., ext4), and execute those commands. Do that first, because you can resize and move an ext4 partition. Next, expand the second of the two partitions to fill the rest of the disk (Partition -> Move/Resize). Do this for all the disks you want to make before applying, because it will take a long long time. Then “apply”, and go away for a few hours.

Here is the fdisk transcript:

[root@amahibox ~]# fdisk -u /dev/sdb

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): 
Command (m for help): p

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000efb6d

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3907029167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3907029167, default 3907029167): +72G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4, default 2): 
Using default value 2
First sector (150996992-3907029167, default 150996992): 
Using default value 150996992
Last sector, +sectors or +size{K,M,G} (150996992-3907029167, default 3907029167): +72G

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@amahibox ~]#

7 Responses to “In case you were wondering, Linux is STILL not ready for prime time”

  1. mrmeval Says:


    You can blame the drive makers for catering to an old standard. Eventually with enough polite outcry some incompetently made hardware gets support. Grab a debug kernel and turn on ALL messages and then read them till your eyes bleed. The worked around bugs will announce that fact, someone had fall over it and bleed a little and then politely tell a developer about it.

    Good hardware manufacturers will give out hardware specifications to open source that sometimes actually work but some manufacturers ignore that and only offer such to commercial users. In some cases that hardware is blacklisted but if you’re lucky someone provides a work around.

  2. emibcn Says:

    Just a question: isn’t it good to use fdisk as this:

    fdisk -cu -b 4096 /dev/sda

    • dr2chase Says:

      I honestly don’t know, and given the nature of the bug I ran into, the answer might change (get better) over time. But I figure your comment is an idea to try, and worth recording for the next time I have to do this.

      • emibcn Says:

        I have a new WD drive I have to partition and add to a system. I like simple things (like using -b 4096) but I don’t know how to test if this works or not. Maybe a performance check after creating the partition?

        Thanks for the fast reply!!

        • dr2chase Says:

          I never did a performance check, and after the fact, it looks like it might not matter much anyway with ext4. What I recall is that one of the tools whined at me about what a dummy I was for misaligning my partition(s).

  3. Kevin B. Says:

    You need to create a partition table of a GPT (GUID) type. By default any and all paritioners will always create an msdos partition table, which does not bode well for 2 TB and greater hard drives. A GPT disk supports 2 TB and HIGHER. Also, you’ll want to install GRUB 2 instead of GRUB Legacy as GRUB 2 supports booting a GPT. Also, one more thing, but after creating the new partition table, create a 2 MB partition and leave it as unformatted. This should and will always need to be there and its flag will be BIOS_GRUB. Fdisk does not support GPT tables but there is now gdisk, that does. Or, you can use gnu/parted if you are familiar with it. Simply type #parted /dev/sd_ and fill in the blank with your letter of the drive. Also, you can just as well use Gparted, make sure all file systems are unmount and go to the top tab “Partition” then click “New Partition Table” and -BE SURE TO CLICK DROP MENU and select “GPT” disk, not msdos and apply. Then just make the 2 MB parition first and as “unformatted” and then whatever else type and sizre parition after that. Oh, set the flagof the 2 MB to BIOS GRUB. Also, there will never been a need to create a mandatory logical volume to have more than 4 partitions either. On a GPT you can have up to 15 partitions and all as primary. And finally as for GRUB 2. always place it into /dev/sda (or the mbr).

    Don’t blame Linux, blame Microsoft for the crap msdos method THEY invented. Even Apple does not use msdos but instead uses GPT. Live and Learn. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: