1
1
#! /bin/bash
2
2
3
- version=2.0.12
3
+ version=2.0.13
4
4
5
5
# auto run grub-install if grub detected
6
6
grub_auto=1
@@ -229,7 +229,7 @@ rsync_file_system()
229
229
src_dir=" $1 "
230
230
dst_dir=" $2 "
231
231
232
- qprintf " rsync $1 $2 $3 ..."
232
+ qprintf " => rsync $1 $2 $3 ..."
233
233
234
234
if [ " $3 " == " with-root-excludes" ]
235
235
then
610
610
611
611
if [[ " $part_type " == * " ext" * ]]
612
612
then
613
- label=` e2label ${src_device[p]} 2> /dev/null`
613
+ label=` e2label ${src_device[p]} 2> /dev/null`
614
614
if [ " $label " != " " ]
615
615
then
616
616
src_label[p]=" $label "
957
957
dst_fs_type[p]=" swap"
958
958
elif [[ " $part_type " == * " ext" * ]]
959
959
then
960
- label=` e2label ${dst_device[p]} 2> /dev/null`
960
+ label=` e2label ${dst_device[p]} 2> /dev/null`
961
961
if [ " $label " != " " ]
962
962
then
963
963
dst_label[p]=" $label "
@@ -1176,7 +1176,7 @@ Use -U for unattended even if initializing.
1176
1176
image_to_sector=${src_start_sector[$image_to_part]}
1177
1177
count=$(( image_to_sector / 2 / 1024 + 4 )) # in MiB blocks for dd bs=1M
1178
1178
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 "
1180
1180
sync
1181
1181
echo " => dd if=/dev/$src_disk of=/dev/$dst_disk bs=1M count=$count ..."
1182
1182
dd if=/dev/$src_disk of=/dev/$dst_disk bs=1M count=$count
@@ -1199,7 +1199,7 @@ Use -U for unattended even if initializing.
1199
1199
sfd1=$( echo " $sfd1 " | sed " \/dev\/$part /s/size=[^,]*,//" )
1200
1200
fi
1201
1201
1202
- printf " => Resizing last partition to end of disk ..."
1202
+ printf " Resizing last partition to end of disk ..."
1203
1203
for (( x = 0 ; x < 3 ; ++ x))
1204
1204
do
1205
1205
sleep $(( x + 1 ))
@@ -1212,24 +1212,28 @@ Use -U for unattended even if initializing.
1212
1212
then
1213
1213
printf " \n====$PGM \n==orig:\n%s\n\n==edited:\n%s\n" \
1214
1214
" $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"
1216
1217
1217
1218
# Don't let dst disk keep source disk ID. Can lead to remounts.
1218
1219
new_id=$( od -A n -t x -N 4 /dev/urandom | tr -d " " )
1219
1220
qprintf " x\ni\n0x$new_id \nr\nw\nq\n" | fdisk /dev/$dst_disk > /dev/null
1220
1221
exit 1
1221
1222
fi
1222
1223
done
1223
- printf " \n Resize success.\n\n"
1224
+ printf " \n Resize success.\n"
1225
+ printf " Changing destination Disk ID ..."
1224
1226
sync
1225
1227
sleep 2
1226
1228
1227
1229
new_id=$( od -A n -t x -N 4 /dev/urandom | tr -d " " )
1228
1230
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 ..."
1229
1232
sync
1230
1233
sleep 2
1231
1234
partprobe " /dev/$dst_disk "
1232
1235
sleep 2
1236
+ echo " "
1233
1237
1234
1238
for (( p = n_image_parts + 1 ; p <= n_src_parts; p++ ))
1235
1239
do
@@ -1253,13 +1257,13 @@ Use -U for unattended even if initializing.
1253
1257
if [ " ${src_mounted_dir[p]} " == " /boot" ] && (( p == 1 ))
1254
1258
then
1255
1259
# Avoid "Volume not properly unmounted" warnings.
1256
- printf " \n => fsck -p $dst_dev ..."
1260
+ printf " => fsck -p $dst_dev ..."
1257
1261
fsck -p $dst_dev & >> /tmp/$PGM -log
1258
1262
echo " "
1259
1263
else
1260
1264
if [ " $fs_type " == " swap" ]
1261
1265
then
1262
- printf " \n => mkswap $dst_dev \n"
1266
+ printf " => mkswap $dst_dev \n"
1263
1267
mkswap $dst_dev
1264
1268
elif (( p != ext_part_num))
1265
1269
then
@@ -1272,8 +1276,9 @@ Use -U for unattended even if initializing.
1272
1276
then
1273
1277
fs_type=" vfat -F 32"
1274
1278
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"
1277
1282
echo " "
1278
1283
if (( p == n_image_parts))
1279
1284
then
@@ -1361,7 +1366,7 @@ line=$(fdisk -l /dev/$dst_disk | grep "Disk identifier:")
1361
1366
dst_disk_ID=${line#* x}
1362
1367
if [ " $dst_disk_ID " == " $src_disk_ID " ]
1363
1368
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."
1365
1370
new_id=$( od -A n -t x -N 4 /dev/urandom | tr -d " " )
1366
1371
qprintf " x\ni\n0x$new_id \nr\nw\nq\n" | fdisk /dev/$dst_disk | grep changed
1367
1372
sync
@@ -1378,7 +1383,7 @@ then
1378
1383
fi
1379
1384
1380
1385
sync
1381
- qprintf " \nSyncing file systems (can take a long time): "
1386
+ qprintf " \nSyncing file systems (can take a long time)\n "
1382
1387
1383
1388
sync_msg_done=0
1384
1389
for (( p = 1 ; p <= n_src_parts; p++ ))
1391
1396
then
1392
1397
if (( ! sync_msg_done))
1393
1398
then
1394
- qprintf " \nSyncing unmounted partitions\n"
1399
+ qprintf " Syncing unmounted partitions: \n"
1395
1400
fi
1396
1401
sync_msg_done=1
1397
1402
mount_partition ${src_device[p]} $clone_src " "
1403
1408
done
1404
1409
1405
1410
1406
- qprintf " \n=> Syncing mounted partitions\n"
1411
+ qprintf " \nSyncing mounted partitions: \n"
1407
1412
mount_partition $dst_root_dev $clone " "
1408
1413
unmount_list=" $clone "
1409
1414
@@ -1438,34 +1443,34 @@ if [ -f $cmdline_txt ]
1438
1443
then
1439
1444
if (( leave_sd_usb_boot && SD_slot_dst))
1440
1445
then
1441
- qecho " => Leaving SD to USB boot alone."
1446
+ qecho " Leaving SD to USB boot alone."
1442
1447
cp $cmdline_txt ${clone} /boot/cmdline.boot
1443
1448
cmdline_txt=${clone} /boot/cmdline.boot
1444
1449
fi
1445
1450
if grep -q $src_disk_ID $cmdline_txt
1446
1451
then
1447
- qecho " => Editing $cmdline_txt PARTUUID to use $dst_disk_ID "
1452
+ qecho " Editing $cmdline_txt PARTUUID to use $dst_disk_ID "
1448
1453
sed -i " s/${src_disk_ID} /${dst_disk_ID} /" " $cmdline_txt "
1449
1454
elif [ " $edit_fstab_name " != " " ] && grep -q ${src_part_base} $cmdline_txt
1450
1455
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 "
1452
1457
sed -i " s/${src_part_base} /$edit_fstab_name /" " $cmdline_txt "
1453
1458
fi
1454
1459
if (( leave_sd_usb_boot && SD_slot_boot))
1455
1460
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."
1457
1462
cp /boot/cmdline.txt /boot/cmdline.boot
1458
1463
cp $cmdline_txt /boot/cmdline.txt
1459
1464
fi
1460
1465
fi
1461
1466
1462
1467
if grep -q $src_disk_ID $fstab
1463
1468
then
1464
- qecho " => Editing $fstab PARTUUID to use $dst_disk_ID "
1469
+ qecho " Editing $fstab PARTUUID to use $dst_disk_ID "
1465
1470
sed -i " s/${src_disk_ID} /${dst_disk_ID} /g" " $fstab "
1466
1471
elif [ " $edit_fstab_name " != " " ] && grep -q ${src_part_base} $fstab
1467
1472
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 "
1469
1474
sed -i " s/${src_part_base} /${edit_fstab_name} /" " $fstab "
1470
1475
fi
1471
1476
1487
1492
1488
1493
if [ " $setup_args " != " " ]
1489
1494
then
1490
- qprintf " \n==> Running setup script: $setup_command $setup_args \n"
1495
+ qprintf " \nRunning setup script: $setup_command $setup_args \n"
1491
1496
$setup_command $setup_args
1492
1497
fi
1493
1498
@@ -1513,7 +1518,7 @@ then
1513
1518
echo -n $"
1514
1519
Cloned partitions are mounted on $clone for inspection or customizing.
1515
1520
1516
- Hit Enter when ready to unmount the /dev/$dst_disk partitions..."
1521
+ Hit Enter when ready to unmount the /dev/$dst_disk partitions ..."
1517
1522
1518
1523
read resp
1519
1524
fi
0 commit comments