[arch-general] How to align partitions?
Hi, I'd like to know how to create aligned partitions on a 160GB disk which uses a 512B sector size. (Partition table: msdos) I've got the theory [1, 2], but I can't make it work. I'd like to have three partitions: 1. ext3 ~ 100mb /boot 2. linux-swap ~ 1GB swap 3. ext3 (for the rest of the system) How to adjust the sizes? I'm planning to encrypt swap and the third partition with dm-crypt (not LUKS). Separate /boot is needed to mount and decrypt them after booting. [1] http://forums.gentoo.org/viewtopic-t-838522.html [2] http://superuser.com/questions/349887/gnu-parted-how-to-deal-with-the-error-... Thanks
On Thu, Aug 30, 2012 at 4:24 PM, Stayvoid <stayvoid@gmail.com> wrote:
Hi,
I'd like to know how to create aligned partitions on a 160GB disk which uses a 512B sector size.
Almost all recent HDD/SSD have 4KiB internal sector (even when reported as 512B by ATA). Read [1].
(Partition table: msdos)
I've got the theory [1, 2], but I can't make it work.
I'd like to have three partitions: 1. ext3 ~ 100mb /boot 2. linux-swap ~ 1GB swap 3. ext3 (for the rest of the system)
How to adjust the sizes? Recent versions of fdiks, parted, gdisk do it for you. This is boring in some cases.
[1] https://ata.wiki.kernel.org/index.php/ATA_4_KiB_sector_issues -- Sébastien "Seblu" Luttringer www.seblu.net
Recent versions of fdiks, parted, gdisk do it for you.
I use parted. AFAICT it can tell that partitions aren't aligned, but there is no option to do it automatically. Could you help me to do the math? All these bytes give me a headache. Thanks
On Friday 31 Aug 2012 01:45:40 Stayvoid wrote:
Recent versions of fdiks, parted, gdisk do it for you.
I use parted. AFAICT it can tell that partitions aren't aligned, but there is no option to do it automatically.
Could you help me to do the math? All these bytes give me a headache.
Thanks
This is what I do: In parted, enter "unit b" to switch to bytes, because then you know what you're working with. I like to start my first partition at 1048576, which is 1Mb into the disk, and end it at 104857599, which makes it 99Mb long. After that, I use a single partition spanning the rest of the disk, starting at 104857600 (100Mb), and ending at a multiple of (1024*1024=1048576). I use LMV or RAID+LVM on top of that. Don't forget that the end point for each partition will be one byte before a Mb marker, so my first partition, ending at 104857599, is 1b before the 99Mb mark. The size of the partition includes this end byte, so the partition is a full 99Mb's worth of bytes. I hope this helps, Paul
On Sep 3, 2012 4:41 PM, "Paul Gideon Dann" <pdgiddie@gmail.com> wrote:
On Friday 31 Aug 2012 01:45:40 Stayvoid wrote:
Recent versions of fdiks, parted, gdisk do it for you.
I use parted. AFAICT it can tell that partitions aren't aligned, but there is no option to do it automatically.
Could you help me to do the math? All these bytes give me a headache.
Thanks
This is what I do:
In parted, enter "unit b" to switch to bytes, because then you know what you're working with.
I like to start my first partition at 1048576, which is 1Mb into the
disk, and
end it at 104857599, which makes it 99Mb long. After that, I use a single partition spanning the rest of the disk, starting at 104857600 (100Mb), and ending at a multiple of (1024*1024=1048576). I use LMV or RAID+LVM on top of that.
Don't forget that the end point for each partition will be one byte before a Mb marker, so my first partition, ending at 104857599, is 1b before the 99Mb mark. The size of the partition includes this end byte, so the partition is a full 99Mb's worth of bytes.
Yuk! :-) I'd only change the unit setting: u mib ... much simpler than bytes, and then +1 and -1 are always aligned (and appropriate for MBR) I simply leave ~1mib gap between partitions ... something like: mkpart pri ... 1 129 mkpart pri ... 130 1154 mkpart pri ... 1155 -1 ... seems to work universally. -- C Anthony
On Mon, Sep 3, 2012 at 11:19 PM, C Anthony Risinger <anthony@xtfx.me> wrote:
Yuk! :-) I'd only change the unit setting:
u mib
... much simpler than bytes, and then +1 and -1 are always aligned (and appropriate for MBR)
I simply leave ~1mib gap between partitions ... something like:
mkpart pri ... 1 129 mkpart pri ... 130 1154 mkpart pri ... 1155 -1
... seems to work universally.
er, my mistake ... i *used* to leave a 1MiB gap, but as long as the default unit is MiB, and you specify offsets using simple integers, parted will automatically start/end on the correct byte: (parted) u mib (parted) mkpart pri 1 129 (parted) mkpart pri 129 641 (parted) p [...] Number Start End Size File system Name Flags 1 1.00MiB 129MiB 128MiB 2 129MiB 641MiB 512MiB (parted) u b (parted) p Number Start End Size File system Name Flags 1 1048576B 135266303B 134217728B 2 135266304B 672137215B 536870912B -- C Anthony
On Monday 03 Sep 2012 23:34:34 C Anthony Risinger wrote:
On Mon, Sep 3, 2012 at 11:19 PM, C Anthony Risinger <anthony@xtfx.me> wrote:
Yuk! :-) I'd only change the unit setting:
u mib
... much simpler than bytes, and then +1 and -1 are always aligned (and appropriate for MBR)
I simply leave ~1mib gap between partitions ... something like:
mkpart pri ... 1 129 mkpart pri ... 130 1154 mkpart pri ... 1155 -1
... seems to work universally.
er, my mistake ... i *used* to leave a 1MiB gap, but as long as the default unit is MiB, and you specify offsets using simple integers, parted will automatically start/end on the correct byte:
(parted) u mib (parted) mkpart pri 1 129 (parted) mkpart pri 129 641 (parted) p [...] Number Start End Size File system Name Flags 1 1.00MiB 129MiB 128MiB 2 129MiB 641MiB 512MiB
(parted) u b (parted) p Number Start End Size File system Name Flags 1 1048576B 135266303B 134217728B 2 135266304B 672137215B 536870912B
Thanks, excellent tip. I wasn't aware of the mib option. Paul
Could you help me to do the math? All these bytes give me a headache.
I used fdisk. Looks like that it automatically aligns everything. Could anyone confirm this? Cheers
The 03/09/12, Paul Gideon Dann wrote:
I like to start my first partition at 1048576, which is 1Mb into the disk, and end it at 104857599, which makes it 99Mb long. After that, I use a single partition spanning the rest of the disk, starting at 104857600 (100Mb), and ending at a multiple of (1024*1024=1048576). I use LMV or RAID+LVM on top of that.
LVM needs dedicated configuration, too. AFAIK, some RAID can't be aligned at all due to metadata. A good article is from Theodore Ts'o: http://tytso.livejournal.com/2009/02/20/ -- Nicolas Sebrecht
participants (5)
-
C Anthony Risinger
-
Nicolas Sebrecht
-
Paul Gideon Dann
-
Stayvoid
-
Sébastien Luttringer