# sed -> stream editor # to create the partitions programatically (rather than manually) # we're going to simulate the manual input to fdisk # 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 "default" will send a empty # line terminated with a newline to take the fdisk default. export TGTDEV=$1 sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${TGTDEV} o # clear the in memory partition table n # new partition p # primary partition 1 # partition number 1 # default - start at beginning of disk +18G # 18GB system partition n # new partition p # primary partition 2 # partition number 2 # default, start immediately after preceding partition +1G # 1GB swap partition t # change partition type 2 # choose partition 82 # type swap n # new partition p # primary partition 3 # partion number 2 # default, start immediately after preceding partition +8G # 8GB service partition (backup) n # new partition p # primary partition # default, start immediately after preceding partition # default, extend partition to end of disk a # make a partition bootable 1 # bootable partition is partition 1 -- /dev/sda1 p # print the in-memory partition table w # write the partition table q # and we're done EOF sleep 2