|
|
Subscribe / Log in / New account

unaligned partitions

unaligned partitions

Posted Feb 24, 2011 16:14 UTC (Thu) by mgedmin (subscriber, #34497)
In reply to: unaligned partitions by alex
Parent article: Optimizing Linux with cheap flash drives

How do you check for partition alignment? fdisk -u -l /dev/sdX?

I'm guessing 63 sectors (of 512 bytes) is not a good alignment?

Are there any tools for fixing partition alignment? Does parted's "move" command shift the data in the partition, or just adjust the boundaries in the partition table?


to post comments

unaligned partitions

Posted Feb 24, 2011 18:53 UTC (Thu) by meyering (guest, #48285) [Link]

You can make parted list the partition table in units of sectors,
then ensure that (assuming 512-byte sectors) each partition's
start sector is divisible by some round number, like 2048
if you want them to be 1MiB-aligned.

For example, here all partitions are MiB-aligned, except
for the first one, which is only 32KiB-aligned. But since it's
only for grub, that is ok:

$ parted -m -s -- /dev/sdb u s p free
BYT;
/dev/sdb:117231408s:scsi:512:512:gpt:ATA OCZ-VERTEX2;
1:34s:63s:30s:free;
1:64s:4095s:4032s:ext2:_grub_bios:bios_grub;
2:4096s:1048575s:1044480s:ext3:_/boot:boot;
3:1048576s:12582911s:11534336s:ext4:_/:;
4:12582912s:16777215s:4194304s:linux-swap(v1):_/swap:;
5:16777216s:37748735s:20971520s:ext4:_/usr:;
6:37748736s:52428799s:14680064s:ext4:_/var:;
7:52428800s:52449279s:20480s:ext4:_/full:;
8:52449280s:117229567s:64780288s:ext4:_/h:;
1:117229568s:117231374s:1807s:free;

Please do not use parted's "move" command. It is risky since it tries
to be smart and is file-system aware. In addition to moving the partition
it may try to move an embedded file system, too, but its built-in FS-aware
code is so old and unreliable that it is slated to be removed altogether.

If you try to use that sub-command (or e.g., mkpartfs which is in the same
boat), recent versions of parted will emit a big warning telling you some
of the above.

unaligned partitions

Posted Feb 25, 2011 0:15 UTC (Fri) by jnh (subscriber, #69758) [Link]

It depends on the physical sector size of the device. If you have physical sectors of 512 bytes, then partitions measured in 512 logical sectors are aligned regardless of where they start; with larger physical sectors, starting a partition at LBA 63 isn't going to be aligned. Annoyingly, many SSDs do not correctly report their true internal topology, so even modern partitioning tools which can use that information may need to be given hints, but that said, it isn't immediately clear to me exactly what an SSD should report its topology as given the current interfaces.

I recommend reading Martin K. Petersen's advanced storage papers from
http://oss.oracle.com/~mkp/


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds