Browse code

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

Eric Harney authored on 2016/08/30 23:59:52
Showing 1 changed files
... ...
@@ -58,7 +58,9 @@ function _clean_lvm_backing_file {
58 58
     if [[ -n "$backing_file" ]] && [[ -e "$backing_file" ]]; then
59 59
         local vg_dev
60 60
         vg_dev=$(sudo losetup -j $backing_file | awk -F':' '/'$BACKING_FILE_SUFFIX'/ { print $1}')
61
-        sudo losetup -d $vg_dev
61
+        if [[ -n "$vg_dev" ]]; then
62
+            sudo losetup -d $vg_dev
63
+        fi
62 64
         rm -f $backing_file
63 65
     fi
64 66
 }