From be8df7999be8c45206004e024eb8621ab32e0b52 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 17 Dec 2013 14:56:20 +0100 Subject: [PATCH] first stop lvm, then mdadm Signed-off-by: Steven Armstrong --- .../type/__install_reset_disk/gencode-remote | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cdist/conf/type/__install_reset_disk/gencode-remote b/cdist/conf/type/__install_reset_disk/gencode-remote index e9278a7e..e8e9cf8c 100755 --- a/cdist/conf/type/__install_reset_disk/gencode-remote +++ b/cdist/conf/type/__install_reset_disk/gencode-remote @@ -22,6 +22,15 @@ disk="/$__object_id" disk_name="${disk##*/}" cat << DONE +# stop lvm's if any +if find /sys/class/block/$disk_name*/holders/ -mindepth 1 | grep -q holders/dm; then + if command -v vgchange >/dev/null; then + vgchange -a n + else + echo "WARNING: vgchange command not found" >&2 + fi +fi + # stop mdadm raids if any if [ -r /proc/mdstat ]; then md_name="\$(awk "/$disk_name/ {print \$1}" /proc/mdstat)" @@ -35,28 +44,19 @@ if [ -r /proc/mdstat ]; then fi fi -# stop lvm's if any -if find /sys/class/block/$disk_name*/holders/ -mindepth 1 | grep -q holders/dm; then - if command -v vgchange >/dev/null; then - vgchange -a n - else - echo "WARNING: vgchange command not found" >&2 - fi -fi - -# clean disks from any legacy signatures -if command -v wipefs >/dev/null; then - wipefs -a "$disk" || true +if command -v pvremove >/dev/null; then + pvremove --force --force --yes "$disk" || true +else + echo "WARNING: pvremove command not found" >&2 fi if command -v mdadm >/dev/null; then mdadm --zero-superblock --force "$disk" || true else echo "WARNING: mdadm command not found" >&2 fi -if command -v pvremove >/dev/null; then - pvremove --force --force --yes "$disk" || true -else - echo "WARNING: pvremove command not found" >&2 +# clean disks from any legacy signatures +if command -v wipefs >/dev/null; then + wipefs -a "$disk" || true fi # erase partition table