Skip to content

Commit

Permalink
Run udevadm settle after running parted
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthijskooijman committed Mar 15, 2022
1 parent 2f062a9 commit 28740b4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rpi-clone
Original file line number Diff line number Diff line change
Expand Up @@ -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 " ")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28740b4

Please sign in to comment.