Skip to content

Commit 24f1d5f

Browse files
committed
Add desktop example to README. Mention grub-install in summary.
1 parent 896fd9f commit 24f1d5f

File tree

2 files changed

+111
-15
lines changed

2 files changed

+111
-15
lines changed

README.md

Lines changed: 89 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,27 @@ add them to the rpi-clone-setup script.
8585
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
8686
```
8787

88-
If your other OS is a SD card booted system, it will possibly work.
88+
If your other OS is a SD card booted system, it will possibly work because
89+
an initialize clone images a first /boot partition.
8990
However it currently does not work for emmc booted devices.
9091

91-
rpi-clone does not directly support usage on a desktop OS.
92-
However, I do use it with my Debian desktop because my setup script
93-
handles my /etc/grub.d/ custom menus and fstab, and the script runs
94-
grub_install. rpi-clone does handle editing of
95-
PARTUUID values in /etc/fstab, but a customized setup script for
96-
a desktop might need to handle file system UUID values or device
97-
name editing in /etc/fstab and the bootloader config. If these possible
98-
issues are handled in a setup script, then rpi-clone should work fine
99-
creating clone backup disks for a desktop.
92+
rpi-clone does not directly support usage on a desktop OS because there
93+
are different possible bootloaders and while device names or PARTUUID
94+
are handled for /etc/fstab, UUID is not handled.
95+
However, it works for me and I use rpi-clone renamed as sys-clone on
96+
my Debian desktop because I use PARTUUID in my fstab and I use the grub
97+
bootloader (rpi-clone will run grub-install if it detects it installed
98+
and there is a /boot/grub directory). Using PARTUUID makes fstab
99+
editing simple because only a single number identifies the entire disk.
100+
I do have possible ambiguity in my grub menu setup because I only use
101+
device names in my menu entries while the fstab uses PARTUUID.
102+
But what actually happens is that with a root=/dev/sda2 in my grub menu
103+
default boot line, a USB disk will boot as sda if I have the disk plugged
104+
in when booting, which is what I want. Device names in fstab are a bad
105+
idea when doing this because the USB disk root partition could boot and then
106+
mount my internal drive partitions instead of the USB partitions. But
107+
I use PARTUUID so there will not be cross mounting. And I have a couple
108+
of extra grub menu entries with other root variations just in case.
100109

101110
## Usage
102111
To get a usage screen showing available options,
@@ -212,6 +221,8 @@ If it is not, then the clone will have to be to a two partition -f2
212221
clone or a clone to a manually partitioned destination. So, for a
213222
multi partition disk, select partition number and sizes with a eye
214223
towards how you will be cloning back to smaller disks.
224+
11. Desktop demo
225+
215226

216227
#### 1) First clone to a new SD card in USB card reader
217228
In this example a new SD card in a USB card reader has been plugged in
@@ -621,6 +632,74 @@ Verbose mode : no
621632
Ok to proceed with the clone? (yes/no):
622633
```
623634

