Backing up the Pi SD card

What is the problem?

I have a really nice working copy of Debian and Octoprint and I want to save the SD card so I can duplicate it in the future.

What did you already try to solve it?

I used Win32DiskImager. It read my SD card fine, but when I wrote the image file to another sd card, that card hung up on the Pi boot.

I also tried to clone the card using various cloning tools such as AOMEI Partition Assistant, etc. Nothing I tried would produce an image that would successfully boot into Octoprint (my original SD card did).

Have you tried running in safe mode?

Not applicable

Did running in safe mode solve the problem?

Not applicable

Systeminfo Bundle

You can download this in OctoPrint's System Information dialog ... no bundle, no support!)

Here it is, but it isn't going to be meaningful (121.1 KB)

Additional information about your setup

OctoPrint version, OctoPi version, printer, firmware, browser, operating system, ... as much data as possible

Pi 4B with 7" touchscreen and a bunch of relay controls via the GPIO pins.

I would do it in Linux.

dd the image into an image file and shrink it later.
Just google dd raspberry SD card and you will find a lot of examples.
For the shrinking part you can use GitHub - Drewsif/PiShrink: Make your pi images smaller!

If you are looking for a complete solution - a quick google search found this GitHub - RichardMidnight/pi-safe: Create your own custom image files
It looks pretty complete, but I haven't tested it. Pro: you don't have to set up Linux on you desktop
Con: you need a second SD card

It I'm pretty sure it would also run on a PC desktop image or a VM as link it's connected to a card reader.

I bought a USB to SD (and microSD) adapter. I use this to initially flash the microSD card using the Raspberry Pi imager while plugged into my desktop.

I also use it on my RPi along with rpi-clone to make a copy of the running system. This script uses rsync so while the first copy takes a while, subsequent copies are much faster.

1 Like

I have no problem making a clone or copy. The problem I have is when I try to boot that clone (or copy after burning it to an sd card) is that the cloned card won't boot properly.

Couldn't get either of these solutions to produce a bootable clone of my working Octoprint/Debian SD card.

I'm not sure why rpi-clone didn't work for you but I just used it to copy my RPi 4B OS running on a 32GB USB flash drive to a 32GB microSD card. The microSD card booted successfully. I then copied that microSD card to another 32GB microSD card and that second copy booted successfully.

What commands did you use? I am a real newbe with Linux. The instructions were confusing.

  1. Install rpi-clone from either or
  2. Plug in your USB SD card adapter.
  3. Use lsblk to determine the device name.
  4. sudo rpi-clone /dev/sda (or /dev/sdb, etc.)
  5. Answer the questions appropriately.
pi@octopi:~ $ lsblk
sda           8:0    1 29.8G  0 disk
├─sda1        8:1    1  256M  0 part
└─sda2        8:2    1 29.6G  0 part
mmcblk0     179:0    0 29.8G  0 disk
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 29.6G  0 part /
pi@octopi:~ $ sudo rpi-clone /dev/sda
[sudo] password for pi:

Booted disk: mmcblk0 32.0GB                Destination disk: sda 32.0GB
Part      Size    FS     Label           Part   Size    FS     Label
1 /boot   256.0M  fat32  --              1      256.0M  fat32  --
2 root     29.6G  ext4   --              2       29.6G  ext4   --
== SYNC mmcblk0 file systems to sda ==
/boot                 (48.0M used)   : SYNC to sda1 (256.0M size)
/                     (4.0G used)    : SYNC to sda2 (29.6G size)
Run setup script       : no.
Verbose mode           : no.

Ok to proceed with the clone?  (yes/no): yes

Syncing file systems (can take a long time)
Syncing mounted partitions:
  Mounting /dev/sda2 on /mnt/clone
  => rsync // /mnt/clone with-root-excludes ...
  Mounting /dev/sda1 on /mnt/clone/boot
  => rsync /boot/ /mnt/clone/boot  ...

Editing /mnt/clone/boot/cmdline.txt PARTUUID to use 9b99a359
Editing /mnt/clone/etc/fstab PARTUUID to use 9b99a359
Done with clone to /dev/sda
   Start - 13:17:36    End - 13:23:30    Elapsed Time - 5:54

Cloned partitions are mounted on /mnt/clone for inspection or customizing.

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

The framps version has some additional code to handle an eMMC or M.2 drive which are available on some other SoC computers like the Libre Le Potato. The original code will be fine on all Raspberry Pi systems unless you have an RPi 5 with a M.2 hat.

See above screenshot. As I said, I am a newbe at Linux.

First a couple of useful commands. script filename will capture the commands and output to the file filename. WinSCP is a good tool to help move files (like the filename) to the system you are using to communicate here. man script (or man fdisk) will help with command options and syntax.

Is rpi-clone installed as recommended on your RPi? which rpi-clone will show that. It should be in /usr/local/sbin.

What is the output from sudo fdisk /dev/mmcblk0 option p? (option q to quit)

What is the output from sudo fdisk /dev/sda option p?

With all of those partitions on /dev/sda, it might be a good idea to reformat it first. See for instructions.

Try script -c "sudo rpi-clone /dev/sda" rpi-clone-output and if it fails, try again with
script -c "sudo bash -x rpi-clone /dev/sda" rpi-clone-debug which will give us some insight into that error message.

Thank you,

What I did was take the sd card over to my Windows machine and used AOMEI Partition Assistant to delete all the partitions on that sd card, create one big partition, and format the thing with EXT4. I then plugged it into the Pi, and rpi-clone successfully cloned the entire system onto the sd card, which I then put in the pi, and it booted and ran Octopi fine.

That was the secret: Clean off the target SD card and make one big partition, and format it with EXT4.

Again, thank you.

I now have a complete Octopi box with a touchscreen that will shut down the printer after the job is complete, and allow me to control the LED lights for the camera. I can also control Octoprint from the touch screen using the Chromium browser.

FYI, I have a Prusa MK4, and am getting ready to build another one of these boxes for my newly-arrived Prusa XL. The only problem is that there seems to be a shortage of 7" touchscreens for the Pi.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.