posted Oct 7, 2015, 5:55 PM by Joshua S
[
updated Nov 10, 2015, 7:30 AM
]
This post focuses on creating an image from the RaspberryPi memory card using Linux. We'll do this using the dc3dd utility. It can also be completed using the native dd platform, but dc3dd offers enhanced functionality and status reporting so we know how close the process is to completion. This tutorial will explore completing this task using Debian Jessie Linux with the KDE environment. I chose Debian as the operating system for my laptop because the RaspberryPi's Raspbian operating system is also based on Debian.
This is useful in creating image backups of the RaspberryPi. Restoration is simple from this type of backup -- simply write the image to a new memory card and everything is exactly reset to what it looked like when the image was taken. Be aware that different vendors and different models of memory cards result in slightly different sizes. If the new card is a different size than the old one the image may not have room to successfully write. Typically, in Windows, I will image shortly after configuring a card or building a template image, and only then expand the file-system. Using dc3dd, the entire card is imaged thus this consideration does not need to be followed. Additionally, other backup options are leveraged in the event restoration is later needed.
With any of the Dabbles on this site, if you have questions, suggestions, or thoughts, please feel free to send me an eMail (I'm still working to figure out how to enable comments on Google Sites -- suggestions would be appreciated)!
Supply List: - SDHC Card or MicroSD Card – A digital memory card, initially designed for media (think a camera) but which will serve as the hard drive for the RaspberryPi. The older RaspberryPi models leveraged the SDHC form factor while the newer versions leverage the MicroSD form factor.
- RaspberryPi – The actual RaspberryPi hardware this will all be built around.
- Raspbian – The Debian Linux based Operating System (OS) designed for the RaspberryPi. Download the latest version from the website. Note, other OS's are also on this page, including a version of Fedora and a port of XBMC, but my projects all work with the Raspbian distro.
- dc3dd – An updated, patched, version of the GNU dd utility, developed by the DoD Cyber Crimes Center, to read and write image (.IMG) files to various flash card media (SDHC, MicroSD, etc.). Download the software using apt-get on Debian if you do not already have it in your environment.
Project: - I know I said this guide was going to be comprehensive and not skip any steps, so what better way to start this off than by skipping steps. I am not writing out instructions for the following (and illustrating from XKCD):
- Buying a MicroSD Card
- Buying a RaspberryPi
- Downloading & Extracting Raspbian
- Installing dc3dd on Debian

- Open a shell as root or with a user who has sudo authority. For purposes of this tutorial, we will use an account with sudo authority, but, if run as root, simply remove the sudo command from the below steps. For a refresher on sudo, see the below illustration from XKCD.
- Insert the memory card into your computer's reader (or adapter if you do not have a reader built in). We need to see if Debian auto-mounted the memory card by issuing the sudo df -h command to see what is currently mounted. Note, memory cards should show up on the file system under the /dev directory, and are most easily identified by referring to the size column to find one closely matching the memory card inserted. Cards should show up as either /dev/sdX (where X is an alphabetical letter) or /dev/mmcblkX (where X is numerical). If Debian mounted partitions (such as in the below example) they will be noted with the letter "p". In our example, the card would be identified as /dev/mmcblk0, but partition 1 an 2 are mounted as /dev/mmcblk0p1 and /dev/mmcblk0p2.
- In our example with two partitions mounted, we'll need to unmount each prior to proceeding using the umount command as shown below. When this is complete, re-issue the df -h command to validate the partitions have been unmounted.
- With the disk prepared, it is now time to issue the dc3dd command to create the image file from the memory card. Note, the if= argument specifies the input file while the of= argument specifies the output file (or device in this case). In the example we use the following command:
sudo dc3dd if=/dev/mmcblk0 of=/home/User/Desktop/RPi/Backup.img
- Remove the freshly read card from your computer's reader.
- Mission accomplished! You created the image and now have a backup if you need one!
|
|