1

With this line:

(echo o; echo n; echo p; echo 1; echo ; echo +24G; echo a; echo t; echo 7; echo w) | fdisk /dev/sda

I can create a new active primary partition for NTFS, 24 Giga large. The syntax is ugly but effective.

How can I do the same with parted or sfdisk?

3

This is easy using parted. The -s option is used for scripting. The following produces the same results as your fdisk line:

parted -s /dev/sda mkpart primary NTFS 1 24G
  • okay, but add mklabel msdos before the mkpart (what used to be echo o in the fdisk command above). – frostschutz Oct 26 '13 at 20:42
  • @frostschutz: do you know if I can specify the "size" rather than the "end", like "+24G" in fdisk ? – antonio Oct 27 '13 at 19:18
  • 2
    @antonio parted does not support the +24G syntax. Closest you can get is using shell arithmetic instead so you can use something along the lines of parted ... $start $(($start+$size)). – frostschutz Oct 27 '13 at 19:33

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.