1

I would like to partition a drive from a script, so that there is a big partition filling most of the drive, then a small one at the end. So far I have come up with.

parted -s -- /dev/sda mklabel msdos
parted -s -a optimal -- /dev/sda mkpart primary 1MiB -10GiB  
parted -s -a optimal -- /dev/sda mkpart primary -10GiB -1s

Unfortunately the last command doesn't work. It seems parted will accept a negative number for the end of a partition but not for the start. How do I get around this?

1

I finally figured this one out, it seems that while the documentation says that specifying the filesystem type is optional and normally it is, the parser can't handle a negative number when it's looking for a filesystem type.

If I change the script to specify filesystem types then it works.

parted -s -- /dev/sda mklabel msdos
parted -s -a optimal -- /dev/sda mkpart primary btrfs 1MiB -10GiB  
parted -s -a optimal -- /dev/sda mkpart primary linux-swap -10GiB -1s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.