1
1
#! /bin/bash
2
2
3
- version=2.0.17
3
+ version=2.0.18
4
4
5
5
# auto run grub-install if grub detected
6
6
grub_auto=1
@@ -70,8 +70,8 @@ usage()
70
70
echo $"
71
71
usage: $PGM sdN {-v|--verbose} {-f|--force-initialize} {-f2}
72
72
{-u|--unattended} {-U|--Unattended} {-q|--quiet}
73
- {-s|--setup} {-e|--edit-fstab sdX }
74
- {-m |--mountdir dir } {-l|--leave-sd-usb-boot}
73
+ {-s|--setup host } {-e|--edit-fstab sdX } {-m|--mountdir dir }
74
+ {-L |--label-partitions label } {-l|--leave-sd-usb-boot}
75
75
{-a|--all-sync} {-F|--Force-sync} {-x} {-V|--version}
76
76
{--convert-fstab-to-partuuid}
77
77
@@ -97,6 +97,9 @@ usage: $PGM sdN {-v|--verbose} {-f|--force-initialize} {-f2}
97
97
the custom list will be synced instead of the default of all
98
98
mounted directories. The root directory is always synced.
99
99
Not for when initializing.
100
+ -L lbl - label for ext type partitions. If ends with '#', replace with
101
+ partition number and label all ext partitions. Otherwise,
102
+ apply label to root partition only.
100
103
-l - leave SD card to USB boot alone when cloning to SD card mmcblk0
101
104
from a USB boot. This preserves a SD card to USB boot setup
102
105
by leaving the SD card cmdline.txt using the USB root. When
@@ -414,6 +417,18 @@ print_options()
414
417
printf " %-22s : %s\n" " -e clone fstab edit" \
415
418
" edit $src_part_base device entries to $edit_fstab_name "
416
419
fi
420
+ if [ " $ext_label " != " " ]
421
+ then
422
+ rep=" ${ext_label: -1} "
423
+ if [ " $rep " == " #" ]
424
+ then
425
+ msg=" all ext partition types"
426
+ else
427
+ msg=" root partition only"
428
+ fi
429
+ printf " %-22s : %s\n" " -L $ext_label " \
430
+ " volume label for $msg ."
431
+ fi
417
432
if (( leave_sd_usb_boot))
418
433
then
419
434
if (( SD_slot_dst))
@@ -442,6 +457,28 @@ print_options()
442
457
printf " %-23s:\n" " -----------------------"
443
458
}
444
459
460
+ ext_label ()
461
+ {
462
+ pnum=$1
463
+ fs_type=$2
464
+ flag=$3
465
+ label_arg=" "
466
+
467
+ if [ " $ext_label " != " " ] && [[ " $fs_type " == * " ext" * ]]
468
+ then
469
+ rep=" ${ext_label: -1} "
470
+ if [ " $rep " == " #" ]
471
+ then
472
+ label_arg=${ext_label:: -1}
473
+ label_arg=" $flag $label_arg$pnum "
474
+ elif (( pnum == root_part_num))
475
+ then
476
+ label_arg=" $flag $ext_label "
477
+ fi
478
+ fi
479
+ printf -v " ${4} " " %s" " $label_arg "
480
+ }
481
+
445
482
get_src_disk ()
446
483
{
447
484
partition=${1#/ dev/ }
628
665
#
629
666
setup_args=" "
630
667
edit_fstab_name=" "
668
+ ext_label=" "
631
669
verbose=" no"
632
670
633
671
force_initialize=0
718
756
fi
719
757
custom_sync=1
720
758
;;
759
+ -L|--label_partitions)
760
+ shift
761
+ ext_label=$1
762
+ ;;
721
763
-l|--leave-sd-usb-boot)
722
764
leave_sd_usb_boot=1
723
765
;;
@@ -1170,11 +1212,10 @@ Use -U for unattended even if initializing.
1170
1212
fi
1171
1213
confirm " Initialize and clone to the destination disk ${dst_disk} ?" " abort"
1172
1214
1173
- root_label=" "
1174
- if (( ! Unattended))
1215
+ if (( ! Unattended)) && [ " $ext_label " == " " ]
1175
1216
then
1176
- printf " Optional destination rootfs $dst_root_dev label (16 chars max): "
1177
- read root_label
1217
+ printf " Optional destination ext type file system label (16 chars max): "
1218
+ read ext_label
1178
1219
fi
1179
1220
1180
1221
start_time=` date ' +%H:%M:%S' `
@@ -1282,6 +1323,11 @@ Use -U for unattended even if initializing.
1282
1323
printf " => fsck -p $dst_dev ..."
1283
1324
fsck -p $dst_dev & >> /tmp/$PGM -log
1284
1325
echo " "
1326
+ ext_label $p $fs_type " " label
1327
+ if [ " $label " != " " ]
1328
+ then
1329
+ e2label $dst_dev $label
1330
+ fi
1285
1331
else
1286
1332
if [ " $fs_type " == " swap" ]
1287
1333
then
@@ -1298,9 +1344,10 @@ Use -U for unattended even if initializing.
1298
1344
then
1299
1345
fs_type=" vfat -F 32"
1300
1346
fi
1301
- printf " => mkfs -t $fs_type $dst_dev ..."
1302
- mkfs -t " $fs_type " " $dst_dev " & >> /tmp/$PGM -output <<< " yes"
1303
- # mkfs -t "$fs_type" "$dst_dev" <<< "yes"
1347
+ ext_label $p $fs_type " -L" label
1348
+ printf " => mkfs -t $fs_type $label $dst_dev ..."
1349
+ yes | mkfs -t " $fs_type " $label " $dst_dev " & >> /tmp/$PGM -output
1350
+ # mkfs -t "$fs_type" "$dst_dev" &>> /tmp/$PGM-output <<< "yes"
1304
1351
echo " "
1305
1352
if (( p == n_image_parts))
1306
1353
then
@@ -1320,15 +1367,16 @@ Use -U for unattended even if initializing.
1320
1367
else
1321
1368
echo " "
1322
1369
fi
1370
+ ext_label $p $fs_type " " label
1371
+ if [ " $label " != " " ]
1372
+ then
1373
+ echo " e2label $dst_dev $label "
1374
+ e2label $dst_dev $label
1375
+ fi
1323
1376
fi
1324
1377
fi
1325
1378
fi
1326
1379
done
1327
-
1328
- if [ " $root_label " != " " ]
1329
- then
1330
- e2label $dst_root_dev " $root_label "
1331
- fi
1332
1380
else
1333
1381
qecho " == SYNC $src_disk file systems to $dst_disk =="
1334
1382
print_sync_actions
0 commit comments