66

I have just ordered my Raspberry Pi, and I want to prepare my SD card. How do I install an OS image onto an SD card?

3
  • 1
    FYI: It took ~30min for the image copy to complete with dd on OS X.
    – Tyler
    Commented Aug 11, 2012 at 21:22
  • @Tyler Yeah, it takes a while! I'm not sure that dd is the correct way to go on *nix systems. Commented Aug 11, 2012 at 21:28
  • Just want to add a little. Use SD Formatter to format the SD card. Commented Jan 2, 2017 at 23:34

5 Answers 5

59

This Answer was useful in 2012 (and is still mostly valid) but has been superceded by superior methods. Users are recommended to follow the official Foundation documentation

The process is pretty simple.

Download the image

First, go to the Raspberry Pi Foundation's Download page and download the image you want.

The latest image is Raspbian Stretch, which is the official distribution for all Pi models. Alternatively, the Arch Linux image is great if you want a minimal install or if you've had a bit of experience with Linux before.

Verify the Download

The Raspberry Pi Foundaton provide the SHA-256 hash of the download, which we can use to verify the file was downloaded correctly and wasn't tampered with on the way.

Windows

You can use a utility provided by Microsoft called fciv or another provided by Frozen Logic called Summer Properties.

Linux

  1. Run sha256sum 2018-06-27-raspbian-stretch.zip. The generated hash should match the one given on the website; for the 2018-06-27 zip, this is 8636ab9fdd8f58a8ec7dde33b83747696d31711d17ef68267dbbcd6cfb968c24. For other versions, change the file name above as appropriate and verify against the hash on the website.

Extract the img file

Extract the .img file and remember where you put it. Take note of the image file name—you will need to use this later. In the case of a Linux host, check that your PWD is the directory in which the image file is stored.

Linux

You can use unzip from the command line.

Installation

The installation differs depending on whether you are using a Linux or a Windows host to flash the image onto the card.

Windows

  1. Insert your SD card into your computer and note down the drive letter it is assigned.
  2. Download and install the Win32DiskImager.
  3. Select the image file you extracted earlier and the drive letter of the SD card.

Warning There is a significant risk you could damage your file system if you select the wrong drive letter. Make sure you get it right!

  1. Click "Write" and watch the pretty progress bar.

Linux

  1. Insert your SD card into your computer.

  2. Locate the device, by running sudo fdisk -l. It will probably be the only disk about the right size. Note down the device name; let us suppose it is /dev/sdx. If you are in any doubt, remove the card, run sudo fdisk -l again and note down what disks are there. Insert the SD card again, run sudo fdisk -l and it is the new disk.

  3. Unmount the partitions by running sudo umount /dev/sdx*. It may give an error saying the disk isn't mounted - that's fine.

  4. Copy the contents of the image file onto the SD card by running

    sudo dd bs=1M if=your_image_file_name.img of=/dev/sdx

    Of course, you'll need to change the name of the image file above as appropriate.

Warning There is a significant risk of damage to your filesystem if you use the wrong /dev/sdx. Make sure you get it right!

Have fun!

Once you have installed the OS eject the SD card properly and insert it into the Raspberry Pi. Attach power and enjoy.

References

  1. RPi Easy SD Card Setup
7
  • 3
    I like to use "Summer Properties" for calculating checksums in Windows. Integrates very nicely. frozenlogic.org/summerproperties.shtml
    – Kibbee
    Commented Jul 4, 2012 at 16:29
  • @Kibbee, That Summer Properties app is pretty awesome.
    – user606723
    Commented Jul 5, 2012 at 19:41
  • 1
    Be sure to run sync after you're done to be sure that the image is written.
    – isaaclw
    Commented Jun 15, 2014 at 20:28
  • @isaaclw any suggestion on how one would use sync in this case? An example would be very helpful
    – modulitos
    Commented Mar 20, 2016 at 1:06
  • 5
    Adding "status=progress" e.g. "dd if=2018-11-13-raspbian-stretch-lite.img of=/dev/sdc bs=1M status=progress" let's you see progress of the operation
    – Mikkel
    Commented Feb 17, 2019 at 4:42
20

There is a tool called Etcher for Windows, Linux, and Mac. It has a simple GUI.

A screenshot from the website:


(source: etcher.io)

2
  • 1
    this is what I used after reading the installation instructions raspberrypi.org/documentation/installation/installing-images/… Commented Oct 2, 2017 at 13:45
  • What format should the sdCard be? I didnt want to use Etcher because it's a whopping 200MB. Fuck that. However, using dd makes the sdCard no longer mountable. I'm configuring a headless Raspbian and need to enable SSH and WiFi, which requires being able to mount the card.
    – chx101
    Commented Aug 31, 2020 at 21:15
5

Modifications to above Linux process if using Mac OS X:

  1. Hook up the card.
  2. Go to Disk Utility.
  3. Make note of partition name
  4. Go to About this Mac
  5. Click System report
  6. Go to USB
  7. Find the partition name list
  8. Make note of BSD Name (example: disk1s1)
  9. Go to Terminal
  10. type: dd if=path_to_image_file of=/dev/BSD_Name noted in previous step
  11. Wait a LONG time

    or you skip step 10 and 11 and use sudo dd if=path_to_image_file of=/dev/rBSD_Name bs=1M (note the r before BSD_Name, it's supposed to be there!)

3
  • Doesn't /dev/disk1s1 refer to the first partition? Commented Aug 10, 2012 at 6:00
  • Welcome to Raspberry Pi, nice answer! I edited your original post trying to improve its legibility. If you want you can double-check if everything is ok now.
    – Avio
    Commented Sep 29, 2012 at 9:19
  • Also, bs=1m must be lowercase rendezvouswithpavan.wordpress.com/2015/06/16/…
    – Jason
    Commented Oct 1, 2015 at 4:36
4

The Raspberry Pi Foundation now has their own image burning software called Raspberry Pi Imager. You can download it here: https://www.raspberrypi.org/downloads/

enter image description here

1

You can create an SD card directly on your Android phone - no PC required:

https://play.google.com/store/apps/details?id=com.redrobe.raspicardimager

Not the answer you're looking for? Browse other questions tagged or ask your own question.