First written 8 January 2011.
Updated 25 July 2015.
I bought a Western Digital
WD20EARS-00MVWB0 hard-disk to use in a FreeBSD 8.2 system. These disks have a 4KB physical sector size but lie about it:
# camcontrol identify ada0 | grep size sector size logical 512, physical 512, offset 0
Simple disk timings:
# dd if=/dev/ada0 of=/dev/null bs=1M count=1024
Sequential read: 124,100,265 bytes/sec. (median of 11 samples)
# dd if=/dev/zero of=/dev/ada0 bs=1M count=1024
Sequential write: 123,152,588 bytes/sec. (median of 11 samples again)
For UFS tests, I did this:
# fdisk -I -B ada0 # bsdlabel -w -B /dev/ada0s1 # bsdlabel -e /dev/ada0s1 size offset fstype [fsize bsize bps/cpg] a: 8388608 $ofs unused 0 0 # newfs -f $frag /dev/ada0s1a # mount /dev/ada0s1a /mnt # ( cd /mnt; time sh -c 'tar xf ~/tarball.tar; sync' )
I measured that
ada0s1 starts at offset 0x7e00 in
ada0. (32256 in decimal, or 63 sectors of 512 bytes)
bsdlabel defaulting to an offset of 16 sectors,
ada0s1a starts at 0x9e00 (40448 in decimal, or 79 sectors of 512 bytes), which is exactly one sector away from being 4K-aligned.
The UFS results (time is median of 5 samples):
Timings with ZFS - median of seven runs,
geli provider with 4K sectorsize, timing untar and sync:
|aligned partition:||10.09 secs|
|unaligned partition:||12.09 secs|
I was expecting a bigger difference, but ZFS is excellent at batching writes. Watching
zpool iostat 1 shows it sustaining platter speed for 2-3 seconds during its flush cycle.
bsdlabelsays 16, change it to 17 and your partitions will be aligned to your drive's 4K sectors.
- Make sure your partition sizes are multiples of 8.
- For small filesystems, use
newfs -f 4096to specify a 4K fragment size.
Update: (25 June 2011) Newer disks have stopped lying.
device model WDC WD20EARS-00MVWB0 (2TB) sector size logical 512, physical 512, offset 0 device model WDC WD20EARX-00PASB0 (2TB) sector size logical 512, physical 4096, offset 0
Update: (30 October 2011) My first 3TB disk:
device model WDC WD30EZRX-00MMMB0 sector size logical 512, physical 4096, offset 0
Update: (17 May 2013) My first 4TB disk:
device model ST4000DM000-1F2168 sector size logical 512, physical 4096, offset 0
Update (25 July 2015) An assortment of disks:
Device Model: WDC WD10EACS-00ZJB0 (1TB) Sector Size: 512 bytes logical/physical Device Model: ST31000528AS (1TB) Sector Size: 512 bytes logical/physical Device Model: ST31500341AS (1.5TB) Sector Size: 512 bytes logical/physical Device Model: ST2000DM001-1ER164 (2TB) Sector Sizes: 512 bytes logical, 4096 bytes physical