Code Monkey home page Code Monkey logo

rpi-clone's People

Contributors

bdwilson avatar billw2 avatar hkuno9000 avatar spoddycoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpi-clone's Issues

Remote destination or image file?

Forgive me if I'm barking up the wrong tree, or if I'm trying to invent a wheel that exists: I would like to have the option to make the destination of rpi-clone a file or a remote disk. I'm lazy and would love to have a way to schedule all the pis in my house to periodically backup to a fileserver.

rpi-clone to img file

Is it possible to use rip-clone to write not to an sd-card but to a img file (perhaps created with dd)? If so, how to?

Problem cloning Pi2 with external HD

So I have a Pi2 with external usb hd - all working perfectly - I decided to give this a try to back it up as the hard drive really is overkill.

I put a usb SD 16gig in - and it reported as sdb1. I ran the script

sudo rpi-clone -f sdb1

and it noted the formatting wasn't right and offered to fix that by initialising the drive- I agreed. It then complained it could not stat /dev/sdb12 - no such file or directory. Not sure what sdb12 is supposed to be.

it said the device apparently does not exist - did I specify it correctly?

Anyway, it THEN went on to say that /dev/sdb1 is initialised and resized - and gave the right size....

But then i got an attempt to read a block form the filesystem resulting in short read while trying to open /dev/mmcblk0p2 - could not find valid filesystem (the hard disk is EXT4 if that helps)....

It then asked me for a label..... and I gave it "Backup1" without the quotes.

At that point it said no such file or directory while trying ot open /dev/sdb12

It asked me if I wanted to proceed with the clone - I said yes, and... mount: special device /dev/sdb12 does not exist... and it bombed out.

Any thoughts other than cutting my wrists?

Hard linked files synced as individual files

"-H" should be added to $rsync_options to have any hard linked files synced as hard links and not as indivividual files.

    -H, --hard-links            preserve hard links

As an example, the bzcat files in the source are all hard linked files with the same inode, while the destination has these as three separate files.

Source
root@hall2:/mnt/clone/bin# cd /bin root@hall2:/bin# ls -li bunzip2 bzcat bzip2 998 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bunzip2 998 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bzcat 998 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bzip2 root@hall2:/bin#

Clone
root@hall2:/tmp# cd /mnt/clone/bin/ root@hall2:/mnt/clone/bin# ls -li bunzip2 bzcat bzip2 475 -rwxr-xr-x 1 root root 30404 Jan 29 2017 bunzip2 493 -rwxr-xr-x 1 root root 30404 Jan 29 2017 bzcat 508 -rwxr-xr-x 1 root root 30404 Jan 29 2017 bzip2 root@hall2:/mnt/clone/bin#

The good news is that adding -H to the rsync flags will correct the clone on the next run.

Clone after re-running rpi-clone with -H added to rsync flags
root@hall2:/mnt/clone/bin# ls -li bunzip2 bzcat bzip2 475 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bunzip2 475 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bzcat 475 -rwxr-xr-x 3 root root 30404 Jan 29 2017 bzip2 root@hall2:/mnt/clone/bin#

