diff --git a/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl b/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl index 9ab63df5e..4c5f72c50 100644 --- a/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl +++ b/ceph-osd/templates/bin/osd/ceph-volume/_common.sh.tpl @@ -213,8 +213,8 @@ function zap_extra_partitions { function disk_zap { # Run all the commands that ceph-disk zap uses to clear a disk local device=${1} - local device_filter=$(echo $device | cut -d'/' -f3) - local dm_devices=$(lsblk -o name,type -l | grep "lvm" | grep "$device_filter" | awk '/ceph/{print $1}' | tr '\n' ' ') + local device_filter=$(basename "${device}") + local dm_devices=$(get_lvm_path_from_device "pv_name=~${device_filter},lv_name=~ceph") for dm_device in ${dm_devices}; do if [[ ! -z ${dm_device} ]]; then dmsetup remove ${dm_device} @@ -384,6 +384,13 @@ function get_osd_wal_device_from_device { get_lvm_tag_from_device ${device} ceph.wal_device } +function get_lvm_path_from_device { + select="$1" + + options="--noheadings -o lv_dm_path" + pvs ${options} -S "${select}" | tr -d ' ' +} + function set_device_class { if [ ! -z "$DEVICE_CLASS" ]; then if [ "x$DEVICE_CLASS" != "x$(get_device_class)" ]; then