partition alignment

i’ve got new hdd delivered. it’ll be used as one of rotated disks for offline backup storage.
it is WDC WD15EARS-00Z5B1 – WD Caviar Green 1.5 TB and is one of first disks with 4kB physical sectors instead of 512B ones. i’ve read at some places about performance impact of miss-aligned linux partitions for write performance, so i decided to test it by myself.

first i’ve create partitions using cfdisk – one primary with default start at 63rh sector [ that translates to 63*512 = 32256 cannot be divided by 4096 without leaving a reminder – so partition is not aligned to 4kB sectors ].

root@gk-desktop:~# parted -s /dev/sdb unit s print
Model: ATA WDC WD15EARS-00Z (scsi)
Disk /dev/sdb: 2930277168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start  End         Size        Type     File system  Flags
 1      63s    390620474s  390620412s  primary  ext3

average results of few runs of bonnie++ were:

Sequential Output Block: 29MB/s
Sequential Output Rewrite: 20MB/s

after aligning the partition:

root@gk-desktop:~# fdisk /dev/sdb
# + partprobe /dev/sdb
# + mkfs.ext3
Model: ATA WDC WD15EARS-00Z (scsi)
Disk /dev/sdb: 2930277168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start  End         Size        Type     File system  Flags
 1      128s   390620474s  390620347s  primary  ext3

i got much better avg write speeds:

Sequential Output Block: 70MB/s
Sequential Output Rewrite: 37MB/s

so.. yeah – definitively – aligning is worth the trouble! the same procedure [ and performance gain ] applies to all sorts of raid that use striping – raid5, raid10, raid6 etc.. but this time you should align to your stripe-size [probably 64kB or so].

truecrypt sidenote. at this forum i’ve found:

“When I encrypted the partition with Truecrypt, I only got 8Mbyte/sec because it does not place the start of the volume at sector 8192, but instead it places the volume at the end of the track which 8192 belongs to. I have 63 sectors per track, so sector 8192 is the second sector of the 130th track. Truecrypt started its volume at the end of this track (sector number 8252), which is 60 sectors too far. So the solution was to move the partition back by 60 sectors, so the partition started at 8132 instead of 8192. This caused the first sector of the Truecrypt volume to be located at the magic sector 8192. ”

which i’m about to test….

creating new partitions on an empty drive:

eskvirt0:~# parted /dev/sdc
(parted) mklabel gpt
(parted) mkpart primary ext4 1 -1
(parted) quit
eskvirt0:~# parted -s /dev/sdc unit s print
Model: ATA Hitachi HDS72303 (scsi)
Disk /dev/sdc: 5860533168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End          Size         File system  Name     Flags
 1      2048s  5860532223s  5860530176s               primary

some wd green disks have annoying feature – they park the head if disk inactive for 8sec; in 24×7 server case that does not make much sense and can lead to premature death of the drive. there are ways to disable it [ this or that ], but wdidle3 crashed for me with “Unrecoverable exception. Program terminated”. so i ended up using band-aid solution – simple cron script /etc/cron.d/wdc:

* * * * * root for i in `seq 0 10`; do  /usr/sbin/smartctl -i -d sat /dev/sdc > /dev/null ; sleep 6 ; done;

[inspired by this thread; although their solution did not work, maybe due to caching ].

Leave a Reply

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

(Spamcheck Enabled)