Suppose the following scenario:
- On your Raspberry Pi, go to a terminal and then go to the /dev directory. You should see, among other devices, mmcblk0, mmcblk0p1 and mmcblk0p2.
- mmcblk0 is the "bare" SD card device, while mmcblk0p1 is the first partition of that SD card containing the kernel image and so on and mmcblk0p2 is the second partition of that SD card containing the root file system.
- Shut down your Raspberry Pi in a decent manner (type the command "shutdown", possibly as root)
- Put the SD card into another Linux machine. Normally, the above mentioned directories should be automatically mounted on /media/ and there should be 2 subdirectories in there (one for partition 1 of the SD card, one for partition 2 of the SD card)
- You have created a temp directory to copy the content of your SD card. Say:
- You are located in
You can now copy the content of the first partition o fthe original original SD card by issueing the following rsync command:
rsync -avn /media/<user>/<partition1> .
Do not put a
/ at the end! The above command will "dry run", which means that it will show you what it eventually will do, but will not execute it for real.
To execute for real (after you've confirmed that the dry run is doing what it should do), you can remove the
n from the above command (so,
rsync -av /media/<user>/<partition1> .).
Use the same command for the other partition.
Now you should have an exact copy of your original SD card on your Linux machine.
Remove the original SD card, put another -correctly formatted- SD card in your Linux machine and execute the following rsync command:
rsync -avn <partition1> /media/<user>
This is again a dry run, which should show you that the content of
/media/<user> will be copied to the SD card.
Once you confirmed all is fine, you can again remove the
n from the
Do the same for the second partition.
This should give you an exact copy of the original SD card onto the other SD card.
Note: I checked all these on a Lubuntu machine. Directories and names may vary on other Linux distro's.
Note also that items between
< > are placeholders and you have to see for yourself how they match with your environment.