2

I need my SD card to be cloned and shared. One of the obvious way is to use Win32DiskImager. However it has some disadvantages:

  • It's huge: it has a size equals to the size of the cloned SD card (even if I use just a fraction of its capacity)
  • It can be cloned on a same sized SD card only (I'm not shure if it is possible to clone from smaller card to a bigger one, but it is not possible to clone bigger on a smaller)

I heard of PiBakery, but it looks more like a setup solution, not cloning.

So I need something that will allow me to clone my 16 GB SD card to another 8 GB card through Internet with least traffic possible and easiest for the receiving part. Is there anything?

Roman Matveev
  • 405
  • 3
  • 14
  • `clone my 16 GB SD card to another 8 GB` - assuming you've used less than 8GB on your 16GB card do some research on `rsync` – Jaromanda X Jul 02 '20 at 06:47
  • @JaromandaX just looked at the `rsync` description, it looks more like a synchronization software. Will it clone not only files but system configuration like python installed modules, services running etc...? – Roman Matveev Jul 02 '20 at 06:53
  • 4
    keep researching rsync until you understand what it can do for you – Jaromanda X Jul 02 '20 at 10:06
  • 2
    Have you tried the ‘SD Card Copier’ detail in this blog entry https://www.raspberrypi.org/blog/another-update-raspbian/ – CoderMike Jul 02 '20 at 10:15
  • 1
    *"Will it clone not only files but system configuration like..."* -> Any and all configuration of everything (python, systemd services, the kitchen sink) **is in files** (where else could it be?), as well as all the things themselves (the "executable files"). Point being, if you copy all of the files properly into an empty filesystem of the same type, you have cloned the system 100%. You can create an entire image this way, but then you need to clone both partitions and get the image structure/partition table correct. – goldilocks Jul 02 '20 at 18:05

4 Answers4

5

Everyone has their favorite solution. Mine is called image-utils. Why?

  1. open-source (and free :)
  2. small footprint - filesize & resources required for execution
  3. creates a portable image file that's easy to store for later use (or distribute)
  4. runs concurrently with your system (you can make image backups while your system is running)
  5. small image file size

You can download a .zip containing the code (shell scripts) from the forum link above, or you can sync to it from this github pageNOTE.


NOTE: I am not the author of image-utils, nor do I make any changes at all to the source. I have put it on my GitHub site for my own convenience. I'm happy to share that if you prefer using git to keep your local sources updated (rather than dealing with the .zip file). I maintain sync with the master copy on the Raspberry Pi org's forum with a small script I've written to automate the process.

Seamus
  • 18,728
  • 2
  • 27
  • 57
  • Is that correct that I need Linux computer to use this utility? I'd readlly like to make a backup using my Windows 10 computer (for store and restore image) – Roman Matveev Jul 03 '20 at 11:13
  • @RomanMatveev: All you need is a Raspberry Pi that is running `buster`. If you classify a Raspberry Pi as a Linux computer, then yes - but this utility only works on Raspberry Pi AFAIK. And don't forget - it runs while your RPi is up and running... you don't need to shut down, unmount the SD card or anything... you just run it. Once you have the image file, you can use other utilities on other computers (macOS, Windows, Linux, etc) to write that image to an SD card. – Seamus Jul 03 '20 at 16:48
3

You can always use a partitioning tool capable of resizing Linux partitions to make them smaller, then you only need to clone the part of the SD image which is actually occupied by your partitions. In Linux gparted is a user-friendly graphical tool you could use. If you're on Windows, search for partition managers which support Linux partitions.

Don't try to resize a partition leaving zero free space on it, else you may not be able to boot from it. Leave at least 10% of free space.

Dmitry Grigoryev
  • 26,688
  • 4
  • 44
  • 133
2

You could do backup with rsync to mounted external storage

sudo mount /dev/sdb1 /mnt
sudo rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}  /mnt

or via network (given you have both computers on the same network, set up vpn or openned destination server ssh port to public internet ):

sudo rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} username@server_ip:/path/to/backup/directory/

To restore this backup to a blank sd card you might need to first flash raspbian to it and then overwrite everything with files from backup. (I will try to update this answer when will have time to actually test this idea)

(One of good sources: https://www.ostechnix.com/backup-entire-linux-system-using-rsync/ )

to reduce network traffic you could use -z flag: -z, --compress compress file data during the transfer ( https://linux.die.net/man/1/rsync ) also, --progress and -v flags might be useful

Rimantas
  • 21
  • 3
0

"One of the" LEAST "obvious way is to use Win32DiskImager". At best this will share all the well known limitations of any of the more reliable image utilities.

There are many possibilities for creating installable images. See Periodic backup of Rpi3 Stretch SD card

I use Backup image of SD Card

It would be possible to extend this to create an image over the internet (assuming your connection allows the appropriate access permissions).

Milliways
  • 54,718
  • 26
  • 92
  • 182