diff --git a/docker-storage-setup.sh b/docker-storage-setup.sh index 3bbaccc..7997003 100755 --- a/docker-storage-setup.sh +++ b/docker-storage-setup.sh @@ -707,32 +707,60 @@ scan_disks() { } create_partition_sfdisk(){ - local dev="$1" size + local dev="$1" size label="$2" type # Use a single partition of a whole device # TODO: - # * Consider gpt, or unpartitioned volumes + # * Consider unpartitioned volumes # * Error handling when partition(s) already exist # * Deal with loop/nbd device names. See growpart code + size=$(( $( awk "\$4 ~ /"$( basename $dev )"/ { print \$3 }" /proc/partitions ) * 2 - 2048 )) + # if parted is not present, and this version of sfdisk + # does not support GPT then we are limited to 2TB + if [ $label = "gpt" ]; then + if $(sfdisk --help|grep gpt >/dev/null) ; then + label="label: gpt" + type="" + size=$(( $size - 34 )) #34 is the first usable sector for GPT labels + else + Info "Your version of sfdisk does not support GPT labels. Will use MBR instead but partition size will be limited to 2TB" + label="" + type=", Id=8e" + # 2TB in sectors - 2048 + if [ $size -gt 4294965248 ]; then size=4294965248; fi + fi + elif [ $label = "msdos" ]; then + label="" + fi + cat <