Scripteable GPT partitions using parted
It's correct in principle but you might consider reducing it to a single parted
call.
parted --script /device \
mklabel gpt \
mkpart primary 1MiB 100MiB \
mkpart primary 100MiB 200MiB \
...
Your alignment issue is probably because you use MB
instead of MiB
. You should not need an actual align-check
command when creating partitions on MiB
boundaries / on a known device.
I know this is old and a pretty good answer in that you can use MiB, but I'd like to throw another option out there for other folks.
Within the script call (--script or -s for the short version), you can add the -a option, which tells it to align and pass the option "optimal" when creating the partitions. Something like this:
sudo parted -s -a optimal -- /dev/sdX mkpart primary 1MiB -2048s
this is just an example of starting at the 1st Mebibyte and ending at the end of the disk minus the last Mebibyte to leave the GPT table in place.