ObsoletelyFabulous
Posts: 5
Joined: Sun Oct 06, 2019 5:47 pm

SD card copier: homebrew version

Sat Feb 15, 2020 10:50 am

Hi, I have heard there is an SD card copier included with recent versions of full Raspbian. Is there a command line equivalent? I'm just using the no GUI version.

Also what I'm more interested in is dedicating a pi to taking images of any SD card I put in there; I have set up a pi3B to boot from a USB stick and, once booted, I have tried putting an SD card in the onboard slot with another bootable image, then looked at it with fdisk; seems to work. My second question is: once finished taking an image of it, am I OK removing this SD card with the pi still powered up since it is not using it for the OS and it shouldn't be writing anything to it?

My ultimate aim for this is to have an easy way of backing-up my SBC cards easily and saving to a local HDD; ideally with a physical button to start a dd script and a small display to show progress.

fruitoftheloom
Posts: 22106
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: SD card copier: homebrew version

Sat Feb 15, 2020 11:10 am

ObsoletelyFabulous wrote:
Sat Feb 15, 2020 10:50 am
Hi, I have heard there is an SD card copier included with recent versions of full Raspbian. Is there a command line equivalent? I'm just using the no GUI version.

Also what I'm more interested in is dedicating a pi to taking images of any SD card I put in there; I have set up a pi3B to boot from a USB stick and, once booted, I have tried putting an SD card in the onboard slot with another bootable image, then looked at it with fdisk; seems to work. My second question is: once finished taking an image of it, am I OK removing this SD card with the pi still powered up since it is not using it for the OS and it shouldn't be writing anything to it?

My ultimate aim for this is to have an easy way of backing-up my SBC cards easily and saving to a local HDD; ideally with a physical button to start a dd script and a small display to show progress.

https://github.com/billw2/rpi-clone
Retired disgracefully.....
......to an uncomplicated life !

Rather than negativity think outside the box !

ObsoletelyFabulous
Posts: 5
Joined: Sun Oct 06, 2019 5:47 pm

Re: SD card copier: homebrew version

Sat Feb 15, 2020 4:24 pm

Thanks - this looks great!

Eirikur
Posts: 52
Joined: Sun Sep 09, 2018 9:43 pm

Re: SD card copier: homebrew version

Sun Feb 16, 2020 6:39 am

The two lines below are my solution in this space. I find it intellectually and practically easier to just think and act in terms of copying the all the bits on the card to a file or from a file to a card or from card to card. The linux dd command is the way to do that and if I just told you that you would have to figure it out from the man page. Instead here is the contents of my ddimage.sh which becomes my ddimage command (via an alias in .bashrc). You get progress information and total time. This is so simple that you could make it do the wrong thing, like writing a card image to a partition or a partition image to an entire card. I think it's good that it's simple. It can't have a problem with making things bootable because it doesn't touch anything about that. It's a pure bulk copy.

You use it like this if it is in your current directory: ./ddimage.sh spiffy-raspbian.img /dev/mmcblk0
That would burn an image to a card. Next, let's back up a card:
./ddimage.sh /dev/mmcblk0 mynewimage.img

#!/bin/bash
time sudo dd if=$1 of=$2 bs=4M iflag=fullblock oflag=direct,dsync status=progress; sync; echo "Complete and synced."

RonR
Posts: 849
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: SD card copier: homebrew version

Sun Feb 16, 2020 8:16 pm

ObsoletelyFabulous wrote:
Sat Feb 15, 2020 10:50 am
Hi, I have heard there is an SD card copier included with recent versions of full Raspbian. Is there a command line equivalent? I'm just using the no GUI version.

Take a look at: image-backup

Return to “General discussion”