Create partition aligned using parted
In order to align partition with parted
you can use --align
option. Valid alignment types are:
- none - Use the minimum alignment allowed by the disk type.
- cylinder - Align partitions to cylinders.
- minimal - Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.
- optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.
Other useful tip is that you can set the size with percentages to get it aligned. Start at 0% and end at 100%. For example:
parted -a optimal /dev/sda mkpart primary 0% 4096MB
My solution has been to use gdisk which can perform partitions alignment automatically on a 2048 sectors (1024KiB) by default, although it can be changed in the expert menu.
From the Arch Wiki:
When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:
(parted) mkpart primary fat16 0 32M
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel?
The warning means the partition start
is not aligned.
Enter Ignore
to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1MB alignment.
Additionally, just above this section, they state that the more precise IEC binary units of KiB, MiB, GiB, etc., are acceptable for units as well as the less precise KB, MB, GB, etc.
Personally, my exact command that solved this was:
mkpart hd ext4 1024KiB 8470MB
It didn't complain, I guess it wanted 1MB alignments.