Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is disgusting to me, but it works:

echo -e "n\np\n1\n\n\nt\nc\na\n1\nw" | fdisk /dev/sdb

I would like to know a more prudent or elegant way to accomplish this. The entire boot record and partition table is being zeroed prior to this task, so we can trust that partition 1 is available.

share|improve this question

Take a look at parted which can be used in command line mode for scripting. sfdisk can also be scripted but note the caveats about GPTs and partition sizes.

share|improve this answer
I'm sure it's in here somewhere, but I'm having a hard time finding how you can specify to use all of the available space. – andyortlieb Oct 12 '11 at 14:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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