Disk partition alignment

Marcos Felipe Rasia de Mello <[email protected]>
Newsgroups gmane.comp.security.ipcop.devel
Message-ID <[email protected]>
The current parted commands used by the installler are

parted -s $dev mklabel msdos
parted -s $dev mkpart primary 63s ${root_size}MiB
parted -s $dev mkpart primary ${root_size}MiB ${disk_size}MiB
parted -s $dev set 1 boot on

A comment in the disk-partition.sh script says "disks are optimized
for win that had the habit until XP to start first partition at 63s".
I think this is not correct. The main reason why Vista started putting
the first partition at sector 2048 was to get good performance with
4KB physical sector hard disks. Parted started doing the same thing by
default (for all partitions) since version 2.1 as far I remember.

With "mkpart primary 63s ${root_size}MiB" and "mkpart primary
${root_size}MiB ${disk_size}MiB" IPcop will use an odd partitionig
scheme. The first partition will be missaligned with 4KB sector HDs.
*But* the second partition will be aligned, because is the default
behaviour of parted when the sector unit isn't used. This will bring
very bad performance with Western Digital drives with "Advance Format"
[1] (all models ending with "EARS") in the first parition, but not in
the second!

The Seagate 4KB drives are smarter, because they realize when the
partition is misaligned an compensate it (I have no clue how it works
internally) in the firmware (they call "SmartAlign") [2]. But I have
doubts if it work with one partiton aligned and other not.

The right way to force the old aligment is parted's "-a cylinder"
option. With the option, start of the first partition can be
represented by 0% and parted will put it in sector 63.

Maybe is a good idea IPcop fallow all major Linux distributions. All
of them use the MiB aligment now. Just replace "63s" by "0%" and it's
done. But there are reports of very broken BIOSes that refuses to boot
with the MiB alignment. Taking into account that IPcop can run very
well with old PCs (more likely to has buggy BIOS), can be dangerous..

Reference about 4KB physical sector HDs and Linux:
https://ata.wiki.kernel.org/index.php/ATA_4_KiB_sector_issues

I say this based on x86 PCs only. With other architectures I don't
know anything :)

[1] http://www.wdc.com/global/products/features/?id=7&language=1
[2] http://www.seagate.com/docs/pdf/whitepaper/tp615_smartalign_for_af_4k.pdf

And sorry, my english sucks :(

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.