From 28740b48ddb8d0be70e5ee1352830f1a1d584964 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 15 Mar 2022 16:59:19 +0100 Subject: [PATCH] Run udevadm settle after running parted It seems that parted can force a partition scan (observed on a removable USB disk), which temporaly clears the filesystem labels from lsblk output. To prevent this, call udevadm settle to wait until all udev events are processed before continuing. --- rpi-clone | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rpi-clone b/rpi-clone index 32abda5..38ea16d 100755 --- a/rpi-clone +++ b/rpi-clone @@ -692,6 +692,9 @@ fi # src_partition_table=$(parted --script -m "/dev/$src_disk" unit s print | tr -d ';') src_fdisk_table=$(fdisk -l /dev/$src_disk | grep "^/dev/") +# Parted seems to force a partition rescan, which hides fs labels from +# lsblk output. Wait for kernel/udev to be done processing. +udevadm tmp=$(df | grep -e "^/dev/$src_disk" -e "^/dev/root" -e "$src_root_dev" \ | tr -s " ") @@ -1138,6 +1141,10 @@ then fi dst_partition_table=$(parted --script -m "/dev/$dst_disk" unit s print | tr -d ';') +# Parted seems to force a partition rescan, which hides fs labels from +# lsblk output. Wait for kernel/udev to be done processing. +udevadm + n_dst_parts=$(echo "$dst_partition_table" | tail -n 1 | cut -d ":" -f 1) if [ "$n_dst_parts" == "/dev/$dst_disk" ] then