2

My question is whether I can use the following command to create a SD card clone on the Raspberry Pi itself.

sudo dd bs=4M if=/dev/mmcblk0 of=raspbian-5.15.16.img

This can then be copied to my home PC was what I was thinking.

1
  • No. Do not do that. See here and start reading at the second paragraph: "You actually do not want a complete copy of a running system as a back-up, since some of the stuff ostensibly in the filesystem exists only at runtime. Including that in a backup and then using it to recreate an image later may create problems for you."
    – goldilocks
    May 15 '16 at 11:38
2

Yes and No. You can image on the Pi itself (although this may not be the best option), BUT you need to image to some external medium.

This can be a SD Card (in a USB adaptor) a HDD or network drive.

The command above would attempt to image the Pi to a file on the SD which will fail.

The latest Raspbian has a SD Copy utility (which I have not used).

2

Yes you can, ... but it will almost certainly be inconsistent and not work as intended.

Any subsequent change to a sector already written will be lost which will leave the underlying file system in an unknown state. Perhaps a file has been moved or deleted and the sector is now in use by another file.

For a safer solution (if you are using Raspbian) see https://www.raspberrypi.org/blog/another-update-raspbian/ and search for "SD card copier".

One query which comes up a lot on the forums is about the best way to back up your Pi. People also want to know how to migrate their Raspbian install to a new SD card which is larger or smaller than the one they are using at the moment. This has been difficult with the command-line tools that we’ve recommended in the past, so there is now a new application to help with this, and you’ll find it in the menu under ‘Accessories’.

2

Use the package piclone. It will copy the current running system to SD which can then be backed up to your PC using win32diskimager.

Hint: remove as much stuff that you don't use in the running image as possible to get the backup file size small. Use as small an SD that you can to keep your back up files small, also reducing image read and write in the future.

Hint 2: expand the partition on any backup SD cards as this isn't automatic.

1
  • The comment which was most helpful to me in this answer, was to install package piclone. That installs the "SD card copier" Accessory which was missing in my desktop.
    – glenschler
    Feb 2 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.