Skip to content

Commit 5c6384c

Browse files
committed
Merge pull request #105 from rhvgoyal/part-lsblk
use lsblk to figure out if a device is partition or not
2 parents 1c2b95b + 1be6cf3 commit 5c6384c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docker-storage-setup.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,21 @@ is_dev_part_of_vg() {
411411
return 1
412412
}
413413

414+
is_block_dev_partition() {
415+
local bdev=$1
416+
417+
[ ! -b "$bdev" ] && bdev="/dev/${bdev}"
418+
if ! disktype=$(lsblk -n --nodeps --output type ${bdev}); then
419+
Fatal "Failed to run lsblk on device $bdev"
420+
fi
421+
422+
if [ "$disktype" == "part" ];then
423+
return 0
424+
fi
425+
426+
return 1
427+
}
428+
414429
# Make sure passed in devices are valid block devies. Also make sure they
415430
# are not partitions.
416431
check_block_devs() {
@@ -423,7 +438,7 @@ check_block_devs() {
423438
Fatal "$dev is not a valid block device."
424439
fi
425440

426-
if [[ $dev =~ .*[0-9]$ ]]; then
441+
if is_block_dev_partition ${dev}; then
427442
Fatal "Partition specification unsupported at this time."
428443
fi
429444
done

0 commit comments

Comments
 (0)