How to write SD cards for the Raspberry Pi

Look at two different ways to write an SD card.
381 readers like this.
Raspberry Pi 3 board

Raspberry Pi Foundation. CC BY-SA 4.0

Writing SD cards for the Raspberry Pi is something that every member of the Pi community has attempted. Some are old hats and tackle the task with aplomb, but for some it strikes fear into their hearts.

In this article, I look at two different ways to write an SD card. First using the latest application to offer a simple GUI, Etcher. Then, I take a look at dcfldd, a Linux terminal command that expands on the popular dd command and offers much more functionality.

Why did I choose these two applications? There are many options to use to write SD cards, such as NOOBS, Win32 DiskImager, dd, and the new SD card creation tool built into the Raspbian operating system. But the two that I have chosen for this post, not only offer an easy way to write an SD card, but these applications also provide extra features that are accessible to everyone.

Let's take a look at the first application.

Etcher

Etcher came out of nowhere in 2016 and has since become the best cross-platform SD card creation experience. Why? Well, the short answer is consistency. Regardless of what operating system it is used with, it works in exactly the same way. Downloading the application is a breeze, and running the application is equally easy, even on Linux, thanks to it using AppImage to create a simple executable file.

An image showing the Etcher application running on Ubuntu 16.04 LTS

Etcher running on Ubuntu 16.04 LTS.

An image showing the Etcher application running on Windows 10

Etcher running on Windows 10 (identical to the Ubuntu application).

Regardless of your operating system, all you need to do is point Etcher to the image that you would like to write. Next, insert a blank microSD card into your computer. Etcher will detect the card and check that it is ready to be used. After it completes that check, click on Flash to start the process. For Linux users, you'll need to provide a sudo / root password in order to start the Flash process.

An image showing the Etcher application running on Ubuntu 16.04, writing an image to the microSD card.

Etcher writes the card at the best speed possible for your system. Here we see it will take approximately eight minutes to write an image.

Etcher has some great features. First, the image written to the SD card is verified, ensuring that your card is written correctly. Second, by default, Etcher will only write to SD cards and will ignore large hard drives. However, you shouldn't take this capability for granted and you should always check you're using the correct drive. Etcher gives you the option to write multiple cards using the same image. All you need to do is supply the cards and Etcher will do the rest.

When I need to write a new SD card, I use Etcher, because it is fast, easy, and efficient. It is a truly great application that offers so much for all levels of users.

Dcfldd

Let's turn to dcfldd, which is an enhanced version of dd that works in much the same manner, but it also offers more forensics and security-focused features. With a similar syntax to dd, dcfldd requires the location where your microSD card is mounted and the location of the image to flash. Typically, I would use df -h to locate the drive containing my microSD card. In this example, you can see that I have an SD card in my laptop SD reader that it is mounted at /dev/mmcblk0.

les@les-ThinkPad-X220:~/Downloads$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  9.5M  1.6G   1% /run
/dev/sda1       425G  252G  151G  63% /
tmpfs           7.8G  489M  7.4G   7% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs           1.6G   72K  1.6G   1% /run/user/1000
/dev/sdb1       3.6T  876G  2.6T  26% /media/les/Seagate
/dev/sdc1       3.8G  720M  3.1G  19% /media/les/USB DISK
/dev/mmcblk0p1   63M   21M   42M  33% /media/les/boot
/dev/mmcblk0p2  3.9G  3.5G  130M  97% /media/les/7f593562-9f68-4bb9-a7c9-2b70ad620873

In order to write an image to the microSD card, I need to make sure that the drive is unmounted. Remember when you try this to change the location to match your own machine.

umount /dev/mmcblk0p1
umount /dev/mmcblk0p2

Because the syntax for dcfldd is, again, very similar to dd, a typical command is as follows.

sudo dcfldd if=./IMAGE TO WRITE of=LOCATION OF SD CARD sizeprobe=if

The term if relates to the input file, the image that I wish to write to my card, whereas of is the output file, the location of my SD card. You’ll notice that sizeprobe is used, which will take the size of the image file and use it to calculate and display the progress of the application. For example, if I wanted to write the latest Pixel image to my microSD card, I would type.

sudo dcfldd if=./2017-01-11-raspbian-jessie.img of=/dev/mmcblk0 sizeprobe=if

Why should I use dcfldd over dd? For me, the killer feature is the ability to write to multiple output devices. In other words, I can write many cards at once.

Let’s say that I need to write three cards for my friends. Using USB card readers and my internal SD reader I can run the following command:

sudo dcfldd if=./2017-01-11-raspbian-jessie.img of=/dev/mmcblk0 of=/dev/sdb of=/dev/sdc sizeprobe=if

You can see of=/ is used three times. These three occurrences mean that I can write three cards at once using just one image file. The more powerful your machine, the more cards you can write at once. It is as powerful and dangerous as dd, but with the ability to easily write multiple cards at once. It is a power tool for those comfortable with the Terminal.

Les, holding a neopixel powered glove light to his face
Writer for Linux Format, Linux Voice, MagPi ,Pi User and @element14 Trainer and part of #picademy team. Maker specialising in Raspberry Pi projects.

3 Comments

Thanks for this. This is great info. I have been loving the built in SD card copier for cloning, but it's great to hear other options.

What would you recommend for bulk cloning? Write an image in dcfldd and then multiple writes, or can of bypass the image writing? Could you give me an example command for image writing and/or straight cloning?

Thanks,
Pablo

I won a Raspberry Pi...SMILE!!..with whipped cream! AND? I want to do the robotic arm for assistance in my li'l eShop. Then the USB , camera ..plus all come into play. I am waiting for the Pi 2 arrive ~;( in meantime..) I was looking for tweet connection I made with my @GW37C account..and found your site! Hi. Nice to meet you.

Setting up 5G MIMO Small Cell and thinking I can run it with Linux/Ubuntu and? I am on a learning curve. TY. *inspired-lilGet

Thanks for very useful information.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.