Linux – Scriptable GPT Partitions Using Parted

bashlinuxpartedpartitionscripting

I am partitioning eMMC using following commands in the script,

parted /dev/mmcblk0 --script mklabel gpt
parted /dev/mmcblk0 --script mkpart primary ext4 32MB 132MB
parted /dev/mmcblk0 --script mkpart primary ext4 233MB 433MB
parted /dev/mmcblk0 --script mkpart primary ext4 433MB 533MB
parted /dev/mmcblk0 --script mkpart primary ext4 533MB 593MB
parted /dev/mmcblk0 --script mkpart primary ext4 593MB 793MB
parted /dev/mmcblk0 --script mkpart primary ext4 793MB 3800MB
parted /dev/mmcblk0 --script align-check min 1
  1. Is it the correct way to create partition in the script ? Is there any better way ?
  2. After creating first partition i am getting following warning

    Warning: The resulting partition is not properly aligned for best performance.

Do i need to worry about it ?
I tried parted /dev/mmcblk0 --script align-check min 1 but not sure that's the solution. Any pointers for that?
I am going through this link meanwhile any other suggestions ?

Edit:
Just a quick reference for frostschutz reply,

MiB = Mebibyte = 1024 KiB
KiB = Kibibyte = 1024 Bytes
MB = Megabyte = 1,000 KB
KB = Kilobyte = 1,000 Bytes

Best Answer

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.

Related Question