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?
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.
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
.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.
You can use
unzip from the command line.
The installation differs depending on whether you are using a Linux or a Windows host to flash the image onto the card.
- Insert your SD card into your computer and note down the drive letter it is assigned.
- Download and install the Win32DiskImager.
- 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!
- Click "Write" and watch the pretty progress bar.
Insert your SD card into your computer.
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 -lagain and note down what disks are there. Insert the SD card again, run
sudo fdisk -land it is the new disk.
Unmount the partitions by running
sudo umount /dev/sdx*. It may give an error saying the disk isn't mounted - that's fine.
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!
Once you have installed the OS eject the SD card properly and insert it into the Raspberry Pi. Attach power and enjoy.
Modifications to above Linux process if using
Mac OS X:
- Hook up the card.
- Go to
- Make note of partition name
- Go to
About this Mac
- Go to
- Find the partition name list
- Make note of BSD Name (example:
- Go to
dd if=path_to_image_file of=/dev/BSD_Namenoted in previous step
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
rbefore BSD_Name, it's supposed to be there!)
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/
I found myself doing this more often than I thought, and got tired of doing these steps manually and wrote a script that does the heavy lifting...
If you're on a Mac, you could try MakeMyPi which downloads, if necessary, a Wheezy image and writes it for you, then configures the Pi according to your liking (and any custom provisioning scripts), while filling the SD card with the root file system (so you're not limited to the default ≈2GB space). It even sets up wifi if you want.
The only things you have to do are set the configuration settings before you run it, insert the SD card, follow the instructions, and just a few minutes later you should have a working Raspberry Pi.
(I'm still learning, though, and I know this script can be improved. Feel free to contribute...)
You can create an SD card directly on your Android phone - no PC required: