From f4da3e094e6124d1a78e60538e54bdaeec44a046 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 12 Jun 2023 11:31:38 +0200 Subject: [PATCH] MT#57049 Ensure SW-RAID device is inactive before re-reading partition table Re-reading of disks fails if the mdadm SW-RAID device is still active: | root@sp1 ~ # cat /proc/mdstat | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] | md0 : active raid1 sdb3[1] sda3[0] | 468218880 blocks super 1.2 [2/2] [UU] | [========>............] resync = 42.2% (197855168/468218880) finish=22.4min speed=200756K/sec | bitmap: 3/4 pages [12KB], 65536KB chunk | | unused devices: | root@sp1 ~ # blockdev --rereadpt /dev/sdb | blockdev: ioctl error on BLKRRPART: Device or resource busy | 1 root@sp1 ~ # blockdev --rereadpt /dev/sda | blockdev: ioctl error on BLKRRPART: Device or resource busy | 1 root@sp1 ~ # Only if we stop the mdadm SW-RAID device, then we can re-read the partition table: | root@sp1 ~ # mdadm --stop /dev/md0 | mdadm: stopped /dev/md0 | root@sp1 ~ # blockdev --rereadpt /dev/sda | root@sp1 ~ # This behavior isn't new and unrelated to Debian/bookworm but was spotted while debugging an unrelated issue. FTR: we re-read the partition table (via `blockdev --rereadpt`) to ensure that /etc/fstab of the live system is up2date and matches the current system state. While this isn't stricly needed, we preserve existing behavior and also try to avoid a hard "cut" of a possibly ongoing SW-RAID sync. Change-Id: I735b00423e6efa932f74b78a38ed023576e5d306 --- templates/scripts/includes/deployment.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh index f846ed2..d60b4fb 100755 --- a/templates/scripts/includes/deployment.sh +++ b/templates/scripts/includes/deployment.sh @@ -2437,6 +2437,9 @@ if [[ "${SWRAID}" = "true" ]] ; then echo "Cloning EFI partition from ${efidev1} to ${efidev2}" dd if="${efidev1}" of="${efidev2}" bs=10M fi + + echo "Ensuring ${SWRAID_DEVICE} is stopped" + mdadm --stop "${SWRAID_DEVICE}" || true fi if ! blockdev --rereadpt "/dev/${DISK}" ; then