Re: Disk partition alignment

"Gilles Espinasse" <[email protected]>
Newsgroups gmane.comp.security.ipcop.devel
Message-ID <156601cbfcd5$197d5970$f9b5a8c0@pii350>
----- Original Message ----- 
From: "Marcos Felipe Rasia de Mello" <[email protected]>
To: <[email protected]>
Sent: Sunday, April 17, 2011 4:28 AM
Subject: [IPCop-devel] Disk partition alignment


> 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 comment is correct but the behavior has changed since XP.

> 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.
>
I had think to align to sector 2048 but haven't yet made.

> 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.
>
thank for that information.
I read TP615 that send you to MB604 document [3]
Mostly, that say you have to use VISTA sp1 or use Seagate Advanced Format
drive with Smartalign Technology or use a partition program that align
partition.

I suppose new seagate firmware is smart enough to align partition limit to
4kb sector boundaries.

> 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.
>
Why not simply use the 2048 sector shift?

> 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..
>
Anyway, we should think aligment requirement with SSD in mind.
That would mean we may require an advanced setting with aligment on erase
block boudaries (that vary greatly with disk model). I don't know if we have
a way to read the erase block size somewhere.

> 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 :)
>
Actually, pcc was broken with hardened gcc patch.
sparc was too broken there but I think it need another fix (compile gcc
against newlib to compile a 64bits kernel properly)
I haven't yet tried to fix that.

> [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
>
    [3]
http://www.seagate.com/docs/pdf/whitepaper/mb604_4k_transition_faq.pdf

Gilles


------------------------------------------------------------------------------
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.