Skip to content

Commit 2a5d17f

Browse files
committed
Adjusted progress printing. Stop mkfs verbose output.
1 parent 41b70a4 commit 2a5d17f

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

rpi-clone

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

3-
version=2.0.12
3+
version=2.0.13
44

55
# auto run grub-install if grub detected
66
grub_auto=1
@@ -229,7 +229,7 @@ rsync_file_system()
229229
src_dir="$1"
230230
dst_dir="$2"
231231

232-
qprintf " rsync $1 $2 $3 ..."
232+
qprintf " => rsync $1 $2 $3 ..."
233233

234234
if [ "$3" == "with-root-excludes" ]
235235
then
@@ -610,7 +610,7 @@ do
610610

611611
if [[ "$part_type" == *"ext"* ]]
612612
then
613-
label=`e2label ${src_device[p]} 2>/dev/null`
613+
label=`e2label ${src_device[p]} 2> /dev/null`
614614
if [ "$label" != "" ]
615615
then
616616
src_label[p]="$label"
@@ -957,7 +957,7 @@ do
957957
dst_fs_type[p]="swap"
958958
elif [[ "$part_type" == *"ext"* ]]
959959
then
960-
label=`e2label ${dst_device[p]} 2>/dev/null`
960+
label=`e2label ${dst_device[p]} 2> /dev/null`
961961
if [ "$label" != "" ]
962962
then
963963
dst_label[p]="$label"
@@ -1176,7 +1176,7 @@ Use -U for unattended even if initializing.
11761176
image_to_sector=${src_start_sector[$image_to_part]}
11771177
count=$((image_to_sector / 2 / 1024 + 4)) # in MiB blocks for dd bs=1M
11781178

1179-
echo "Imaging past the start of $msg partition $image_to_part."
1179+
printf "\nImaging past the start of $msg partition $image_to_part.\n"
11801180
sync
11811181
echo " => dd if=/dev/$src_disk of=/dev/$dst_disk bs=1M count=$count ..."
11821182
dd if=/dev/$src_disk of=/dev/$dst_disk bs=1M count=$count
@@ -1199,7 +1199,7 @@ Use -U for unattended even if initializing.
11991199
sfd1=$(echo "$sfd1" | sed "\/dev\/$part/s/size=[^,]*,//")
12001200
fi
12011201

1202-
printf " => Resizing last partition to end of disk ..."
1202+
printf " Resizing last partition to end of disk ..."
12031203
for ((x = 0; x < 3; ++x))
12041204
do
12051205
sleep $((x + 1))
@@ -1212,24 +1212,28 @@ Use -U for unattended even if initializing.
12121212
then
12131213
printf "\n====$PGM\n==orig:\n%s\n\n==edited:\n%s\n" \
12141214
"$sfd0" "$sfd1" >> /tmp/$PGM-fail
1215-
printf "\n Resize failed. See /tmp/$PGM-fail.\n\n"
1215+
printf "\n Resize failed. See /tmp/$PGM-fail.\n"
1216+
printf " Try running $PGM again.\n\n"
12161217

12171218
# Don't let dst disk keep source disk ID. Can lead to remounts.
12181219
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
12191220
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
12201221
exit 1
12211222
fi
12221223
done
1223-
printf "\n Resize success.\n\n"
1224+
printf "\n Resize success.\n"
1225+
printf " Changing destination Disk ID ..."
12241226
sync
12251227
sleep 2
12261228

12271229
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
12281230
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
1231+
printf "\n Delaying so partprobe can update /dev entries ..."
12291232
sync
12301233
sleep 2
12311234
partprobe "/dev/$dst_disk"
12321235
sleep 2
1236+
echo ""
12331237

12341238
for ((p = n_image_parts + 1; p <= n_src_parts; p++))
12351239
do
@@ -1253,13 +1257,13 @@ Use -U for unattended even if initializing.
12531257
if [ "${src_mounted_dir[p]}" == "/boot" ] && ((p == 1))
12541258
then
12551259
# Avoid "Volume not properly unmounted" warnings.
1256-
printf "\n => fsck -p $dst_dev ..."
1260+
printf " => fsck -p $dst_dev ..."
12571261
fsck -p $dst_dev &>> /tmp/$PGM-log
12581262
echo ""
12591263
else
12601264
if [ "$fs_type" == "swap" ]
12611265
then
1262-
printf "\n => mkswap $dst_dev\n"
1266+
printf " => mkswap $dst_dev\n"
12631267
mkswap $dst_dev
12641268
elif ((p != ext_part_num))
12651269
then
@@ -1272,8 +1276,9 @@ Use -U for unattended even if initializing.
12721276
then
12731277
fs_type="vfat -F 32"
12741278
fi
1275-
printf "\n => mkfs -t $fs_type $dst_dev\n"
1276-
mkfs -t "$fs_type" "$dst_dev" <<< "yes"
1279+
printf " => mkfs -t $fs_type $dst_dev ..."
1280+
mkfs -t "$fs_type" "$dst_dev" &> /dev/null <<< "yes"
1281+
# mkfs -t "$fs_type" "$dst_dev" <<< "yes"
12771282
echo ""
12781283
if ((p == n_image_parts))
12791284
then
@@ -1361,7 +1366,7 @@ line=$(fdisk -l /dev/$dst_disk | grep "Disk identifier:")
13611366
dst_disk_ID=${line#*x}
13621367
if [ "$dst_disk_ID" == "$src_disk_ID" ]
13631368
then
1364-
qecho "=> Destination disk has same Disk ID as source, changing it."
1369+
qecho "Destination disk has same Disk ID as source, changing it."
13651370
new_id=$(od -A n -t x -N 4 /dev/urandom | tr -d " ")
13661371
qprintf "x\ni\n0x$new_id\nr\nw\nq\n" | fdisk /dev/$dst_disk | grep changed
13671372
sync
@@ -1378,7 +1383,7 @@ then
13781383
fi
13791384

13801385
sync
1381-
qprintf "\nSyncing file systems (can take a long time):"
1386+
qprintf "\nSyncing file systems (can take a long time)\n"
13821387

13831388
sync_msg_done=0
13841389
for ((p = 1; p <= n_src_parts; p++))
@@ -1391,7 +1396,7 @@ do
13911396
then
13921397
if ((!sync_msg_done))
13931398
then
1394-
qprintf "\nSyncing unmounted partitions\n"
1399+
qprintf "Syncing unmounted partitions:\n"
13951400
fi
13961401
sync_msg_done=1
13971402
mount_partition ${src_device[p]} $clone_src ""
@@ -1403,7 +1408,7 @@ do
14031408
done
14041409

14051410

1406-
qprintf "\n=> Syncing mounted partitions\n"
1411+
qprintf "\nSyncing mounted partitions:\n"
14071412
mount_partition $dst_root_dev $clone ""
14081413
unmount_list="$clone"
14091414

@@ -1438,34 +1443,34 @@ if [ -f $cmdline_txt ]
14381443
then
14391444
if ((leave_sd_usb_boot && SD_slot_dst))
14401445
then
1441-
qecho "=> Leaving SD to USB boot alone."
1446+
qecho "Leaving SD to USB boot alone."
14421447
cp $cmdline_txt ${clone}/boot/cmdline.boot
14431448
cmdline_txt=${clone}/boot/cmdline.boot
14441449
fi
14451450
if grep -q $src_disk_ID $cmdline_txt
14461451
then
1447-
qecho "=> Editing $cmdline_txt PARTUUID to use $dst_disk_ID"
1452+
qecho "Editing $cmdline_txt PARTUUID to use $dst_disk_ID"
14481453
sed -i "s/${src_disk_ID}/${dst_disk_ID}/" "$cmdline_txt"
14491454
elif [ "$edit_fstab_name" != "" ] && grep -q ${src_part_base} $cmdline_txt
14501455
then
1451-
qecho "=> Editing $cmdline_txt references from $src_part_base to $edit_fstab_name"
1456+
qecho "Editing $cmdline_txt references from $src_part_base to $edit_fstab_name"
14521457
sed -i "s/${src_part_base}/$edit_fstab_name/" "$cmdline_txt"
14531458
fi
14541459
if ((leave_sd_usb_boot && SD_slot_boot))
14551460
then
1456-
qecho "=> Copying USB cmdline.txt to SD card to set up USB boot."
1461+
qecho "Copying USB cmdline.txt to SD card to set up USB boot."
14571462
cp /boot/cmdline.txt /boot/cmdline.boot
14581463
cp $cmdline_txt /boot/cmdline.txt
14591464
fi
14601465
fi
14611466

14621467
if grep -q $src_disk_ID $fstab
14631468
then
1464-
qecho "=> Editing $fstab PARTUUID to use $dst_disk_ID"
1469+
qecho "Editing $fstab PARTUUID to use $dst_disk_ID"
14651470
sed -i "s/${src_disk_ID}/${dst_disk_ID}/g" "$fstab"
14661471
elif [ "$edit_fstab_name" != "" ] && grep -q ${src_part_base} $fstab
14671472
then
1468-
qecho "=> Editing $fstab references from $src_part_base to $edit_fstab_name"
1473+
qecho "Editing $fstab references from $src_part_base to $edit_fstab_name"
14691474
sed -i "s/${src_part_base}/${edit_fstab_name}/" "$fstab"
14701475
fi
14711476

@@ -1487,7 +1492,7 @@ fi
14871492

14881493
if [ "$setup_args" != "" ]
14891494
then
1490-
qprintf "\n==> Running setup script: $setup_command $setup_args\n"
1495+
qprintf "\nRunning setup script: $setup_command $setup_args\n"
14911496
$setup_command $setup_args
14921497
fi
14931498

@@ -1513,7 +1518,7 @@ then
15131518
echo -n $"
15141519
Cloned partitions are mounted on $clone for inspection or customizing.
15151520
1516-
Hit Enter when ready to unmount the /dev/$dst_disk partitions..."
1521+
Hit Enter when ready to unmount the /dev/$dst_disk partitions ..."
15171522

15181523
read resp
15191524
fi

0 commit comments

Comments
 (0)