[easyreview title=”Complexity rating” icon=”geek” cat1title=”Level of experience required, to follow this how-to.” cat1detail=”This is wizard-driven. Very simple. You’ll need to be able to burn a CD, nothing more taxing than that.” cat1rating=”1″ overall=”false”]
Contents
- Part 1: Getting started with the Raspberry Pi
- Part 2: Creating/restoring an image of the Pi’s SD card
- Coming up – Part 3: Using the Raspbery Pi to host multiple web sites and as a file server
- Coming up – Part 4: Creating a Dropbox replacement from a Raspberry Pi
- Coming up – Part 5: Using a Raspberry Pi as a thin (or remote desktop) client
In my last Raspberry Pi tutorial (the first in this series), I mentioned that we can take a snapshot of the Raspberry Pi’s SD card at any time. This will give us a “restore point”, so we can skip a few installation steps if we want to wipe the Pi and start again. Quite a few Raspberry Pi projects will require that we start with a working installation of Raspbian so that’s the snapshot I’m going to take. You can of course take a snapshot whenever you like. If you’ve honed and polished your Rasbmc box, it would make sense to take a snapshot in case it becomes horribly corrupted at some point or melts.
There are many different ways of skinning this cat (or squashing this ‘berry), but my preferred method is the tried and tested customised Linux distribution, Clonezilla. I’ve been using CloneZilla personally and professionally for years and persuaded many colleagues of its merits (besides the obvious, that it’s free). It can be a bit intimidating with all the options it presents. If this is your first experience of CloneZilla, following this tutorial will also give you a gentle introduction to this powerful toolkit.
What you’ll need
- A copy of Clonezilla, burned to disc.
- A computer (desktop or laptop) configured to boot from CD.
- An external hard drive, with enough space to store the image (you’ll only need a few gigabytes spare).
- A USB reader for your SD card. You can buy one here.
Take a snapshot
- Power down your Pi, with the command
halt
,shutdown
orpoweroff
. - Boot your PC from the Clonezilla disc. You will arrive at a simple menu/boot screen. It will boot automatically within 30 seconds – you can hit enter at any time, to proceed.
- You’ll be treated to rows and rows of gibberish while Clonezilla boots up.
- Choose your language and keyboard setting.
- Hit enter to start Clonezilla (yeah, you thought it had already started, didn’t you).
- Insert your Raspberry Pi’s card, in its reader.
- Choose “local_dev”.
- A screen prompt will tell you to insert your external hard drive.
- Insert the external drive and then wait for 5 seconds or so.
- A few lines will indicate that Clonezilla has registered the presence of the drive.
- Hit enter and Clonezilla will mount the various partitions now available to it.
- Select the external hard drive as the drive to which we’re copying the snapshot (in my case, the largest partition on the list).
- Hit enter. If the drive wasn’t cleanly dismounted before (oopsie), Clonezilla will check and fix as required.
- Choose a directory to store the SD card image and hit enter.
- Clonezilla will spit some more gibberish at you. Ignore it and hit enter.
- Though it makes me feel a little silly, choose Beginner mode.
- Choose “savedisk”.
- Give your disk image a meaningful name.
- Select the SD card, to save the image. You use cursor keys and the space bar here.
- Select Ok to continue.
- If you’re confident your SD card is in good shape, you can skip checking it.
- I’d recommend checking the saved image though. It doesn’t take long and gives you peace of mind that you should be able to restore from this image.
- Clonezilla will helpfully point out that you can do all this from the command line (yeah, right).
- Press Y and enter to continue.
- Shouldn’t take too long.
- When it’s all done, it’ll report progress. Press enter.
- Enter 0 to power off (or whatever you prefer) followed by enter.
- Clonezilla will eject the disc. Hit enter to carry on.
You should now have an image (consisting of several files) on your external hard drive, which you can later use for restoration. Job done.
Restore a snapshot
In this scenario, we’re starting with everything powered off, ready to begin.
- Boot your PC from the Clonezilla disc. You will arrive at a simple menu/boot screen. It will boot automatically within 30 seconds – you can hit enter at any time, to proceed.
- I’ve got to say, this screen full of strange foreign characters is pretty unnerving. But don’t worry. It’ll pass.
- Choose your language.
- I’ve never found I’ve had keyboard problems, even though I use a UK keyboard…
- Hit enter to begin.
- Insert the SD card/reader. Some nonsense will appear on screen. Don’t worry – just hit enter.
- Select “local_dev” and hit enter.
- Insert your external hard drive and wait 5 seconds or so for it to be recognised.
- It’ll detect the drive – hit enter.
- Next, it will mount your various partitions.
- You may have a few…
- Choose the external drive from the list then hit enter.
- Clonezilla will check the drive.
- Choose the directory where your saved image is stored and hit enter.
- Clonezilla will give you an overview of its file systems. You will be thrilled. Hit enter.
- Choose “Beginner”, no matter how patronised you may feel.
- Choose “restoredisk”.
- Select the previously saved image.
- Choose the SD card. Hit enter.
- Clonezilla reckons you really want to do this at the command line. Hit enter.
- This is a destructive operation and will wipe your SD card. Press Y then enter.
- Clonezilla doesn’t trust your judgment. Hit Y and enter again.
- There are two partitions to restore to this card. You’ll get a progress report for each restoration.
- Clonezilla will let you know once it’s done.
- Press enter to continue.
- Choose 1 to reboot (or whatever you prefer) then hit enter.
- Once the CD is ejected, you can also disconnect the SD card and hard drive. Hit enter.
- Witness the majesty of the Linux death rattle.
If all went well, you can now install this SD card back in your Pi, boot up and continue.
Why go to all this trouble? Just use Win 32 Disk Imager and select read instead of write. Simples 😀
Doh. Well spotted. I need to go back to Geek school. I feel a post update coming on!
PS We don’t do anything naughty with your email by the way – it’s only used so that you can subscribe to comments if you want notifications of replies. Geek’s honour!
Using win disk imager is simpler but the image includes the unused space on the SD card. Clonezilla is smart enough to exclude unused blocks.
Wonderful article. Thanks a ton for taking the time to put this together. Appreciate it!
And a quick comment to RemainsAnon, you are right Win32DiskImager is faster and easier, but, honestly, i dont trust it that much when dealing with Linux FSs.. just a personal opinion..
Thanks,
Best Regards
Firas S Assaad
We appreciate the feedback. Many thanks!
I’m new to the Pi and both of the backup/restore methods I’ve tried, ‘DiskImager’ and ‘image USB’ result in the same problem. Backup/restore more than about twice and and you’re told that the image to be restored is bigger than the card you are trying to write to – even when the card you are trying to write to is the one that the image was taken from. Others have reported this problem with no solution offered other than the rather impractical one, for a Windows user, of getting a computer with a linux OS and ‘shrinking partitions’. What on earth were they thinking of with a computer you can’t back up more than 2/3 times
You shouldn’t experience this problem with Clonezilla.
Incidentally, you can boot most Windows PCs from a GParted live CD if you want to resize partitions. This does not overwrite the operating system on the Windows PC.
excellent article! very well explained
Even though you can use a disk imaging tools like dd, or disk imager the Clonezilla approach has a number of extra capabilities; which can be really handy when doing bulk operations. I can see how Clonezilla is *generally* overkill for this, but it fits my use case, plus I have an existing Clonezilla server I use to maintain workstation images, so adapting it to do Pi images is a no brainer.
I found this article really useful because it walked through the Clonezilla method, and I find Clonezilla hard to ‘tame’. While it’s understandable that nobody wants to identify themselves as a beginner, Clonezilla’s advanced options can be *extremely* frustrating. After losing a night’s sleep getting my lab set up a few months ago I learned to *love* beginner mode!
The CLI shortcuts are also a great help for this, as you don’t need to repeatedly navigate the menus, and you can use them with other tooling.
Again, it was really nice to have a step by step walkthrough of this, and this has saved me more time than it took to write this post. Thanks!
Thanks so much for some truly excellent feedback Michael. We really appreciate it.