Nicolas Barbey
Nicolas Barbey

Reputation: 6797

Fill a disk with an ext4 partition in a script

I tried to use parted for scripted partitionning like so :

parted -a optimal /dev/sda mklabel gpt mkpart primary ext4 1 -1

But it complains about -1 not being a recognized option. Still the same sub-command works in the parted prompt. So my question is how to use the same options in a script ?

Upvotes: 15

Views: 34279

Answers (3)

Nicolas Barbey
Nicolas Barbey

Reputation: 6797

Finally found a solution :

parted -s -a optimal /dev/sda mklabel gpt -- mkpart primary ext4 1 -1s

-- is very important for it to work here.

Note the use of ‘--’, to prevent the following ‘-1s’ last-sector indicator from being interpreted as an invalid command-line option.

Upvotes: 30

ᐅdevrimbaris
ᐅdevrimbaris

Reputation: 796

You can also use --script option. In this case you should put your script part in single quotes.

Example:

parted --script /dev/sda 'mkpart primary ext4 1 -1'   

Upvotes: 2

shkschneider
shkschneider

Reputation: 18243

I guess it's parted's argument parser's fault.

Try parted -a optimal /dev/sda mklabel gpt mkpart primary ext4 1 \-1 or parted -a optimal /dev/sda mklabel gpt mkpart primary ext4 1 \\-1

Upvotes: 0

Related Questions