First I create a properly aligned partition in a new GPT table using parted by specifying percentages for start and end of the partition:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
(parted) mkpart primary 0% 1%
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB primary
(parted) quit
Note that this disk is using Advanced Format, but correctly reports the physical sector size of 4096B
to Parted. Let's look at it again, using sectors as the unit:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 2048s 4095s 2048s primary
(parted) quit
- Why did it start the partition at
2048s
and not34s
which is the first possible sector? 34s
is not a properly aligned start sector if the physical sector size is4096B
and the logical (which is the one you specify in Parted) sector size is512B
. A properly aligned start sector is one divisable by8
(since physical sector size / logical sector size =8
). But that means40s
is the first properly aligned start sector, yet it's not used. Why?
If we try to create a properly aligned partition of 100MiB
capacity starting at 40s
in a fresh GPT partition table:
# parted -a optimal /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Y
(parted) mkpart primary 40s 204839s
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I
(parted) unit MiB
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 2861588MiB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 0.02MiB 100MiB 100MiB fat32 primary
(parted)
(parted) unit s
(parted) p
Model: ATA WDC WD30EZRX-00M (scsi)
Disk /dev/sdb: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Number Start End Size File system Name Flags
1 40s 204839s 204800s fat32 primary
(parted)
- We still get the
Warning: The resulting partition is not properly aligned for best performance.
warning, even though40s
and 204840s (204839s
+ 1) are both divisable by8
. Why?
Best Answer
Parted is just being overly conservative. The usual practice these days is to align partitions on 1MiB (2048-sector) boundaries because this works on Advanced Format disks, on certain type of RAID setups that require alignment, and on most SSDs. For an Advanced Format disk, so long as the alignment is on a multiple of 8, you're fine, and 2048 is a multiple of 8. The lost disk space is puny -- 0.0000336% of your total disk space, if I did the math right and didn't mistype anything. So don't worry about it; just use the 1MiB alignment.