From a8cf5e774b5025b95f21f824f20e59fcdabfb49a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 16 May 2016 12:01:35 +0300 Subject: [PATCH] Handle partition names like "loop0p1" This also assumes that the block device for the partition is available right after "udevadm settle". Fixes #137 --- docker-storage-setup.sh | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/docker-storage-setup.sh b/docker-storage-setup.sh index f3ad571..091c953 100755 --- a/docker-storage-setup.sh +++ b/docker-storage-setup.sh @@ -608,12 +608,11 @@ scan_disks() { local new_disks="" for dev in $DEVS_ABS; do - local basename=$(basename $dev) - local p + local part=$(query_first_child $dev) - if is_dev_part_of_vg ${dev}1 $VG; then - Info "Device ${dev} is already partitioned and is part of volume group $VG" - continue + if [ -n "$part" ] && is_dev_part_of_vg ${part} $VG; then + Info "Device ${dev} is already partitioned and is part of volume group $VG" + continue fi # If signatures are being overridden, then simply return the disk as new @@ -623,9 +622,7 @@ scan_disks() { continue fi - # If device does not have partitions, it is a new disk requiring processing. - p=$(awk "\$4 ~ /${basename}./ {print \$4}" /proc/partitions) - if [[ -z "$p" ]]; then + if [ -z "$part" ]; then new_disks="$dev $new_disks" continue fi @@ -643,12 +640,11 @@ create_partition() { # TODO: # * Consider gpt, or 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 )) - cat <