Thursday, 22 September 2011

Tweaking partitions for optimal use of the HDD

By default Ubuntu is installed with the root filesystem at the start of the disk drive and with swap right at the end.    If one analyses the read/write performance of a hard disk drive (HDD) one will quickly spot that the I/O rates differ depending on the physical location of the data.

From the relatively small sample of laptop and desktop drives that I've looked at it seems that reads from the logical start of the drive are fastest and drop off down to roughly half that rate near the end of the drive.    The rate is higher for data on the outer tracks (because there are more data sectors) and lower toward the inner tracks (fewer data sectors).

Since my new 7200rpm 250GB drive performs fastest at the lowest logical block locations,  it makes sense to construct my partitions to utilise this.  For my configuration, I want to load my kernels and initrd in quickly and be able to swap and hibernate fairly quickly too.  Next I want applications to load quickly, and my user data (such as mp3s, cached Email, etc) I care less about for performance.   So, with these constraints, I created separate partitions in this order:

1st /boot (ext4), 2nd swap, 3rd / (ext4) and 4th /home (ext4).

Some quick'n'dirty write benchmarks show me that:

/boot : 84.74 MB/s
swap  : 84.44 MB/s
/     : 82.26 MB/s
/home : 73.30 MB/s this should make booting, swapping and hibernating just slightly faster.   Over the lifetime of the drive the random file writes and deletions in /home won't cause /boot new kernels and initrd images to be fragmented because the are on separate partitions.   Also I can avoid over-writing all my user data in /home if I do a clean installation of Ubuntu into /boot and / at a later date.


  1. Depending on the type of disk drive this sort of tweaking doesn't really work as well as it once did. Drives will rewrite and move items deep down inside so your /boot may end up eventually in the same areas as /home. It would be interesting to see if those speed times stay consistent over the life of the system (I would expect /boot probably not to change much but / would depending on the number of updates.)

  2. OK - I will re-test this every six months and see what results I get.

  3. How does this hold up with LVM partitions? In theory they could be anywhere on the disk and perhaps be fragmented in a similar way to the disk sector remapping which Smooge mentioned, but if you don't mess with the LVM partitions too much are they likely to be allocated in the same order as these physical partitions?

  4. @Legooolas, no idea. Anyone like to offer an answer?