635+
#### 11) Clones from my Debian desktop
636+
Here are a couple of runs to show how rpi-clone looks handling more complex
637+
partitioning on my desktop. I have three primary partitions and extra
638+
extended partitions. I don't have a separate /boot partition but have
639+
a small first partition in case I want to change that.
640+
It probably won't work if there is a primary partition
641+
after an extended partition.
642+
```
643+
~$ sudo sys-clone sdb
644+
/usr/sbin/grub-install
645+
646+
Booted disk: sda 275.1GB Destination disk: sdb 320.1GB
647+
---------------------------------------------------------------------------
648+
Part Size FS Label Part Size FS Label
649+
1 1.0GB ext4 SSD-275-G6-p1 1 320.1GB -- --
650+
2 root 52.4GB ext4 SSD-275-G6-p2
651+
3 12.6GB swap --
652+
4 209.0GB EXT --
653+
5 /home 62.9GB ext4 SSD-275-G6-p5
654+
6 /mnt/sda 146.1GB ext4 SSD-275-G6-p6
655+
---------------------------------------------------------------------------
656+
== Initialize: IMAGE sda partition table to sdb - FS types mismatch ==
657+
1 : IMAGE to sdb1
658+
2 root (15.3GB used) : MKFS SYNC to sdb2
659+
3 : MKSWAP
660+
5 /home (12.9GB used) : MKFS SYNC to sdb5
661+
6 /mnt/sda (73.1GB used) : RESIZE(191.1GB) MKFS SYNC to sdb6
662+
---------------------------------------------------------------------------
663+
Run setup script : no
664+
Run grub : grub-install --root-directory=/mnt/clone /dev/sdb
665+
Verbose mode : no
666+
-----------------------:
667+
** WARNING ** : All destination disk sdb data will be overwritten!
668+
: The partition structure will be imaged from sda.
669+
-----------------------:
670+
671+
Initialize and clone to the destination disk sdb? (yes/no):
672+
```
673+
And a subsequent sync to the same disk after I have manually labeled all
674+
the partitions:
675+
```
676+
~$ sudo sys-clone sdb
677+
/usr/sbin/grub-install
678+
679+
Booted disk: sda 275.1GB Destination disk: sdb 320.1GB
680+
---------------------------------------------------------------------------
681+
Part Size FS Label Part Size FS Label
682+
1 1.0GB ext4 SSD-275-G6-p1 1 1.0GB ext4 Maxone-320A-p1
683+
2 root 52.4GB ext4 SSD-275-G6-p2 2 52.4GB ext4 Maxone-320A-p2
684+
3 12.6GB swap -- 3 12.6GB swap --
685+
4 209.0GB EXT -- 4 254.0GB EXT --
686+
5 /home 62.9GB ext4 SSD-275-G6-p5 5 62.9GB ext4 Maxone-320A-p5
687+
6 /mnt/sda 146.1GB ext4 SSD-275-G6-p6 6 191.1GB ext4 Maxone-320A-p6
688+
---------------------------------------------------------------------------
689+
== SYNC sda file systems to sdb ==
690+
/ (15.3GB used) : SYNC to sdb2 (52.4GB size)
691+
/home (12.9GB used) : SYNC to sdb5 (62.9GB size)
692+
/mnt/sda (73.1GB used) : SYNC to sdb6 (191.1GB size)
693+
---------------------------------------------------------------------------
694+
Run setup script : no
695+
Run grub : grub-install --root-directory=/mnt/clone /dev/sdb
696+
Verbose mode : no
697+
-----------------------:
698+
699+
Ok to proceed with the clone? (yes/no):
700+
```
701+
702+
624703
## Author
625704
Bill Wilson
626705
billw--at--gkrellm.net

rpi-clone

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

3-
version=2.0.15
3+
version=2.0.16
44

55
# auto run grub-install if grub detected
66
grub_auto=1
@@ -433,6 +433,11 @@ print_options()
433433
else
434434
printf "%-22s : no\n" "Run setup script"
435435
fi
436+
if ((have_grub))
437+
then
438+
printf "%-22s : %s\n" "Run grub" \
439+
"grub-install --root-directory=$clone /dev/$dst_disk"
440+
fi
436441
printf "%-22s : %s\n" "Verbose mode" "$verbose"
437442
printf "%-23s:\n" "-----------------------"
438443
}
@@ -1070,6 +1075,13 @@ then
10701075
exclude_swapfile="--exclude $swapfile"
10711076
fi
10721077

1078+
if ((grub_auto)) && [ -d /boot/grub ] && command -v grub-install
1079+
then
1080+
have_grub=1
1081+
else
1082+
have_grub=0
1083+
fi
1084+
10731085
print_partitions
10741086

10751087
if ((initialize))
@@ -1446,7 +1458,7 @@ do
14461458
unmount_list="$dst_dir $unmount_list"
14471459
fi
14481460
done
1449-
echo ""
1461+
qecho ""
14501462

14511463
# Fix PARTUUID or device name references in cmdline.txt and fstab
14521464
#
@@ -1498,10 +1510,15 @@ then
14981510
dst_root_vol_name="no label"
14991511
fi
15001512

1501-
if [ -d /boot/grub ] && ((grub_auto))
1513+
if ((have_grub))
15021514
then
1503-
echo "grub-install --root-directory=$clone /dev/$dst_disk"
1504-
grub-install --root-directory=$clone /dev/$dst_disk
1515+
qecho "grub-install --root-directory=$clone /dev/$dst_disk"
1516+
if ((quiet))
1517+
then
1518+
grub-install --root-directory=$clone /dev/$dst_disk &> /dev/null
1519+
else
1520+
grub-install --root-directory=$clone /dev/$dst_disk
1521+
fi
15051522
fi
15061523

15071524
if [ "$setup_args" != "" ]

0 commit comments

Comments
 (0)