Raspberry Pi: Make Sure You Backup Your SDCard
April 16, 2013 7:23 am 3 CommentsSo, this is a short post to remind everyone using Raspberry Pi. Friends, if you have a great setup on your SD card, don’t forget to back it up. While writing for my upcoming article on the weekend, my Raspberry Pi SD Card encountered some pretty bad errors, most likely in the boot sector. Basically it says “Kernel Panic: VFS: Unable to mount root fs…”.
What happen, I think, I transferred too many files using too many concurrent connections to the Raspberry Pi via SFTP. This killed the Raspberry Pi completely, the UI was unresponsive and my desktop lost connections to it. The little Raspberry Pi was frozen. So I turned it off and re-boot it, well that’s when I see the error. I then did some research and there were some forum posts about fixing it using fsck, however I didn’t attempt it. Since I didn’t have that much data on it and most of my experiment has been documented on the posts in this website such as dosbox, retro console and luakit; I just decided to re-flash the card.
However, for the future, after I setup the Pi as it used to be this is what I do:
Dump the SDCard Image
I think this is the best thing with Raspberry Pi, it uses SDCard. I can just dump the image onto my harddrive using the DD command. So basically I looked at what my SDCard device is using diskutil.
I’m doing this using my OSX laptop, but it’s easy enough to do this with any Linux machine.
1 |
diskutil list |
You’ll see something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *121.3 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 120.5 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 /dev/disk1 #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *32.0 GB disk1 1: Windows_FAT_32 AUX1 32.0 GB disk1s1 /dev/disk3 #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *8.2 GB disk3 1: Windows_FAT_32 58.7 MB disk3s1 2: Linux 8.1 GB disk3s2 |
It’s pretty easy to identify that the SDCard is the /dev/disk3 as it’s only 8 GB.
So the next thing to do is unmount the SDCard using the Disk Utility or similar tool.
Then the dump the SDCard using DD
1 |
sudo dd bs=1024 of=20130414-raspi-dump.img if=/dev/disk3 |
The of parameter can be any filename that you want to use and the if parameter is the device that your SDCard resides on.
Please note that doing an image dump would create the exact same full size of your SDCard, so in this case the SDCard is 8 GB.
I think this is the simplest way of doing backup as to restore back all you have to do is do another DD to fill in the SDCard.
Backing Up the Data via SFTP
This is definitely a good simple way to backup your data of your Raspberry Pi. I don’t think this will be useful to backup the actual disk structure, but for data, this is the simpler way. Simply use any SFTP program like Filezilla or WinSCP and login to your Raspberry Pi using your usual login. Then download all the data that you wanted to backup.
Rsync via SSH
Another way to do automated data backup can be using Rsync via SSH. If you have another linux box you can simply run a cron job to rsync your data periodically from the raspberry pi into your linux box. I won’t go into details on this, perhaps for another day.
I’m sure there are other good ways of backing up your data, if you have any suggestions feel free to leave a comment and share it with everyone :)
Categorised in: Fun computing, General Computing, Raspberry Pi