@@ -95,8 +95,9 @@ handles my /etc/grub.d/ custom menus and fstab, and the script runs
95
95
grub_install. rpi-clone does handle editing of
96
96
PARTUUID values in /etc/fstab, but a customized setup script for
97
97
a desktop might need to handle file system UUID values or device
98
- name editing in /etc/fstab and the bootloader config.
99
-
98
+ name editing in /etc/fstab and the bootloader config. If these possible
99
+ issues are handled in a setup script, then rpi-clone should work fine
100
+ creating clone backup disks for a desktop.
100
101
101
102
## Usage
102
103
See the examples below. To get a usage screen showing available options,
@@ -105,8 +106,10 @@ run rpi-clone without any arguments:
105
106
pi@rpi0: $ sudo ./rpi-clone
106
107
No destination disk given.
107
108
108
- usage: rpi-clone sdN {-v|--verbose} {-f|--force-initialize} {-u|--unattended}
109
- {-U|--Unattended} {-s|--setup} {-m|--mountdir dir }
109
+ usage: rpi-clone sdN {-v|--verbose} {-f|--force-initialize}
110
+ {-u|--unattended} {-U|--Unattended}
111
+ {-s|--setup} {-e|--edit-fstab name }
112
+ {-m|--mountdir dir }
110
113
{-a|--all-sync} {-F|--Force-sync} {-x} {-V|--version}
111
114
112
115
-v - list all files as they are copied.
@@ -118,6 +121,8 @@ usage: rpi-clone sdN {-v|--verbose} {-f|--force-initialize} {-u|--unattended}
118
121
-s host - add 'host' to args passed to script rpi-clone-setup and run it
119
122
after cloning but before unmounting partitions. For setting
120
123
clone disk hostname, but args can be what the script expects.
124
+ -e sdX - edit fstab to change booted device names to new device 'sdX'.
125
+ Only for device names. Don't use if fstab uses PARTUUID, etc.
121
126
-m dir - Add dir to a custom list of mounted directories to sync. The
122
127
root directory is always synced. NA when initializing.
123
128
-a - Sync all partitions if types compatible, not just mounted ones.
@@ -127,6 +132,12 @@ usage: rpi-clone sdN {-v|--verbose} {-f|--force-initialize} {-u|--unattended}
127
132
-x - use set -x for very verbose bash shell script debugging
128
133
-V - print rpi-clone version.
129
134
```
135
+ + If /etc/fstab uses device names:
136
+ + SD card to bootable USB flash or hard disk clones: use "-e sdX"
137
+ to set up the destination fstab and cmdline.txt.
138
+ + USB disk to SD card slot (mmcblk0) clones: "-e mmcblk0p" is assumed.
139
+ + rpi-clone version 1 briefly had a -s option that is replaced with a
140
+ -s option that has different meaning.
130
141
131
142
## Raspberry Pi SD Card Booted Examples
132
143
#### First clone to a new SD card
@@ -137,7 +148,7 @@ have matching partition types, so the clone is an initialize where
137
148
the source partition structure is cloned to the destination. Because
138
149
the destination is smaller, the last partition will be resized down.
139
150
When disks are initialized a label can be given for the
140
- destination a root file system. I do that so I can keep track of
151
+ destination root file system. I do that so I can keep track of
141
152
my cloned cards. When you run rpi-clone, it tells you what it will do:
142
153
```
143
154
pi@rpi0: $ sudo ./rpi-clone sdb
@@ -194,28 +205,51 @@ Ok to proceed with the clone? (yes/no):
194
205
#### Clone to manually partitioned hard drive
195
206
I wanted to have a Pi3 hard drive USB boot with extra data partitions
196
207
and I want to be able to clone back to 2 partition SD cards for use
197
- in other SD card booted Pis. So my USB disk, which was showing up
198
- as sdc, was manually partitioned with partitions of the appropriate
199
- types and file systems made with mkfs.
208
+ in other SD card booted Pis. So my USB connected hard drive, which
209
+ was showing up as sdc, was manually partitioned with partitions of
210
+ the appropriate types and file systems made with mkfs.
200
211
201
212
Raspbian on the Raspberry Pi needs for the first two partitions to be:
202
213
```
203
214
Partition Type File System Type
204
215
1: type c W95 FAT32 (LBA) mkfs -t vfat /dev/sdc1
205
216
2: type 83 Linux mkfs.ext4 /dev/sdc2
206
217
```
207
- Although the first partition file system cound be mkfs -t vfat -F 32.
218
+ Although the first partition file system could be mkfs -t vfat -F 32.
208
219
I made the extra partitions mkfs.ext4 and I made a swap partition for
209
- possible later use. Now when rpi-clone is run it will see
210
- that the destination disk has matching types for the booted partitions
211
- 1 and 2, so it will do a sync clone without trying to initialize the
212
- destination and my extra partitions 5 and 6 will not be touched.
213
- Here's the first clone attempt to my manually partitioned disk.
214
- The partition types match so rpi-clone goes straight to a sync clone.
215
- Note: when manually preparing like this and you make partition types
216
- match, don't forget that you must also make the file systems. rpi-clone
217
- won't know if you've forgotten that until it tries to mount the
220
+ possible later use (since this is a hard drive and not a flash drive).
221
+ Now when rpi-clone is run it will see that the destination disk has
222
+ matching types for the booted partitions 1 and 2, so it will do a
223
+ sync clone without trying to initialize the destination and my extra
224
+ partitions 5 and 6 will not be touched. This will be the first clone
225
+ attempt to my manually partitioned disk. The partition types match so
226
+ rpi-clone will go straight to a sync clone.
227
+
228
+ Notes:
229
+ + When manually preparing partitions like this and you make partition types
230
+ match, don't forget that you must also make the matching file systems.
231
+ rpi-clone won't know if you've forgotten that until it tries to mount the
218
232
partitions.
233
+ + What I say here applies generally, not just for manually partitioned
234
+ drives. The clone to create a bootable USB disk can work without
235
+ any additional steps beyond the rpi-clone run I show in
236
+ this example if you are on a Pi3 that uses PARTUUID in cmdline.txt and fstab
237
+ because rpi-clone automatically edits those.
238
+ But if you are using device names and are setting up to have a
239
+ system that SD card boots but uses a USB root, then you have to add an
240
+ argument to the rpi-clone run:
241
+ + Use the "-e sdX" option and rpi-clone will edit the destination
242
+ /etc/fstab and /boot/cmdline.txt to reference sdX partition names
243
+ instead of the SD card mmcblk0p partition names.
244
+ + Once you boot your system and are running with a USB root, then the
245
+ SD card slot is available and you can put a SD card into it and clone
246
+ the running USB disk back to it. In that case you would
247
+ run: "rpi-clone mmcblk0". If you do this, rpi-clone assumes you want
248
+ to make the SD card standalone bootable and assumes "-e mmcblk0p"
249
+ and you don't have to explicitly add the argument.
250
+ + But rpi-clone will not edit the currently booted SD card cmdline.txt.
251
+ You must do that yourself.
252
+
219
253
```
220
254
pi@rpi0: $ sudo ./rpi-clone sdc
221
255
@@ -242,7 +276,7 @@ Ok to proceed with the clone? (yes/no):
242
276
243
277
## Raspberry Pi USB Hard Drive Booted Examples
244
278
Now I have booted the USB hard drive I cloned to in the example just
245
- above. I'm going to show several examples here because things now get
279
+ above. I'm going to show several examples here because things get
246
280
interesting with rpi-clone's flexibility.
247
281
248
282
#### Routine USB disk clone to 16GB SD card
@@ -296,11 +330,15 @@ The destination disk is too small.
296
330
```
297
331
rpi-clone sees the mounted partition 5 and wants to clone it but finds
298
332
there's not enough space on the destination drive and won't let me.
333
+ A bigger disk is needed to clone all the way through partition 5.
299
334
300
335
#### USB disk with mounted partition 5 clone to 16GB SD card try 2
301
- I" ve got things I'm working on and don't want to unmount the partition
336
+ I' ve got things I'm working on and don't want to unmount the partition
302
337
to make the clone work, so I use the -m option to tell rpi-clone to
303
- only clone root and /boot and exclude the mounted /mnt/mnt directory:
338
+ only clone root and /boot and exclude any other directory mounts not given
339
+ with a -m option. You don't need to specify "-m /" because root is
340
+ always included in a clone. But you can give only one "-m /" option
341
+ and rpi-clone will clone only the root.
304
342
```
305
343
pi@rpi0: ~$ sudo rpi-clone sda -m /boot
306
344
@@ -360,7 +398,9 @@ space, there is a -F option which will allow the clone to proceed
360
398
anyway. Maybe not a good idea, but the interesting thing about
361
399
this case is that the sync will actually succeed. That's
362
400
because the root used space includes an almost 2GB file system based
363
- swap file (/var/swap) that will be excluded from the sync.
401
+ swap file (/var/swap) that will be excluded from the sync. I haven't
402
+ yet switched to using the hard disk swap partition.
403
+ This is just a FYI.
364
404
365
405
#### USB disk clone to large USB disk
366
406
If you have an extra backup hard drive, you can clone to it and back up
@@ -369,7 +409,9 @@ plugging in a drive I happen to use for backing up my desktop,
369
409
so the partition types won't match and rpi-clone will want to do an
370
410
initialize. The part to note is that rpi-clone will tell you the
371
411
steps it will take when doing an image clone of several partitions.
372
- It will even make a swap partition on the destination.
412
+ It will even make a swap partition on the destination. So, I'll also
413
+ note that this example gives a clue if you want to try using rpi-clone
414
+ on a desktop.
373
415
```
374
416
pi@rpi0: ~$ sudo rpi-clone sda
375
417
0 commit comments