Commit 9ec298c7 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Use sgdisk to create gpt partitions

parent b0cb7802
......@@ -371,10 +371,17 @@ create_partition() {
local name="${fields[5]}"
local flags="${fields[6]//,/ }"
$PARTED -s -m -- $device mkpart "$ptype" $fs "$start" "$end"
for flag in $flags; do
$PARTED -s -m $device set "$id" "$flag" on
if [ "$ptype" = "primary" -o "$ptype" = "logical" -o "$ptype" = "extended" ]; then
$PARTED -s -m -- $device mkpart "$ptype" $fs "$start" "$end"
for flag in $flags; do
$PARTED -s -m $device set "$id" "$flag" on
# For gpt
start=${start:0:${#start}-1} # remove the s at the end
end=${end:0:${#end}-1} # remove the s at the end
$SGDISK -n "$id":"$start":"$end" -t "$id":"$ptype" "$device"
enlarge_partition() {
......@@ -89,11 +89,8 @@ fi
if [ "$table_type" != "msdos" ]; then
# Primary, extended and logical partitions is a concept for msdos partition
# tables. Parted's mkpart will use part-type as partition name if applied
# on a gpt table and leaving this empty is fragile: For a strange reason
# for swap partitions the command fails (???)
# For gpt partitions, get the partition GUID code as partition type
last_part_type="$($SGDISK -i "$last_part_id" "$SNF_IMAGE_DEV" | grep "^Partition GUID code:" | cut -d"(" -f1 | cut -d: -f2 | xargs echo)"
elif [ $last_part_id -gt 4 ]; then
extended=$(get_extended_partition "$table")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment