Skip to content

Commit f3fc1cf

Browse files
committed
Merge remote-tracking branch 'framps/master'
2 parents 4335917 + 15fc0cf commit f3fc1cf

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

README.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## rpi-clone
2-
Latest version: 2.0.22
2+
Latest version: 2.0.23
3+
4+
This updated code is located in a fork of Bill Willsons git repository
5+
https://github.com/billw2/rpi-clone at https://github.com/framps/rpi-clone
36

47
Version 2 is a complete rewrite with improved capability over
58
the original. See the examples below.
@@ -45,7 +48,7 @@ only Debian packages with apt-get.
4548

4649
#### On a Raspberry Pi:
4750
```
48-
$ git clone https://github.com/billw2/rpi-clone.git
51+
$ git clone https://github.com/framps/rpi-clone.git
4952
$ cd rpi-clone
5053
$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
5154
```
@@ -66,7 +69,7 @@ add them to the rpi-clone-setup script.
6669
To install on another OS, rpi-clone may be renamed to suit. For example,
6770
on my Debian desktop I rename:
6871
```
69-
$ git clone https://github.com/billw2/rpi-clone.git
72+
$ git clone https://github.com/framps/rpi-clone.git
7073
$ cd rpi-clone
7174
$ sudo cp rpi-clone /usr/local/sbin/sys-clone
7275
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
@@ -256,7 +259,7 @@ Booted disk: mmcblk0 16.0GB Destination disk: sdb 8.0GB
256259
---------------------------------------------------------------------------
257260
Part Size FS Label Part Size FS Label
258261
1 /boot 58.4MB fat16 -- 1 8.0GB fat32 --
259-
2 root 16.0GB ext4 SD-RPI-s1
262+
2 root 16.0GB ext4 SD-RPI-s1
260263
---------------------------------------------------------------------------
261264
== Initialize: IMAGE mmcblk0 partition table to sdb - FS types mismatch ==
262265
1 /boot (22.5MB used) : IMAGE to sdb1 FSCK
@@ -271,7 +274,7 @@ Verbose mode : no
271274
272275
Initialize and clone to the destination disk sdb? (yes/no): yes
273276
Optional destination rootfs /dev/sdb2 label (16 chars max): SD-RPI-8a
274-
...
277+
...
275278
```
276279

277280
#### 2) Subsequent clone to the same SD card in USB card reader as example 1
@@ -299,7 +302,7 @@ Run setup script : rpi-clone-setup rpi2
299302
Verbose mode : no
300303
-----------------------:
301304
302-
Ok to proceed with the clone? (yes/no):
305+
Ok to proceed with the clone? (yes/no):
303306
```
304307

305308
#### 3) Cloning a Pi3 when fstab uses PARTUUID
@@ -407,7 +410,7 @@ and using rpi-clone for a clone back to the SD card slot will not work.
407410

408411

409412
#### 6) Clone to smaller 4GB SD card
410-
I happen to have an old 4GB SD card and here's a try to clone to it:
413+
I happen to have an old 4GB SD card and here's a try to clone to it:
411414
```
412415
root@rpi2: ~$ rpi-clone sda
413416
@@ -513,8 +516,8 @@ Booted disk: sda 64.2GB Destination disk: sdb 31.5GB
513516
---------------------------------------------------------------------------
514517
Part Size FS Label Part Size FS Label
515518
1 /boot 104.4MB fat32 -- 1 31.5GB fat32 --
516-
2 root 16.8GB ext4 Samsung 64GB A
517-
3 /home/pi/media 47.3GB ext4 --
519+
2 root 16.8GB ext4 Samsung 64GB A
520+
3 /home/pi/media 47.3GB ext4 --
518521
---------------------------------------------------------------------------
519522
== Initialize: IMAGE sda partition table to sdb - FS types mismatch ==
520523
1 /boot (21.5MB used) : IMAGE to sdb1 FSCK
@@ -528,7 +531,7 @@ Verbose mode : no
528531
: The partition structure will be imaged from sda.
529532
-----------------------:
530533
531-
Initialize and clone to the destination disk sdb? (yes/no):
534+
Initialize and clone to the destination disk sdb? (yes/no):
532535
```
533536
Note that if I had partitioned the 64GB disk with more than three
534537
partitions it would have been more difficult to clone down to the
@@ -550,8 +553,8 @@ Booted disk: sda 64.2GB Destination disk: mmcblk0 15.8GB
550553
---------------------------------------------------------------------------
551554
Part Size FS Label Part Size FS Label
552555
1 /boot 104.4MB fat32 -- 1 15.8GB fat32 --
553-
2 root 16.8GB ext4 Samsung 64GB A
554-
3 /home/pi/media 47.3GB ext4 --
556+
2 root 16.8GB ext4 Samsung 64GB A
557+
3 /home/pi/media 47.3GB ext4 --
555558
---------------------------------------------------------------------------
556559
Initialize required : partition - types mismatch.
557560
: The minimum destination disk size is 16.9GB
@@ -572,8 +575,8 @@ Booted disk: sda 64.2GB Destination disk: mmcblk0 15.8GB
572575
---------------------------------------------------------------------------
573576
Part Size FS Label Part Size FS Label
574577
1 /boot 104.4MB fat32 -- 1 15.8GB fat32 --
575-
2 root 16.8GB ext4 Samsung 64GB A
576-
3 /home/pi/media 47.3GB ext4 --
578+
2 root 16.8GB ext4 Samsung 64GB A
579+
3 /home/pi/media 47.3GB ext4 --
577580
---------------------------------------------------------------------------
578581
== Initialize: IMAGE sda partition table to mmcblk0 - forced by option ==
579582
1 /boot (21.5MB used) : IMAGE to mmcblk0p1 FSCK
@@ -587,7 +590,7 @@ Verbose mode : no
587590
: The partition structure will be imaged from sda.
588591
-----------------------:
589592
590-
Initialize and clone to the destination disk mmcblk0? (yes/no):
593+
Initialize and clone to the destination disk mmcblk0? (yes/no):
591594
```
592595
I'm using PARTUUID in /etc/fstab, but if I weren't, this clone would also
593596
automatically edit mmcblk0p names into the destination disk fstab.
@@ -600,14 +603,14 @@ I get an error requiring another initialize. This time the
600603
error is because rpi-clone wants to clone the mounted third partition and
601604
there is no destination third partition:
602605
```
603-
pi@rpi2: ~$ sudo rpi-clone mmcblk0
606+
pi@rpi2: ~$ sudo rpi-clone mmcblk0
604607
605608
Booted disk: sda 64.2GB Destination disk: mmcblk0 15.8GB
606609
---------------------------------------------------------------------------
607610
Part Size FS Label Part Size FS Label
608611
1 /boot 104.4MB fat32 -- 1 104.4MB fat32 --
609612
2 root 16.8GB ext4 Samsung 64GB A 2 15.7GB ext4 SD-16c
610-
3 /home/pi/media 47.3GB ext4 --
613+
3 /home/pi/media 47.3GB ext4 --
611614
---------------------------------------------------------------------------
612615
Initialize required : partition 3 /home/pi/media - destination missing.
613616
: Unmount source partitions or use -m
@@ -626,7 +629,7 @@ Booted disk: sda 64.2GB Destination disk: mmcblk0 15.8GB
626629
Part Size FS Label Part Size FS Label
627630
1 /boot 104.4MB fat32 -- 1 104.4MB fat32 --
628631
2 root 16.8GB ext4 Samsung 64GB A 2 15.7GB ext4 SD-16c
629-
3 /home/pi/media 47.3GB ext4 --
632+
3 /home/pi/media 47.3GB ext4 --
630633
---------------------------------------------------------------------------
631634
== SYNC sda file systems to mmcblk0 ==
632635
/boot (21.5MB used) : SYNC to mmcblk0p1 (104.4MB size)
@@ -636,7 +639,7 @@ Run setup script : no
636639
Verbose mode : no
637640
-----------------------:
638641
639-
Ok to proceed with the clone? (yes/no):
642+
Ok to proceed with the clone? (yes/no):
640643
```
641644

642645
#### 11) Clones from my Debian desktop
@@ -654,11 +657,11 @@ Booted disk: sda 275.1GB Destination disk: sdb 320.1GB
654657
---------------------------------------------------------------------------
655658
Part Size FS Label Part Size FS Label
656659
1 1.0GB ext4 SSD-275-G6-p1 1 320.1GB -- --
657-
2 root 52.4GB ext4 SSD-275-G6-p2
658-
3 12.6GB swap --
659-
4 209.0GB EXT --
660-
5 /home 62.9GB ext4 SSD-275-G6-p5
661-
6 /mnt/sda 146.1GB ext4 SSD-275-G6-p6
660+
2 root 52.4GB ext4 SSD-275-G6-p2
661+
3 12.6GB swap --
662+
4 209.0GB EXT --
663+
5 /home 62.9GB ext4 SSD-275-G6-p5
664+
6 /mnt/sda 146.1GB ext4 SSD-275-G6-p6
662665
---------------------------------------------------------------------------
663666
== Initialize: IMAGE sda partition table to sdb - FS types mismatch ==
664667
1 : IMAGE to sdb1
@@ -675,7 +678,7 @@ Verbose mode : no
675678
: The partition structure will be imaged from sda.
676679
-----------------------:
677680
678-
Initialize and clone to the destination disk sdb? (yes/no):
681+
Initialize and clone to the destination disk sdb? (yes/no):
679682
```
680683
And a subsequent sync to the same disk after I have manually labeled all
681684
the partitions:
@@ -703,7 +706,7 @@ Run grub : grub-install --root-directory=/mnt/clone /dev/sdb
703706
Verbose mode : no
704707
-----------------------:
705708
706-
Ok to proceed with the clone? (yes/no):
709+
Ok to proceed with the clone? (yes/no):
707710
```
708711

709712

rpi-clone

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
# the rpi-clone github source repository:
88
# https://github.com/billw2/rpi-clone
99

10+
# This updated code is located in a fork of Bill Willsons git repository
11+
# at https://github.com/framps/rpi-clone
1012

11-
version=2.0.22
13+
version=2.0.23
1214

1315
# setup trusted paths for dependancies (like rsync, grub, fdisk, etc)
1416
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
@@ -746,7 +748,6 @@ do
746748
fi
747749
done
748750

749-
750751
# command line
751752
#
752753
setup_args=""
@@ -939,6 +940,8 @@ then
939940
exit 1
940941
fi
941942

943+
cmdlinedir=$(awk '$1 !~ "^#" && $2 ~ "^/boot" && $3 == "vfat" { print substr($2, 2); exit }' /etc/fstab)
944+
942945
if ((convert_to_partuuid))
943946
then
944947
unattended=0
@@ -968,7 +971,7 @@ then
968971
cp $fstab_tmp $fstab
969972
printf "Your original fstab is backed up to $fstab_save\n"
970973

971-
cmdline_txt=$(realpath /boot/cmdline.txt)
974+
cmdline_txt=/${cmdlinedir}/cmdline.txt
972975
cmdline_save=$cmdline_txt.${PGM}-save
973976
if [ -f $cmdline_txt ] && grep -q "$src_root_dev" $cmdline_txt
974977
then
@@ -1727,15 +1730,15 @@ qecho ""
17271730
# Fix PARTUUID or device name references in cmdline.txt and fstab
17281731
#
17291732
fstab=${clone}/etc/fstab
1730-
cmdline_txt=${clone}$(realpath /boot/cmdline.txt)
1733+
cmdline_txt=${clone}/${cmdlinedir}/cmdline.txt
17311734

17321735
if [ -f $cmdline_txt ]
17331736
then
17341737
if ((leave_sd_usb_boot && SD_slot_dst))
17351738
then
17361739
qecho "Leaving SD to USB boot alone."
1737-
cp $cmdline_txt ${clone}/boot/cmdline.boot
1738-
cmdline_txt=${clone}/boot/cmdline.boot
1740+
cp $cmdline_txt ${clone}/${cmdlinedir}/cmdline.boot
1741+
cmdline_txt=${clone}/${cmdlinedir}/cmdline.boot
17391742
fi
17401743
if grep -q $src_disk_ID $cmdline_txt
17411744
then
@@ -1749,8 +1752,8 @@ then
17491752
if ((leave_sd_usb_boot && SD_slot_boot))
17501753
then
17511754
qecho "Copying USB cmdline.txt to SD card to set up USB boot."
1752-
cp /boot/cmdline.txt /boot/cmdline.boot
1753-
cp $cmdline_txt /boot/cmdline.txt
1755+
cp /${cmdlinedir}/cmdline.txt /${cmdlinedir}/cmdline.boot
1756+
cp $cmdline_txt /${cmdlinedir}/cmdline.txt
17541757
fi
17551758
fi
17561759

@@ -1764,7 +1767,6 @@ then
17641767
sed -i "s/${src_part_base}/${edit_fstab_name}/" "$fstab"
17651768
fi
17661769

1767-
17681770
rm -f $clone/etc/udev/rules.d/70-persistent-net.rules
17691771

17701772
dst_root_vol_name=`e2label $dst_root_dev`

0 commit comments

Comments
 (0)