How to find where mounted

  1. my version does not show where the new SD is mounted, either by df -h or (proc/partitions, leaving me blindly trying sdx where x is anywhere between a and e without any system.

2 I think for consistency with other utilities the parameter should be /dev/sdx and not sdx

Otherwise great job

Orange Pi

Hmm- trying this on an orange Pi which has a 32gig SD. I wanted to copy to a 16gig SD. I formatted the 16 gig to FAT32 and ran the script. All went well for a moment.. Any ideas?

The existing destination disk 'sda' partitions are:
Disk /dev/sda: 16013MB
Partition Table: loop

Number Start End Size File system Flags
1 0.00MB 16013MB 16013MB fat32

*** All data on destination disk sda will be overwritten! ***

Do you want to initialize the destination disk /dev/sda? (yes/no): yes

Imaging the partition structure, copying 96 megabytes...
96+0 records in
96+0 records out
100663296 bytes (101 MB) copied, 4.88343 s, 20.6 MB/s
Running fsck on /dev/sda1...
Sizing partition 2 (root partition) to use all SD card space...

Do you really want to quit? mke2fs 1.42.12 (29-Aug-2014)
The file /dev/sda2 does not exist and no size was specified.

/dev/sda is initialized and resized. Its partitions are:
Error: Can't have a partition outside the disk!

Empty directory not cloned

I use an entry in /etc/fstab to map a local directory to a NAS. I had created directory /mnt/nas on my SD card to map to my NAS. rpi-clone did not create that directory on my new SD card image.

That may be by design (although I couldn't find reference) or an issue.

rpi-clone messes up partition table

I've tried running rpi-clone with several SDcards and readers but am always getting the same result: a corrupt partition table.
This is the output of the script:
[root@rpi-01 rpi-clone]# rpi-clone -f sda

*** Forcing a partition initialization of destination 'sda' ***
The existing partitions on destination disk 'sda' are:
Model: SanDisk SDDR-113 (scsi)
Disk /dev/sda: 7948MB
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 4.19MB 7946MB 7941MB primary fat32

This script can initialize the destination disk with a partition
structure copied from the currently booted filesytem and then resize
partition 2 (the root filesystem) to use all space on the SD card.
Do you want to initialize the destination /dev/sda? (yes/no): y

Imaging the partition structure, copying 1296 megabytes...
1296+0 records in
1296+0 records out
1358954496 bytes (1.4 GB) copied, 525 s, 2.6 MB/s
Sizing partition 2 (root partition) to use all SD card space...
Ignoring extra data in partition table 6.
Ignoring extra data in partition table 6.
Ignoring extra data in partition table 6.
Value out of range.

Do you really want to quit? mke2fs 1.42.8 (20-Jun-2013)
Could not stat /dev/sda2 --- No such file or directory

The device apparently does not exist; did you specify it correctly?

/dev/sda is initialized and resized. Its partitions are:
Error: Can't have a partition outside the disk!
Model: SanDisk SDDR-113 (scsi)
Disk /dev/sda: 7948MB
Partition Table: unknown
Disk Flags:
e2label: Attempt to read block from filesystem resulted in short read while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

Your booted /dev/mmcblk0p2 rootfs existing label:
You may enter a label for the destination rootfs /dev/sda2: ^C

[root@rpi-01 rpi-clone]# parted /dev/sda print
Error: Can't have a partition outside the disk!
Model: SanDisk SDDR-113 (scsi)
Disk /dev/sda: 7948MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
[root@rpi-01 rpi-clone]#

Thansk for any help you could offer!

F2FS

Is their a way to use this script with f2fs format?
I have try a little to change the script but i have run inside disaster

Suggest remove redirection of mkfs statement

Due to the >/dev/null on the MKFS statement I waited for a day, because I didn't see it (tried) to prompt me for proceed or not (because of existing DOS partition). After removed it was done in minutes.

'clone' from sdcard to another Linux machine to a mount point?

Hi Bill,

Can this script also do a clone of the full SD Card to a mount point on another real PC Linux (Ubuntu) server? I have several Pi's - would be cool if I have a full clone of the 2 partitions on a mount point, for quick recovery and recreation of the SD Card, back from the Linux server, then I do not have the hassle of switching cd cards, marking them, ...

If so, how would I go about that?

suggestions

1st, very well done script!
2nd, some suggestions for enhancements

  • add an option to clone to an usb connected drive, useful for those who have boot fs on sd and root one on hd or usb dongle, for example...
  • add an option for unattended cloning, no pause at the end waiting for mods in /etc folder...
  • add an option to do a SYNC backup, so adding the --delete switch to rsync to remove stuff from DST sd that's not anymore on SRC sd...

thanks in advance

Documentation Problem

sudo rpi-clone-setup does not work, but sudo **./**rpi-clone-setup does.
The same is true for rpi-clone.

It it just me??

Suggestion about device names

Hi, great tool, worked perfect for me. It took me some time to find out that i only need to enter 'sdc' insted of '/dev/sdc'. Of cource it is well documented... but i guess it would make it easier for some people if the script just removes '/dev/'.
No more complaints :-)
Thanks for this nice work, Stefan

Allow cloning from sda1 instead of mmblk0 for USB-booting setups

Some of my Raspberry Pis are set up to boot from an USB mass storage device, so they don't have any mSD card inserted. I would like to clone and backup these systems too, without having to resort to the GUI-based clone program. Can you please add a command line option that allows changing the source block device?

parted user interaction not printed

I have a 16 GB USB Stick with one single 2 GB FAT partition.
I have partitioned it like that because I would like to use the cloned 2 GB image for my new SD card initialization. ( which turned out to be not working anyway ).
However parted is asking the user for an input and the actual options aren't printed on the screen.

rpi-clone will just print:

Warning: Not all of the space available to /home/henry/testmod.img appears to be
used, you can fix the GPT to use all of the space (an extra 204800 blocks) or
continue with the current setting?

only with google searches I could figure out that there should be more printed:

Fix/Ignore? i

Even though I selected ignore the USB Stick was using the complete 16 GB.
And since my Pi Zero W have no support for using USB boot I am stuck again at shrinking the current 32 GB SD card to the smaller 2 GB one.

Odd results

Source partition table looks valid, destination card and source card are both 8GB yet I cant make it work :-(

I have no idea how the card the Pi is running was created, but it is running without errors.

I tried two sd cards of different makes, both failed in the same way.

Any ideas ?
Thanks, Jon

Jul 4 00:05:37 raspberrypi kernel: [ 1688.623838] scsi3 : usb-storage 1-1.3:1.0
Jul 4 00:05:38 raspberrypi kernel: [ 1689.618674] scsi 3:0:0:0: Direct-Access FNK TECH USB CARD READER 1.00 PQ: 0 ANSI: 0 CCS
Jul 4 00:05:38 raspberrypi kernel: [ 1689.623629] sd 3:0:0:0: [sda] 15130624 512-byte logical blocks: (7.74 GB/7.21 GiB)
Jul 4 00:05:38 raspberrypi kernel: [ 1689.624116] sd 3:0:0:0: [sda] Write Protect is off
Jul 4 00:05:38 raspberrypi kernel: [ 1689.632141] sda: unknown partition table
Jul 4 00:05:38 raspberrypi kernel: [ 1689.634904] sd 3:0:0:0: [sda] Attached SCSI removable disk

root@raspberrypi:~# fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes
4 heads, 16 sectors/track, 243200 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e1a14

    Device Boot      Start         End      Blocks   Id  System

/dev/mmcblk0p1 8192 3009765 1500787 e W95 FAT16 (LBA)
/dev/mmcblk0p2 3014656 15349759 6167552 85 Linux extended
/dev/mmcblk0p3 15349760 15415295 32768 83 Linux
/dev/mmcblk0p5 3022848 3145727 61440 c W95 FAT32 (LBA)
/dev/mmcblk0p6 3153920 15349759 6097920 83 Linux
root@raspberrypi:~# fdisk /dev/mmcblk0

Command (m for help): v
Partition 5: sector 0 greater than maximum 16
Partition 6: sector 0 greater than maximum 16
Remaining 178967 unallocated 512-byte sectors

root@raspberrypi:~/rpi-clone-master# fdisk -l /dev/sda

Disk /dev/sda: 7746 MB, 7746879488 bytes
239 heads, 62 sectors/track, 1021 cylinders, total 15130624 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sda doesn't contain a valid partition table
root@raspberrypi:~/rpi-clone-master# rpi-clone sda
[Note] fsck.vfat was not found.
It is recommended to install dosfstools:
$ sudo apt-get update
$ sudo apt-get install dosfstools

The destination disk sda partition table does not
match the booted disk /dev/mmcblk0 partition table so a
destination disk initialize is required.
The existing destination disk 'sda' partitions are:
Error: /dev/sda: unrecognised disk label
*** All data on destination disk sda will be overwritten! ***

Do you want to initialize the destination disk /dev/sda? (yes/no): yes

Imaging the partition structure, copying 1552 megabytes...
1552+0 records in
1552+0 records out
1627389952 bytes (1.6 GB) copied, 375.041 s, 4.3 MB/s
Sizing partition 2 (root partition) to use all SD card space...
mke2fs 1.42.5 (29-Jul-2012)

/dev/sda is initialized and resized. Its partitions are:
Error: Can't have a partition outside the disk!
e2label: Attempt to read block from filesystem resulted in short read while trying to open /dev/mmcblk0p2
Couldn't find valid filesystem superblock.

Your booted /dev/mmcblk0p2 rootfs existing label:
You may enter a label for the destination rootfs /dev/sda2:

Documentation Problem

Very unimportant, but some people might get confused.
usage: sys-clone sdN {-v|--verbose} {-f|--force-initialize} {-f2} this is from the website, but when I try it at home I get usage: rpi-clone sdN {-v|--verbose} {-f|--force-initialize} {-f2}

sys-clone and rpi-clone is the difference

Please add -x to rsync options

I hd a bunch of NFS mounted file systems on my RPI and rpi-clone happily cloned them into the clone root filesystem. This can easily be avoided by addin -x to the RSYNC options. This should also allow you to simplify the program because you should not need any 'exclude' anymore for RSYNC (right now there is a long list) - all the exemptions are additional mounted filesystems that will not be copied anymore with '-x'.

Read-only file?

I try the latest version of your script and i've a lot of error during the cloning.
I execute the script as root:

Starting the filesystem rsync to sda
(This may take several minutes)...rsync: write failed on "/mnt/clone/usr/bin/git-upload-pack": Read-only file system (30)

Another if i use "-f" option:

rsync: chown "/mnt/clone/boot/bootcode.bin" failed: Operation not permitted (1)

rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(632) [sender=3.1.1]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at io.c(504) [generator=3.1.1]
./rpi-clone: line 494: /mnt/clone//var/log/rpi-clone.log: No such file or directory

Can't get unattended backup to write to log

I am using cron to schedule backups and it's working fine. What I am unclear on is how to get it to write to a log (or, indeed, how the log file is designated).

I've tried using -q and -u options, but I must be missing something.

Could anyone tell me please:

a) where is the log file defined (or is it just by redirecting output)?
b) what command should I use in my crontab to run unattended but also write out the log to this file?

Automatically clone without user interaction

He there! Thanks for the very nice script. Are you planning to include an additional flag that makes it possible to run the script as a crontab. I mean without having to confirm anything.. but logging the output in a specific logfile? That would be great! Thanks!

Operation not permitted

I have an issue when trying to clone to an empty sd card.
The script hangs at (see below) and its subfolders/files


Starting the filesystem rsync to sda
(This may take several minutes)...rsync: chgrp "/mnt/clone/boot" failed: Operation not permitted (1)
...


Any help is appreciated!

Cannot copy SD card due to rsync errors (possibly)

I tried to use rpi-clone with no result. The card simply does not boot , the LEDS on PI stay still.

Here is the llog:
[ubuntu@raphael sbin]$ sudo rpi-clone sda -f
A destination partition is busy (mounted). Mount status:
/dev/sda2: /media/ubuntu/leonardo-root
/dev/sda1: /media/ubuntu/AB3E-B34D
Do you want to unmount /media/ubuntu/AB3E-B34D? (yes/no): yes
Do you want to unmount /media/ubuntu/leonardo-root? (yes/no): yes

Forcing a partition initialization of destination disk sda
The existing destination disk 'sda' partitions are:
Disk /dev/sda: 7867MB
Partition Table: msdos

Number Start End Size Type File system Flags
1 1,05MB 68,2MB 67,1MB primary fat16 boot, lba
2 68,2MB 7867MB 7799MB primary ext4

*** All data on destination disk sda will be overwritten! ***

Do you want to initialize the destination disk /dev/sda? (yes/no): yes

Imaging the partition structure, copying 76 megabytes...
76+0 records in
76+0 records out
79691776 bytes (80 MB) copied, 18,8005 s, 4,2 MB/s
Running fsck on /dev/sda1...
Sizing partition 2 (root partition) to use all SD card space...
mke2fs 1.42.9 (4-Feb-2014)

/dev/sda is initialized and resized. Its partitions are:
Disk /dev/sda: 7867MB
Partition Table: msdos

Number Start End Size Type File system Flags
1 1,05MB 68,2MB 67,1MB primary fat16 boot, lba
2 68,2MB 7867MB 7799MB primary ext4

Your booted /dev/mmcblk0p2 rootfs existing label: raphael-root
You may enter a label for the destination rootfs /dev/sda2: leonardo-root

======== Clone Summary ========
Clone mode : rsync all files to sda root file system
Clone destination disk : sda
Clone destination rootfs : /dev/sda2 (leonardo-root) on /mnt/clone
Clone destination bootfs : /dev/sda1 on /mnt/clone/boot

Verbose mode : off

Final check, is it Ok to proceed with the clone (yes/no)?: yes
=> Mounting /dev/sda2 (leonardo-root) on /mnt/clone

=> Mounting /dev/sda1 on /mnt/clone/boot

Starting the filesystem rsync to sda
(This may take several minutes)...rsync: symlink "/mnt/clone/boot/.cmdline.txt.3840" -> "firmware/cmdline.txt" failed: Operation not permitted (1)
rsync: symlink "/mnt/clone/boot/.config.txt.3840" -> "firmware/config.txt" failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.0]

*** Done with clone to /dev/sda ***
Started: 15:04:41 Finished: 15:28:28

Hit Enter when ready to unmount the /dev/sda partitions...
unmounting /mnt/clone/boot

unmounting /mnt/clone

[ubuntu@raphael sbin]$

Missing 'boot' partition, and 'recovery' partition contains 'boot' content with NOOBS 1.3.4

I've just made a few attempts at running rpi-clone. The image I was cloning is Raspian from NOOBS 1.3.4. I used -f to force a new SDCard to be partitioned. No errors are printed during the process. I am running the latest script directly from a github clone.

When done, the new SDCard has only one partition, named 'RECOVERY' (1.5G) and it contains the files from the original SDCard that were in the partition named 'BOOT'. The new card has no partition named 'BOOT'. Not surprising this new SDCard does not boot either. Anybody else seeing this? Thanks!

Original card:
'RECOVERY', FAT32, 1.45gb - files: recovery.img, ...
'BOOT', FAT32, 61.9mb - files: config.txt, ...

New card:
'RECOVERY', FAT32, 1.45gb - file: config.txt (this is wrong, these are the 'boot' dir files).
(missing 'BOOT' partition)

Communication

Hi Bill

You emailed me but if I try to reply - your spam filter bounces my emails - here's the one I just wrote

Couple of things – I’m trying out your new version

https://github.com/billw2/rpi-clone

In the docs – first clone to a new SD card..

pi@rpi0: $ sudo ./rpi-clone sdb

That can’t be right – only works with the ./ missing….

Secondly when running..

“Writing superblocks and filesystem accounting information: “

That colon at the end maybe should be … to indicate it is doing something – kind of looks like it has stalled…

When I tried the original version on the Orange Pi Plus 2e it did not work – or rather it did – but then the resulting SD didn’t do anything…. Hoping this version will do better… time will tell (it takes a while)..

Pete.

Adding to OPTIONAL_MNT_DIRS not working

I do not know what version of rpi-clone I'm running but the READ.ME is dated 12/21/2013.

I added 'www' at the end of OPTIONAL_MNT_DIRS but it is not created as part of the clone process.

OPTIONAL_MNT_DIRS="clone mnt sda sdb rpi0 rpi1 www"

I expected it to work since at line 387:

# Some extra optional dirs I create under /mnt
for i in $OPTIONAL_MNT_DIRS
do
        if [ ! -d $CLONE/mnt/$i ]
        then
                mkdir $CLONE/mnt/$i
        fi
done

What am I missing?

mail notification, e.g. if cron is used

Very helpfull script which run directly without any issues and of course also the cloned SD card :-).

Is it possible to add a notification option, specially if the script run with -u/-U.

I sync my SD card with cron to a backup SD within a USB card reader and without notification errors are not seen.

Progress Indicator and RPi Stalling

I have sometimes found it desirable to have a progress indicator while using rpi-clone. I have been experimenting with the rsync option --info=progress2 both with and without the --no-i-r option to make the display more meaningful. For more information on decoding the output, please refer to:

[https://unix.stackexchange.com/questions/215271/understanding-the-output-of-info-progress2-from-rsync]

The --no-i-r option slightly delays the start of file syncing but I regard the extra delay as tolerable to obtain a much more useful progress display.

In the process of testing the progress2 option, I noticed that rsync stalled several times, sometimes for many seconds. Concurrently using the command:

watch -n 1 grep -e Dirty: -e Writeback: /proc/meminfo

it looks like the output micro SD card cannot handle the speed of data being written by rpi-clone in random access mode, and the cache hangs. To alleviate this behavior, I am contemplating permanently adding the rsync option:

--bwlimit=<kbytes/second>

Initial testing with a SanDisk UHS1 micro SD card indicates limiting rsync output to 7 MBytes/second considerably reduces the freezing behavior of rpi-clone.

The RPi SBC platform is extensively listed on the web as experiencing hangs (pauses) when writing multiple small files to a micro SD card. Testing so far has indicated that there is a slight trade-off between clone duration and alleviation of application freezing. Given the amount of web based discussion about RPi SBCs and micro SD card issues, I do not think I am the only user experiencing hangs when using rpi-clone. What have other users done to address this issue, please?

Impossibile unmount sda2 from /

Hi, I'm using with success the first versio of RPI-Clone on a Raspberry with raspbian Linux rpi3mh 4.9.46-v7+ #1032 SMP Wed Aug 30 12:09:14 BST 2017 armv7l GNU/Linux and every synch work fine.

After installing V2 of RPI-Clone, and executing "sudo rpi-clone sda -v", I receive the following message:

Destination disk partition /dev/sda2 is mounted on /.
The clone cannot proceed unless it is unmounted.
Do you want to unmount /? (yes/no): yes
umount: /: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
rpi-clone could not unmount /.
Aborting!

The source and destination are the same...

Where is the problem?

Please help me.

Thanks

Guido

"Clone" without overwriting newer files on destination

rpi-clone does exactly what it says: it clones. But as it in fact does a delta update when possible, I like to use it because it allows me to quickly create clones without having to wait for a full clone. I'm using rpi-clone in two different scenarios: first, for creating bootable backups; second, for creating cloned cards so I can have multiple Pi's running the same configuration.

Unfortunately, that needs manual intervention after each clone cycle, in order to adjust the hostname. It would be helpful if rpi-clone could run rsync in a way that it updates files that are newer on the source, but doesn't touch files that have been changed in the clone afterwards. If I'm not mistaken, this would allow me to create the initial cloned copy, then change the hostname in the clone, and on every subsequent clone update the hostname would not be copied over from the source anymore.

Is this feasible? (using the -u option to rsync?)

rpi-clone crosses filesystems inappropriately

I had a very early version of rpi-clone that worked fine. I upgraded to the latest, and I noticed the removal of the "x" option in RSYNC_OPTIONS causes problems.

My RPi has an external HDD mounted (for NAS-type backups). Without the "x" option, rpi-clone attempts to include my 3TB HDD on the 16GB SD card clone - obviously this doesn't work.

Was there rationale for removing the "x" option for rsync? I can't think if a case where you'd want the clone to cross filesystem boundaries.

I temporarily fixed my problem by adding back in "x" to RSYNC_OPTIONS.

Issue with no space on clone

I have used rpi-clone to clone my 16 GB SD card on to another 4 GB, I haven't installed much so there should be plenty of space. I checked with gParted before and it said the partition was only used about 2.7 GB.

The clone boots up fine and I can run the binaries I already had on it, but I am unable to write anything new. It says there is no space left on the device. I tried to delete some files but it continues to say there is no free space. Even is I just try to change a single character in a textfile after having deleted a much larger program I get the error.

df reports this:

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 3808912 3591148 24280 100% /
/dev/root 3808912 3591148 24280 100% /
devtmpfs 183620 0 183620 0% /dev
tmpfs 38376 284 38092 1% /run
tmpfs 5120 0 5120 0% /run/lock
tmpfs 76740 0 76740 0% /run/shm
/dev/mmcblk0p1 57288 18928 38360 34% /boot
tmpfs 76740 0 76740 0% /tmp

Can you help me?

can't copy SD card on raspberry pi anymore

when I type in the following commands...
cd rpi-clone

sudo cp rpi-clone /usr/local/sbin
ls -la /dev/disk/by-id
look for the last sd_ on your sd card reader
sudo rpi-clone sda -v
or
sudo rpi-clone sdb -v
or
sudo rpi-clone sdc -v
or
sudo rpi-clone sdd -v
answer y for unmount
answer y for initialize the destination disk /dev/sd_

I get the following issue...

Initializing
Imaging past the start of /boot partition 2.
=> dd if=/dev/mmcblk0 of=/dev/sdb bs=1M count=65 ...
Resizing last partition to end of disk ...
Resize failed. See /tmp/rpi-clone-output.
Try running rpi-clone again.

Re-reading the partition table failed.: Device or resource busy
pi@retropie:~/rpi-clone $

and it does not copy.. what am I doing wrong?!

Add -w option to leave wiggle room?

Hi Bill,

Thanks for this excellent script. It's much appreciated. I've written a guide on how to install it under Raspbian with a desktop GUI launcher as a sign of my appreciation here... https://www.raspberrypi.org/forums/viewtopic.php?p=914109#p914109

Not really an issue as such, but...

I was wondering if it might be possible for the /root partition to be optionally slightly undersized so that a clone created on one, let's say, 4GB card could be guaranteed to fit on to any other 4GB card.

As I'm sure you're aware, exact available capacity varies slightly between cards of different makes/models/batches even if they're still marketed as being xGB in size, so adding a -w option to allow trimming of maybe 100MB should give enough wiggle-room for a "fits-all" solution to this problem.

Maybe make the exact amount of wiggle-room adjustable by the end-user specified in MB, for example, '-w 150' for 150MB of wiggle-room?

Could an additional small partition be created at the end of the card to reserve this space, then deleted at the end of the cloning process?

I don't even know if this is possible as my knowledge of Linux partition handling is close to zero, but it would be a very useful addition to the tool IMO if this is doable.

Kind regards, GTR2Fan.

Cloning from/to USB drive?

Hi there!
As I had quite some problems with my SD cards (despite the fact I've bought the recommended ones and written log files, etc. on a different drive..) I've decided to switch to the USB configuration. Booting starts from the SD card first, but then everything is run from USB, maybe in the future from an SSD.+

Anyhow now rpi-clone has some problems finding the partitions of course. I've managed to hardcode the correct values in the script but was wondering if anyone has already come up with a more flexible solution that somehow detects where to copy from..? ;) And.. I get this error message after initializing the target SD card or USB stick (tried both, also a card that was already partitioned correctly):
/dev/sdc is initialized and resized. Its partitions are:
Error: Can't have a partition outside the disk!

It's possible that this is a result of a smaller sized SD card than USB stick.. but I'm not sure..?
Thanks alot guys!

cloning user data from jessie to stretch

i have an rpi3 that has been thru the typical extensive user customizing, SSH keys, openvpn configs, no pi user, custom user, etc. running jessie noobs

I just got an rpi3+ that needs stretch. Because of noobs I can not easily dd clone and update to stretch. Can I use this to clone all my user setup and files to a new stretch. Or maybe I should ask will this clone the raspbian jessie only without noobs, in this case I would have no problem doing that and updating jessie to stretch.

No -b option to findmnt on wheeze raspbian

rpi-clone fails on wheeze because there is no -b option available on the findmnt command. This is with rpi-clone version 2.0.6

`root@xxx:/ss/rpi-clone# rpi-clone sda
findmnt: invalid option -- 'b'

Usage:
findmnt [options]
findmnt [options] |
findmnt [options]
findmnt [options] [--source ] [--target ]

Options:
-s, --fstab search in static table of filesystems
-m, --mtab search in table of mounted filesystems
-k, --kernel search in kernel table of mounted
filesystems (default)

-p, --poll[=] monitor changes in table of mounted filesystems
-w, --timeout upper limit in milliseconds that --poll will block

-a, --ascii use ASCII chars for tree formatting
-c, --canonicalize canonicalize printed paths
`

Script completed leaving both SDs unreadable

The script completed and I shutdown the RPi to attempt booting from the cloned card. Nothing happened. My original card also would not boot and was deemed un-readable by my Mac and PC. Any ideas. I may have lost 2 months of work.

Cloning Pi-Zero forces gadget mode problems

Hello,

I followed this tutorial to put my PiZero in gadget mode so I could use it as an ethernet usb gadget. I wanted to use this script to clone my root file system. I connected via a serial console cable and instead used an OTG cable to connect a usb to microsd card as the destination SD card.

After cloning is complete, I try to use gadget mode on the new SD card and it appears to be forced to host mode. Any ideas on how I might be able to resolve this?

Thanks for the great script!!

only two partitions created, partition 1 won't boot

Looks like a great program but doesn't quite work!
Program seems to work normally
New clone dies at 2 seconds unable to mount the root fs, with an unknown block 179,7
The second partition mounts.
Where are the other partitions?

Full automatic run?

Hi there!
Thanks for the great script that worked very well so far.

Anyhow, I wanted to know if there is any possibility to let the script run in "full auto" mode with auto.unmount, etc. so you could run it via crontab at specific times on its own.

Thanks!

Worked flawless

Obviously, not an issue, but I don't know how to contact you otherwise. Just wanted to say thanks.
Your script really helps a lot!

Cheers
Markus

Bill... Are you out there? Need NOOBS support

Bill, NOOBS is something that is becoming more and more prevalent. It seems that rpi-clone is not compatible with a NOOBS card. I imagine the whole issue is that NOOBS has more partitions which rpi-clone is not set to handle.

For someone familiar with Linux file systems, the change should be fairly easy. There are just more partitions to create/copy. But to those not completely confident, there's a lot of room for error :-)

Can you please help or at least give some guidance to those willing to try modifying the scrip to manage it?

'/dev/sda' does not exist, however it is actually there.

Edit: Issued wrong command. Should have been: rpi-clone sda

This is on a fresh install...

rpi-clone /dev/sda Destination disk '/dev/sda' does not exist. Plug the destination SD card into a card reader connected to a USB port. If it does not show up as '/dev/sda', then do a cat /proc/partitions to see where it might be.

cat /proc/partitions

major minor  #blocks  name

   1        0       4096 ram0
   1        1       4096 ram1
   1        2       4096 ram2
   1        3       4096 ram3
   1        4       4096 ram4
   1        5       4096 ram5
   1        6       4096 ram6
   1        7       4096 ram7
   1        8       4096 ram8
   1        9       4096 ram9
   1       10       4096 ram10
   1       11       4096 ram11
   1       12       4096 ram12
   1       13       4096 ram13
   1       14       4096 ram14
   1       15       4096 ram15
 179        0   30375936 mmcblk0
 179        1     125016 mmcblk0p1
 179        2   30250912 mmcblk0p2
   8        0   30375936 sda
   8        1   30374912 sda1

fdisk -l

Disk /dev/sda: 29 GiB, 31104958464 bytes, 60751872 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x27413b96

Device     Boot Start      End  Sectors Size Id Type
/dev/sda1        2048 60751871 60749824  29G  b W95 FAT32


So it's there, but it won't work. What gives?

Mount not working for me..

Hi,

The script stops at:

Final check, is it Ok to proceed with the clone (yes/no)?: yes
=> Mounting /dev/sda2 (domoticz8) on /mnt/clone
=> Mounting /dev/sda1 on /mnt/clone/boot
mount: you must specify the filesystem type
Mount failure of /dev/sda1, aborting!

Any thoughts?

Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.