check_device() { # 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 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 }