41 lines
873 B
Bash
Executable file
41 lines
873 B
Bash
Executable file
#!/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
|
|
|
|
osd_id=$1; shift
|
|
|
|
osd_path=/var/lib/ceph/osd/ceph-${osd_id}
|
|
|
|
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 ${osd_path}/block)
|
|
|
|
# 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
|
|
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 }')
|
|
|
|
if [ "$pv_name" ]; then
|
|
echo $pv_name
|
|
exit 0
|
|
fi
|
|
|
|
echo "Cannot determine block device for osd.${osdid}" >&2
|
|
exit 1
|