Skip to content

Commit 5882f69

Browse files
committed
Move setting of new Disk ID to after dd.
1 parent 46c7e0f commit 5882f69

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

rpi-clone

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
version=2.0.10
3+
version=2.0.11
44

55
# auto run grub-install if grub detected
66
grub_auto=1
@@ -1182,7 +1182,11 @@ Use -U for unattended even if initializing.
11821182
dd if=/dev/$src_disk of=/dev/$dst_disk bs=1M count=$count
11831183
echo ""
11841184
sync
1185-
1185+
sleep 1
1186+
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
1187+
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
1188+
sync
1189+
sleep 1
11861190
sfd0=$(sfdisk -d /dev/$src_disk)
11871191
if ((force_2_parts && (n_src_parts > n_image_parts)))
11881192
then
@@ -1213,18 +1217,13 @@ Use -U for unattended even if initializing.
12131217
printf "\n====$PGM\n==orig:\n%s\n\n==edited:\n%s\n" \
12141218
"$sfd0" "$sfd1" >> /tmp/$PGM-fail
12151219
printf "\n Resize failed. See /tmp/$PGM-fail.\n\n"
1216-
1217-
# Don't let dst disk keep source disk ID. Can lead to remounts.
1218-
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
1219-
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
12201220
exit 1
12211221
fi
12221222
done
12231223
printf "\n Resize success.\n\n"
1224+
sync
12241225
sleep 2
1225-
1226-
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
1227-
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
1226+
partprobe "/dev/$dst_disk"
12281227

12291228
for ((p = n_image_parts + 1; p <= n_src_parts; p++))
12301229
do

0 commit comments

Comments
 (0)