Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Linux and Advanced Format Drives
As some hard drive buyers might be aware, [4K-sector]( hard drives have already appeared in the market. Anandtech has [a quick primer on these Advanced Format drives](, and how they're different.
One point to nitpick on, though: while Linux is capable of creating aligned partitions, not all its partitioning tools do so by default. [GParted]( creates an `msdos` [partition table]( on new drives by default, and it starts at LBA 63. The result of this is a noticeable slowdown in file transfer to and from the Advanced Format drive.
At the time of this post, the only drives available with 4K-sectors are the [Western Digital Caviar Green Series](, designated with the model name EARS (the older models are labelled EADS). If you are using one of these new drives under Linux, you should personally ensure that the partition starts on a [mod-8]( LBA in order to avoid unpleasant performance loss. [A quick guide is available]( over at the WDC forums.
A summarised snippet of the code:
parted /dev/DEVICE_NAME
(parted) mklabel gpt
(parted) unit s
(parted) mkpart primary ext4 40 -1
(parted) quit
mkfs.ext4 -T largefile4 /dev/DEVICE_NAME
# Boosting Advanced Foramt drive performance
Once again, a little `hdparm` trickery seems to be the trick to getting the [WD Caviar Green]( EARS-series to perform as expected.
From the [hdparm]( man page:
> -m
> Get/set sector count for multiple sector I/O on the drive. A setting of **0** disables this feature. Multiple sector mode (aka IDE Block Mode), is a feature of most modern IDE hard drives, permitting the transfer of multiple sectors per I/O interrupt, rather than the usual one sector per interrupt.
> When this feature is enabled, it typically reduces operating system overhead for disk I/O by 30-50%. On many systems, it also provides increased data throughput of anywhere from 5% to 50%. Some drives, however (most notably the WD Caviar series), seem to run slower with multiple mode enabled. Your mileage may vary.
> Most drives support the minimum settings of 2, 4, 8, or 16 (sectors). Larger settings may also be possible, depending on the drive. A setting of 16 or 32 seems optimal on many systems. Western Digital recommends lower settings of 4 to 8 on many of their drives, due tiny (32kB) drive buffers and non-optimized buffering algorithms.
> The **-i** flag can be used to find the maximum setting supported by an installed drive (look for MaxMultSect in the output). Some drives claim to support multiple mode, but lose data at some settings. Under rare circumstances, such failures can result in **massive filesystem corruption**.
The WD10EARS has a `MaxMultSect` value of 16.
$ hdparm -i /dev/sdc
Model=WDC WD10EARS-00Y5B1, FwRev=80.00A80, SerialNo=WD-WMAV51402824
Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=50
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=off
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=1953525168
IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes:  pio0 pio3 pio4
DMA modes:  mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
AdvancedPM=no WriteCache=enabled
Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7
* signifies the current active mode
$ hdparm -m /dev/sdc
multcount = 0 (off)
$ hdparm -m 16 /dev/sdc
setting multcount to 16
Use of -m is VERY DANGEROUS.
Only the old IDE drivers work correctly with -m with kernels up to at least 2.6.29.
libata drives may fail and get hung if you set this flag.
Please supply the --yes-i-know-what-i-am-doing flag if you really want this.
Program aborted.
$ hdparm --yes-i-know-what-i-am-doing -m 16 /dev/sdc
setting multcount to 16
multcount = 16 (on)
Before “-m 16”: 40-50MB/s writes
After “-m 16”: 90MB/s writes
Now that's more like it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment