Scripteable GPT partitions using parted

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x