Skip to content

Instantly share code, notes, and snippets.

@ricfeatherstone
Created June 10, 2015 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricfeatherstone/c49fe09cd546a979a3a6 to your computer and use it in GitHub Desktop.
Save ricfeatherstone/c49fe09cd546a979a3a6 to your computer and use it in GitHub Desktop.
#!/bin/bash
config=$(gdisk /dev/xvda <<EOF
p
q
EOF
)
disk_guid=$(echo $config | awk '{print($45)}')
part1_start=$(echo $config | awk '{print($87)}')
part1_end=$(echo $config | awk '{print($88)}')
part1_code=$(echo $config | awk '{print($91)}')
part2_start=$(echo $config | awk '{print($96)}')
part2_code=$(echo $config | awk '{print($100)}')
gdisk /dev/xvda <<EOCOMMAND
o
y
n
1
$part1_start
$part1_end
$part1_code
n
2
$part2_start
$part2_code
x
g
$disk_guid
w
y
EOCOMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment