Backup SD Image
At some point in your use of the RPi, you're going to think "I've made a whole heap of changes to my RPi build, what if it breaks and I lose everything? How do I stop that happening?".
The answer is 'you can't' hardware fails, power glitches,
sudo rm -rf * , human error, all these types of thing can corrupt your precious SD card.
The solution is 'back it up'.
The ideal solution is to create an device image of your current SD card so you can completely rebuilt it rather than starting from a vanilla debian or fedora build.
Creating an SD Image
You've probably already used an image tool to burn your SD card from an process similar to Setup:RPI.
I used the windows tool win32-image-writer. win32-image-writer can also be used to create an image file.
- Shutdown you RPI using
sudo shutdown -h now.
- Remove the power from the micro USB connection
- Remove the SD card from the RPi slot.
- Insert the SD card into your Windows PC card slot
- Run the win32-image-writer utility on the windows PC
- Select the SD card in the device drop down. If you have more than one device, be careful to select to correct one.
- Select the Imager Name to write to, make sure you select a *.img filename.
- Press read button to burn a binary image of the SC card to the file.
The process is slow and the imager file generated will be approximated the same size as the SD card capacity. This is because the image is a binary clone of the SD card. The img file may be zipped to reduce its size after the process is completed.
This uses the method given Raspberry Pi Easy SD Card Set Up referenced above: but in reverse. Any Linux machine can be used and it assumes the SD Card being backed up is not mounted. So if you only have one SD card you can't use your Pi, you have to use another Linux machine. However, if you have two SD cards capable of booting a Pi, use the one you aren't backing up to boot Pi and the backup the other, via a USB - SD card reader.
If you are using another Linux machine you can back it up to that machine or to anything, such as a NAS, that it can see. If your using your Pi it will have to be backed up to some form of extarnal storage, such as a USB HDD or a NAS.
The instruction here back up the SDd to a mount point on the Linux machine doing the backup.
Firstly, create a directory on the Linux host to mount the location that will receive the backup. e.g.
Secondly, mount the location that will receive the backup:
sudo mount -t cifs //hostname/sharename -o username=xxxx,password=yyyy /media/cifshares
Thirdly, insert the SD card into the machine doing the backup and note its device assignment; as per the Easy CD card set up. Make sure all partions are dismounted. For the following illustration, assume that the SD card to be backed up is sdb.
Finally, use the dd comand to backup the SD card image
dd bs=1M if=/dev/sdb of=/media/cifshares/SD_Card_Image.img
Note: As yet I haven't actually tried to reload a saved image. So be warned.
If you make regular changes to your RPi its worthwhile spending the time creating these images. Time spent backing up is always saved in rebuilding.