1234567891011121314151617181920212223242526272829303132 |
- check_device()
- {
- LVM=0
- # checking if the disk is used
- if [ ! -e ${DEVICE} ] ; then
- fatal ${NOTEX_E} "${DEVICE} does not exist"
- fi
- if [ ! -b ${DEVICE} ] ; then
- fatal ${NOTBLK_E} "${DEVICE} is not a block file"
- fi
- MAJOR=$(echo $(mountpoint --devno "${DEVICE}") | awk -F: '{print $1}')
- MINOR=$(echo $(mountpoint --devno "${DEVICE}") | awk -F: '{print $2}')
- if [ $MAJOR -ne 254 ] && [ $MAJOR -ne 8 ] || [ $(($MINOR % 16)) -ne 0 ]; then
- fatal ${WRONGBLK_E} "${DEVICE} is not a regular disk"
- fi
- if grep --quiet "${DEVICE}" /proc/mounts ; then
- fatal ${ISMOUNT_E} "${DEVICE} is mounted"
- fi
- if grep --quiet "${DEVICE}" /proc/swaps ; then
- fatal ${ISSWAP_E} "${DEVICE} is udes as swap"
- fi
- if pvs | grep --quiet "${DEVICE}" ; then
- if [ $(lvs --noheadings --select vg_name="$(pvs --noheadings --select pv_name=~"${DEVICE}" -o vg_name)" --select lv_device_open!=0 | wc -l) -ne 0 ] ; then
- fatal ${LVMUSED_E} "${DEVICE} is part of a used lvm volume"
- fi
- if [ $(vgs --noheadings --select pv_name=~"${DEVICE}" -o pv_count | uniq) -gt $(vgs --noheadings --select pv_name=~"${DEVICE}" | wc -l) ] ; then
- fatal ${LVMPV_E} "${DEVICE} is part of a lvm volume group shared with other physical volumes"
- fi
- LVM=1
- fi
- }
|