Skip to content

Instantly share code, notes, and snippets.

@pi-aej
Last active January 15, 2016 01:25
Show Gist options
  • Save pi-aej/f5813dbe9da6de08ac76 to your computer and use it in GitHub Desktop.
Save pi-aej/f5813dbe9da6de08ac76 to your computer and use it in GitHub Desktop.
# The sed script strips off all the comments so that we can
# document what we're doing in-line with the actual commands
# Note that a blank line (commented as "defualt" will send a empty
# line terminated with a newline to take the fdisk default.
sed -e 's/\t\([\+0-9a-zA-Z]*\)[ \t].*/\1/' << EOF | fdisk /dev/sdb
d # delete existing partition
n # new partition
p # primary partition
1 # partition number 1
# default - start at beginning of disk
# default - end of disk
p # print the in-memory partition table
w # write the partition table
q # and we're done
EOF
partprobe
umount /dev/sdb1
e2fsck /dev/sdb1
resize2fs /dev/sdb1
mount -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment