How to Create an Image of a Raspberry Pi SD Card? (Win/Linux/Mac)

Your Answer

Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Video

Card Readers

You can find almost as many SD card readers as SD cards but there really aren’t that many differences. Your local computer store, or even conveinence store will most likely have at least one USB adapters. If your computer doesn’t have one there are plenty of choices available for adapters, for the most part these will connect to your computer over USB. Some will do just uSD, uSD and SD or, a whole bunch of different card types. Any of these should work fine for our examples.

A few different SD and uSD card readers

Most laptops and even some desktops now have direct slots in them to read and write SD cards. Often these are directly connected to the USB port inside your machine, making them the same as the USB adapters, but not always. These should work just fine for our examples, but if you are having problems try a USB adapter.

Most cameras now use SD cards and can be plugged into your computer via a USB cable. For the most part the data is going through the camera and not being read directly from the computer. For that reason this will not work for our examples, this is true for phones and other devices as well. Basically if your device has a name other than “SD adapter” it probably won’t work.

For this tutorial, you will need either an SD slot in your computer or a USB adapter. Make sure it fits the size card you have or you have the appropriate adapter. Otherwise, grab the microSD USB reader from the SparkFun catalog.

$5.50 11 Favorited Favorite 10 Wish List

Making the image

First start a Windows command line as Administrator (hit the start button, type cmd then right click on the cmd.exe that appears and select Run as Administrator). Next change directory to wherever you unzipped the DD tool.

To copy the SD card to an image file (in this case c:\temp\myimage.img) use the following command line:

In this case we’re using DD with 3 simple arguments:

  1. Input file (if) is the SD card device
  2. Output file (of) is the image file we’re creating
  3. Block size (bs) is 1 megabyte

How to Make an Image of an SD Card in Windows

First, download AOMEI Backupper Standard on your computer, install and launch it. If you are a Windows Server user, please turn to AOMEI Backpuper Server. Then connect your SD card to your computer and make sure it can be detected.

Secure Download

Step 1. Click Backup and choose Disk Backup.

Step 2. Name the task and click Add Disk to choose your SD card.

Step 3. Select the destination path and click Start Backup to start.

Notes:

  • You can click backup Options > Compression to choose the compression level. It’s also possible to encrypt the image to protect your data from unauthorized access. If you need encryption, you can upgrade to the Professional edition with a discount.

  • When you need to restore the image, you can go to Home > find the backup image > click Restore to make it.

  • To restore an image file without booting Windows, you may create recovery environment with AOMEI Backupper in advance.

Create an image on Linux

If you are a Linux user, let’s see how to do this on your favorite system!I’ll show you on Ubuntu, but the tool is the same on any distribution.

The dd command

“dd” is a base command on Unix. The goal is to offer a tool to manage files.You can use it to erase a partition (filling it with zeros), generate a random file, but also to manage disk images!I’m also using it for benchmarks (like in this post about SD cards).

Master your Raspberry Pi in 30 days Sale: 10% off today. Download the eBook. Uncover the secrets of the Raspberry Pi in a 30 days challenge. Learn useful Linux skills and practice multiples projects. Get it Now!

As dd can do a complete backup of any disk, it’s really useful for this.Let’s see how to use it!

Are you a bit lost in the Linux command line? Check this article first, for the most important commands to remember, and a free downloadable cheat sheet so you can have the commands at your fingertips.

Find the device name

Looking for the drive letter on Windows is pretty easy, but on Linux it’s a bit more hidden.A device name on Linux is something like /dev/sdX (if you use an USB adapter), or /dev/mmcblkX (if your computer has an SD card reader).

On Ubuntu, you can use the Disk Utility to find this information:

I’m using a 16 GB SD card for this test, so this i

I’m using a 16 GB SD card for this test, so this is this one (/dev/sde).If you aren’t on Ubuntu and can’t find a similar tool, you can also jump to the terminal and use the following command:sudo fdisk -l

It will show you a list of drives on your computer. You just need to find the one corresponding to your SD card.In my case, it looks like this:

So, we have a disk named /dev/sde, with two partit

So, we have a disk named /dev/sde, with two partitions (/dev/sde1 and /dev/sde2).

Create the image with dd

Once we know the device name, we need the correct command to create the image of this device:

  • Open a terminal.
  • Type the following command:sudo dd bs=4M if=/dev/sde of=/home/username/MyImage.img
  • Don’t forget to replace the device name (if for input file) and the file destination (of for output file).
  • You’ll get something like this:
Expect at least 15 minutes to create the image (depending on the SD card size).

Note: In any command I give you with “dd”, you can add the option status=progress to see the transfer statistics. Example:sudo dd bs=4M if=/dev/sde of=/home/username/MyImage.img status=progress

Image restoration to the SD card

Copying back the image to another SD card is almost the same thing.I recommend trying this at least one time, just to be sure that your image is working (don’t try on the same SD card!).

To copy an image to a new SD card, there are two ways you can use:

  • The first one is to use dd again, in the reverse order:
    • The command is something like:sudo dd bs=4M if=/home/username/MyImage.img of=/dev/sde
    • For the first time, you need to edit this command with the correct path, image name and device name.
  • The second way, that I always recommend is to use Etcher:
    • Etcher is a free tool you can download here.The good news is that it’s a graphical tool and very intuitive.The dd command seems simple now because you just used it to create the image, but in 6 months, you probably won’t remember the correct options.
    • The tool looks like this:
