2023-06-10 11:58:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Locate which block device corresponds to the OSD
|
|
|
|
# Nico Schottelius, 2023-06-10
|
|
|
|
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo $0 osdnum
|
|
|
|
echo f.i. $0 99
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-06-10 12:07:14 +00:00
|
|
|
osd_id=$1; shift
|
2023-06-10 11:58:21 +00:00
|
|
|
|
2023-06-10 12:07:14 +00:00
|
|
|
osd_path=/var/lib/ceph/osd/ceph-${osd_id}
|
2023-06-10 11:58:21 +00:00
|
|
|
|
2023-06-10 12:07:14 +00:00
|
|
|
if ! mount | grep -q " on ${osd_path} "; then
|
2023-06-10 11:58:21 +00:00
|
|
|
echo "Nothing mounted on ${osd_path}, are you on the right host?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-06-10 12:07:14 +00:00
|
|
|
blockdev=$(readlink -f ${osd_path}/block)
|
2023-06-10 11:58:21 +00:00
|
|
|
|
|
|
|
# Is directly referring to sdX? print and exit
|
|
|
|
if echo $blockdev | grep -q ^/dev/sd; then
|
|
|
|
echo $blockdev
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# try the non-recursive variant, resulting in finding pv/vg
|
2023-06-10 12:07:14 +00:00
|
|
|
blockdev=$(readlink ${osd_path}/block)
|
2023-06-10 11:58:21 +00:00
|
|
|
lvm_vg=$(echo $blockdev | awk -F/ '{ print $3 }')
|
|
|
|
|
|
|
|
pv_name=$(pvdisplay | grep -B1 $lvm_vg | awk '/PV Name/ { print $3 }')
|
|
|
|
|
|
|
|
if [ "$pv_name" ]; then
|
|
|
|
echo $pv_name
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Cannot determine block device for osd.${osdid}" >&2
|
|
|
|
exit 1
|