From 5237d16d69cf54487b72dd8d12862cb4339efcbc Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 30 Aug 2016 10:59:52 -0400 Subject: [PATCH] LVM: Handle missing loop device at cleanup When the loop device is not present because something has gone wrong, this will print an error: "losetup: option requires an argument -- 'd'" Just skip the losetup -d in this case. Change-Id: Iedc439b1ae924e9a599f6522eb081b83d43190c7 --- lib/lvm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/lvm b/lib/lvm index b9d7c390a2..d35a76fb5f 100644 --- a/lib/lvm +++ b/lib/lvm @@ -58,7 +58,9 @@ function _clean_lvm_backing_file { if [[ -n "$backing_file" ]] && [[ -e "$backing_file" ]]; then local vg_dev vg_dev=$(sudo losetup -j $backing_file | awk -F':' '/'$BACKING_FILE_SUFFIX'/ { print $1}') - sudo losetup -d $vg_dev + if [[ -n "$vg_dev" ]]; then + sudo losetup -d $vg_dev + fi rm -f $backing_file fi }