Just select your backup image, your drive (automatic in theory), and click on “Flash!” to start the copy.

Whatever the method you use, it should create an exact replica of the original SD card.Once done, insert it in your Raspberry Pi and check that everything is working correctly.

Video

Thanks to all my Patrons for supporting me, helping me to keep doing this and producing even more tutorials for everyone! Thank you to everyone supporting me there.

You may also like: 25 awesome Raspberry Pi project ideas at home 15 best operating systems for Raspberry Pi (with pictures) My book: Master your Raspberry Pi in 30 days

4. Creating your own hard drive / removable drive images (to initialize, edit or just as a backup)

The steps I follow when using DD to create the drive image from a physical drive / card:

  1. If I’m using windows, download dd for windows
  2. I attach or insert the hard drive, removable drive (Zip Drive, Jazz Disk etc), memory card (SD, Compact Flash etc.) that I want to image (see options 6 to 8 from my blog entry for Setting up your vintage (classic) 68k Macintosh for a list of connection methods)
  3. open the terminal / command line window
  4. Type dd --list (windows), diskutil list (linux and mac OS) and press return
  5. You should see a list of all attached drives for your system with their names, you should see the name or your micro SD, SD or CF card, you want the identifier of the floppy drive eg.
    • for linux or mac OS something like /dev/disk2
    • for windows something like \\.\Volume{bc8eb0e4-a23d-11e8-9982-00e18c7bb83e}\
  6. Use dd with the correct input and output options, “dd if=INPUTFILE of=OUTPUTFILE bs=BLOCKSIZE”:
    • INPUTFILE = {identifier from step 5}, e.g. /dev/disk2 or \\.\Volume{GUID}
    • OUTPUTFILE =  the location and name of the image you would like to create.
    • BLOCKSIZE, if dd is taking a long time, you can set the block size to speed things up, but what you set it at is dependent on the speed of the device you are working with, and the size of the device you are working with,  if you are working with an SD card try setting it to bs=1M (instead of the default of 512).
    • e.g:
      • linux or mac OS type “sudo dd if=/dev/disk2 of=OS_755_2GB.dsk bs=1M
      • for windows type “dd if=\\.\Volume{bc8eb0e4-a23d-11e8-9982-00e18c7bb83e} of=OS_755_2GB.dsk bs=1M --progress
    • press return
    • wait…. if you’ve connected via SCSI 1, USB 1 or USB 2, this could take some time for larger drives

If I just want to create a “blank” file that I will use an emulator to initialize, then write to a portion of an SD/CF card:

dd if=/dev/zero of=my.img bs=1M count=1880 results in an ~ 2GB image.

Using Mac OS X

This walks you through the process of writing the Embedded Plex Media Player disk image to your USB stick or SD Card using Mac OS X.

Tip!: If you’re planning to write the image to SD Card for your Raspberry Pi 2 you can use a simple app called ApplePi-Baker which allows you to prepare an SD-Card, and write the Plex Media Player Embedded disk image to an SD-Card.

Related Page: ApplePi-Baker Download Page

Using the GUI

Simply double click on the PlexMediaPlayer-version-build.platform-architecture.img.gz file in the finder to let the OS X archive utility extract it for you.

Using the CLI (Command Line Interface)

Open the OS X Terminal application.

Change to the folder where you downloaded the release archive (let’s assume the Downloads folder in your home directory):

Extract the archive. It will be named PlexMediaPlayer-version-build.platform-architecture.img.gz. We need to use gunzip to extract the archive.

Writing the Disk Image

Warning!: Your USB Stick or SD Card will be erased by this procedure as it installs Embedded Plex Media Player onto it. Please ensure you know the correct /dev/disk for your SD Card or USB Stick and that there is nothing important on it.

First, insert your USB stick and open a terminal window and run the following:

This will output something like this:

Now find your SD Card or USB Stick in the list (in this case it is disk1)

You then need to use diskutil to unmount the disk

Next we need to zero out the partition map, OSX has an issue if you don’t do this

Now we need to write the disk image. You’ll need superuser privileges to do this, whether you use the root user or sudo. Either way, you will need to execute the following command:

Note: We need to use the OSX specific /dev/rdisk1

Lastly, to ensure the changes are synced to the SD Card or USB Stick before removing it, execute the following command in Terminal:

You can now safely remove your SD Card or USB Stick and connect to your Embedded Device

Writing Your Raspberry Pi Disk Image to a Card

 Once you’re done, you’ll have a file with the extension .img.gz and you can write or “burn” it to a microSD card the same way you would any .img file you download from the web. The easiest way to burn a custom image is to: 

1.  Launch Raspberry Pi Imager on your PC. You can download Raspberry Pi Imager if you don’t have it already. 

(Image credit: Tom’s Hardware)

2.  Select Use custom from the Choose OS menu. 

(Image credit: Tom’s Hardware)

3.  Select your .img.gz file

4.  Select the microSD card you wish to burn it to. 

(Image credit: Tom’s Hardware)

5.  Click Write

(Image credit: Tom’s Hardware)

Tags

Leave a Reply

Your email address will not be published.