I'm partitioning a non-SSD hard disk with parted because I want a GPT partition table.
parted /dev/sda mklabel gpt
Now, I'm trying to create the partitions correctly aligned so I use the following command to know where the first sector begins:
parted /dev/sda unit s p free
Disk /dev/sda: 488397168s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
34s 488397134s 488397101s Free Space
We can see that it starts in sector 34 (that's the default when this partition table is used).
So, to create the first partition I tried:
parted /dev/sda mkpart primary 63s 127s
to align it on sector 64 since it's a multiple of 8 but it shows:
Warning: The resulting partition is not properly aligned for best performance.
The logical and physical sector sizes in my hard disk are both 512 bytes:
cat /sys/block/sda/queue/physical_block_size
512
cat /sys/block/sda/queue/logical_block_size
512
How do I create partitions correctly aligned? What am I doing wrong?
Best Answer
In order to align partition with
parted
you can use--align
option. Valid alignment types are: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