diff --git a/ceph/find-osd-device.sh b/ceph/find-osd-device.sh index 52f8c7e..75806d9 100755 --- a/ceph/find-osd-device.sh +++ b/ceph/find-osd-device.sh @@ -9,18 +9,16 @@ if [ $# -ne 1 ]; then exit 1 fi -osdid=$1; shift +osd_id=$1; shift -osd_path=/var/lib/ceph/osd/ceph-${osdid} +osd_path=/var/lib/ceph/osd/ceph-${osd_id} -mountpath=$(mount | grep "on ${osd_path} ") - -if [ -z "${mountpath}" ]; then +if ! mount | grep -q " on ${osd_path} "; then echo "Nothing mounted on ${osd_path}, are you on the right host?" exit 1 fi -blockdev=$(readlink -f ${mountpath}/block) +blockdev=$(readlink -f ${osd_path}/block) # Is directly referring to sdX? print and exit if echo $blockdev | grep -q ^/dev/sd; then @@ -29,7 +27,7 @@ if echo $blockdev | grep -q ^/dev/sd; then fi # try the non-recursive variant, resulting in finding pv/vg -blockdev=$(readlink ${mountpath}/block) +blockdev=$(readlink ${osd_path}/block) lvm_vg=$(echo $blockdev | awk -F/ '{ print $3 }') pv_name=$(pvdisplay | grep -B1 $lvm_vg | awk '/PV Name/ { print $3 }')