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
This commit is contained in:
Eric Harney 2016-08-30 10:59:52 -04:00
parent 8755de3d75
commit 5237d16d69
1 changed files with 3 additions and 1 deletions

View File

@ -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
}