0

Pi4, booting from a 2TB USB drive attached.

I've finally got the system the way I want it and I'd like to be able to make an SD card image from it so I can quickly recover when I screw it up. Total space used on disk is around 16GB, so it'll fit onto a card easily.

I know I could just buy another drive and clone it, but I've got a drawer full of SD cards I'd like to use.

Just using the SD copier and dd hasn't worked (I suspect it's trying to copy the entire 2TB to the image). I think tar might do it, but I haven't come up with the magic steps to get it back onto the SD.

Any help would be appreciated. Thanks.

  • Have you tried dd with compression? Without it, dd will try to copy the entire partition to your SD card. You might also give the image-util backup a whirl. It's great for creating an image file for backup from an SD card - never tried it on a USB drive. Or, you might find some ideas here – Seamus Jan 07 '21 at 19:18
  • have a look at what the command line version of piclone does - it's quite simple - https://github.com/raspberrypi-ui/piclone/blob/master/src/backup - there really isn't much to it - of course, it's hard coded to copy from SD card (mmcblk0) so if you change the occurrences of /dev/mmcblk0 to /dev/sda - it may work – Jaromanda X Jan 07 '21 at 22:02
  • Actually, that won't do ... mmcblk0 partition devices are mmcblk0p# whereas sda partition devices are just sda# - no additional p added to the raw device name ... so it's a little more complex to change that script, but it is doable – Jaromanda X Jan 07 '21 at 22:25

2 Answers2

2

You are right - tar is the way to do a copy of your operating system from the USB drive to a SD Card, but also any other usable tool like cp or rsync or your favorite copying tool, provided you have an empty image.

There is a way to just create an empty image with partitions you like and then copy the data to it. You can use dd to create an image file, create partitions on it, format and mount them. You can find an example at How to make an image file from scratch.

If you like to use direct an empty SD Card instead of an image it should not be a big problem to do it with just partition, format and mount the SD Card.

Ingo
  • 42,107
  • 20
  • 85
  • 197
0

I use the procedure in Backup image of SD Card to backup my Pi images.

This can produce a small image, which can be used to make a new SD Card.

I wouldn't try to backup to a SD Card (although this should be possible as I use a similar procedure to synch updated images to other Pi) but you would be better to image to a file, which can be on any media, or a networked drive.

Milliways
  • 59,890
  • 31
  • 101
  • 209