https://bugzilla.novell.com/show_bug.cgi?id=642296
https://bugzilla.novell.com/show_bug.cgi?id=642296#c31
--- Comment #31 from Bob Vickers 2012-08-23 08:33:20 UTC ---
Here is another script which has worked well for me on SLES11SP2.The
combination of sleeps etc is based on trial and error, not science!
#! /bin/bash
# Delete an LVM logical volume (typically used for a snapshot that won't go
# away). See
# https://bugzilla.novell.com/show_bug.cgi?id=642296
set -o nounset
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
usage=\
" deleteLV [-n maxTries] [-t timetowait] LVdevice...
-n max number of tries (default 10)
-t time to wait after sync (default 10 seconds)"
#
# Parse the command options
declare -i maxtries=10 delay=10
ERRFLAG=OK
OPTIND=1
while getopts n:t: OPTION
do
case $OPTION in
n) maxtries=$OPTARG;;
t) delay=$OPTARG;;
\?) ERRFLAG=BAD;;
esac
done
shift `expr $OPTIND - 1`
#
# Exit with a usage message if the syntax is wrong.
#
if [ $ERRFLAG != OK -o $# -eq 0 ]
then
echo 2>&1 "$0: usage:"
echo 2>&1 "$usage"
exit 1
fi
declare -i ntries
for lv in "$@"
do
if lvs $lv >/dev/null
then
# We have a valid LVM logical volume, so repeatedly try to delete it.
ntries=0
while (( $ntries < $maxtries ))
do
ntries=$(( $ntries + 1 ))
echo >&2 "$0: Removing $lv attempt $ntries"
udevadm settle
sync
sleep $delay
lvremove -f $lv && break
done
if lvs $lv >/dev/null 2>/dev/null
then
echo >&2 "$0: FAILED to remove $lv after $ntries attempts"
else
echo >&2 "$0: Successfully removed $lv after $ntries attempt(s)"
fi
else
echo >&2 "$0: $lv is not an LVM logical volume"
fi
done
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.