How to write Raspberry Pi image to SD card

Raspberry Pi is a cheap and tiny single-board computer powered by ARM processor. While it was mainly developed for children to learn computer programming, it has also become a versatile device for DIY electronic enthusiasts or computer professionals who build many useful tools based on the tiny hardware.

Raspberry Pi comes in two different models with the following specifications.

  • A model: 256 MB RAM, 1 USB port, no Ethernet port
  • B model: 512 MB RAM, 2 USB ports, 1 Ethernet port (shown in the picture)

Raspberry PI uses an SD card as backing storage for an operating system and other tools. In this tutorial, I will describe how to write a Raspberry PI image to an SD card.

Raspberry Pi Images

There are several flavors of raw Raspberry PI images (e.g., Raspbian, Pidora, Risc OS, RaspBMC, Arch, and OpenElec) which you can download from Raspberry PI's official site. All these images are compatible with both model A and B.

The RaspBMC and OpenElec images are mainly used for multimedia purposes. With either image installed, Raspberry Pi can be turned into a tiny multimedia center. You can play movie files, audio files, watch online TV, etc.

The Raspbian, Pidora and Risc OS images are like regular operating systems for ARM processors. You can install any application or service on these operating systems, such as web server, file server, access point, etc.

The NOOBS image provides the easiest and most convenient way for you to write Raspberry Pi operating systems without worrying about manually flashing an image into an SD Card. It contains more than one Raspberry Pi operating systems. Upon first boot, NOOBS automatically formats an SD card, and asks you to choose an OS to install from a list.

In this article, I am going to use Raspbian image which based on Debian.

Prepare for Burning Raspbian Image to an SD Card

To burn a Raspbian image, it is recommended to use a class 10 SD card with minimum 4 GB storage.

Before starting the process, first download the Raspbian image from the official download page. The image comes as a zip file. Unzip the file to extract the Raspbian image file.

Burn Raspbian Image to an SD Card on Linux

Insert your SD card into the card reader.

First, you need to identify the device name for the SD card. For that, you can use lsblk command which shows information about available block devices.

$ lsblk

From listed block devices, identify your SD card by checking their sizes. In this example, my SD card is 16GB, which is mapped to sdb device name. Thus the full device name of your SD card is "/dev/sdb". Make a note of this device name as you need it later.

You do not need to create or format any partition on the SD card. If there is already a partition or filesystem created on the SD card, it will be overwritten by dd command subsequently anyway.

If the SD card is mounted, make sure to unmount it now.

Now empty the mounted SD card by "zero-ing out" the SD card device:

$ sudo dd bs=4M if=/dev/zero of=/dev/sdb oflag=sync

Finally, write Raspberry Pi image to the SD card with dd command:

$ sudo dd bs=4M if=/path/to/image of=/dev/sdb oflag=sync

The "bs" argument sets the block size to 4 MB. Normally the "bs" argument will work with 4M, but you can change to 1M, which will take longer time to write. The "if" argument sets the full path to Raspbian image, and the "of" argument specifies the device name of the SD card. Here /dev/sdb is the device name you identified with lsblk command earlier. Finally, the "oflag=sync" option lets the dd utility perform synchronized I/O for all data and metadata writes, which enables you to check for any write errors to the SD card.

Note that the dd command will not give you any feedback during its operation, and it will look like freezing. So be patient until writing is finished.

After the writing process is finished, eject the SD card. Plug in to the Raspberry Pi, and make sure that all the connections are ready (HDMI/TV out, keyboard, mouse, Ethernet cable). Finally, turn on the power.

Besides using dd command, you can also try other image writer applications such as usb-imagerwriter for deb based distributions, and imagewriter for rpm based distributions. These tools will make the image writing process more user-friendly than dd command.

NOTE: the Raspbian image written to an SD card only occupies less than 4GB of space. Thus, the installed Raspbian will not recognize the rest of an SD card beyond Raspbian image size. To utilize all available SD card space, you will need to "expand" the Raspbian file system. In fact, the file system expansion is one of the first things you need to do after powering up Raspberry Pi.

Burn Raspbian Image to an SD Card on Windows

First, download and install SD Card Formatter from SD Associations.

Insert your SD card into the card reader, and then format the SD card with SD Card Formatter. Formatting options do not matter, as the formatted filesystem will be overwritten during the subsequent image writing step. The reason why we format the SD card is to make the card recognized by the operating system.

Next, download and install win32diskimager application which can flash an SD Card.

Launch win32diskimager. After locating the extracted Raspbian raw image via a built-in file dialog box, write the image to an SD card. It will take some times to finish writing the image into the SD card.

After the writing process is finished, eject the SD card and plug in to the Raspberry Pi.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Kristophorus Hadiono is a Linux enthusiast and a teacher in private higher educations in Indonesia. He uses Linux for his daily computing, also when he teaches his students. He is currently continuing his education with government scholarship at a private university in Bangkok, Thailand.

Latest posts by Kristophorus Hadiono (see all)

13 thoughts on “How to write Raspberry Pi image to SD card

  1. Something like that would be fun to experiment with, but actually I think that is where PC's should be now. The old architecture is in itself a dinosaur. I'm sure you don't get cutting edge graphics from it, but with advances in memory why not?

  2. I want to buy the Raspberry PI and use it for listening to video music in my caravan. If there is somebody in Johannesburg SA to help me with Ubuntu Linux and different software for the Raspberry PI. It would be appreciated.
    Ps. I am not so young anymore and the memory is a bit slow lately.

  3. I am new with Raspberry Pi. I wrote the .img file onto my SD Card with DiskImager on Windows 7. I downloaded the 2013-09-25-wheezy-raspbian.img file from the Raspberry Pi website.

    When I start the Raspberry Pi device, some instructions appear on display and suddenly after a few seconds it starts again. Then again it shows the same behavior.

    I have version of Ubuntu 13.04 and I want to write .img file on SD Card. usb-imagewriter is not working for this. Can someone guide me to install Raspbian OS completely on my SD card?

  4. Hello! I just got my raspberry pi. I have problems running the SDformatter and win32diskimager, it just somehow freezes while formatting and writing. I also downloaded NOOBs and copied it into the SD card but there are some files missing. Can you help me on this? The fixup.dat and start.elf is somehow not in the zipped NOOBS file. I am not sure what other files are needed.

    any help would be greatly appreciated.

  5. I'm a Raspberry newbie. But this site gave me so much information on the topic. I have to say: Thank You!!! Now, after having burned the image on a 32 GB micro SD card (I'm using the B+ with 4 USB ports, let's see :-)

  6. Ok the Raspberry Pi2 is amazing, I am running a virtual world in Opensim with twelve sims on and its nowhere near its full potential, runs smooth and fast and can do anything that my old server could do, have now ordered the 64 bit Pi3 and expecting some real magic.

Leave a comment

Your email address will not be published. Required fields are marked *