some tips for 4K hard drives

joetekubi

Member
Nov 6, 2009
176
0
71
Some of you may have heard that there are problems with the new 4K (or 4096 byte) sector hard drives in Linux.

Just like SSD drives with 4K sectors, performance tanks if your partition and file system is not aligned correctly.

As the the proud owner of some new WD15EARS drives, I wanted to set them up correctly. The following tips appear to have been successful.

Note, parted v 2.2 should provide a command "align-check", but it does not work correctly as of the latest Ubuntu Lucid beta-1 release.

fdisk -H 224 -S 56 /dev/sdx

Partition drives as you wish.
When you finish, run
fdisk -l -u
and I pasted the starting sector number into KCalc, and ran "modulo 8" on the numbers. Each one came out as 0, which indicated the correct alignment.

I'm not sure if this is necessary, but I then formatted the partitions with:
mke2fs -j -b 4096 -i 4096 /dev/sdx

I have not run any tests, but everything appears to be aligned correctly.

Hope this helps.
-joe

update: although my first use of this method resulted in perfectly aligned partitions automatically, I tried again last night with /dev/sde1 = 61GB. This resulted in a bit of misalignment for the subsequent partitions on the disk. I checked the starting sector number reported by fdisk and manually added a few sectors to the partition start so "num MOD 8 = 0" in each case.
 
Last edited:

amdhunter

Lifer
May 19, 2003
23,332
249
106
Does it matter if you are clean installing an OS from scratch and letting the OS decide?
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Does it matter if you are clean installing an OS from scratch and letting the OS decide?

Last I knew, no linux distros did hard drive alignment as part of a clean install. It is also good info to know in case you are partitioning a secondary hard drive.

MS has finally caught on and does automatic partition alignment since Vista. I would be happy to hear if parted is following suit. I expect fdisk to remain more of a "dumb" partitioner, but I think it would be good for parted to do automatic alignment and for distros to do automatic alignment as part of clean installs.
 

joetekubi

Member
Nov 6, 2009
176
0
71
Does it matter if you are clean installing an OS from scratch and letting the OS decide?

As far as I understand the problem, it is a partition alignment issue.
For a 4K sector drive (including SSDs), it is imperative that the
partition start on a sector number where:
start sector number xxxxxxx MOD 8 = 0

It's a difficult and confusing issue, because various partitioning utilities use different units.....
 

joetekubi

Member
Nov 6, 2009
176
0
71
I'm glad this was brought up, as it got me to revisit the issue (been manually aligning my harddrives for years). It looks likes parted may be doing automatic alignment as per a patch from January 2010:

http://www.mail-archive.com/bug-parted@gnu.org/msg02972.html
http://www.mail-archive.com/bug-parted@gnu.org/msg02903.html

I researched that issue as best I could before posting.
AFAIK, if you need GPT partitions, you must use parted.
Since I decided to use "good old" msdos partitions, I used fdisk.

I have downloaded the latest daily build of Ubuntu Lucid 10.4 Beta-1
Although parted 2.2 was supposed to fix the 4K "issue", the "align-check" command in parted is not functional, so I didn't feel I could trust it.