How to Flash an SD Card for Raspberry Pi

http://computers.tutsplus.com/articles/how-to-flash-an-sd-card-for-raspberry-pi--mac-53600


The Raspberry Pi is an incredible little computer made up of a components and connectors on an unfeasibly small printed circuit board that is approximately the dimensions of a credit card. Depending upon your intended use, your Rasberry Pi may have a keyboard, monitor and mouse added. Regardless of your intended use, you are going to need an SD (Secure Digital) card on which to install an operating system.

This tutorial describes how to install an operating system onto an SD card for use in your Raspberry Pi.

In order to get up and running with your Raspberry Pi, you will first need to flash an SD card. Whilst your Mac, or PC, uses a magnetic hard disc drive (HDD) or a Solid State Drive (SSD), your Raspberry Pi has no internal storage of its own.

Instead, the Raspberry Pi uses a Secure Digital (SD) card, such as is common as storage in many digital cameras.

This means that the Raspberry Pi will run from whatever operating system you install on an SD card. You can do from your main computer regardless of whether you are using Apple OS X, Linux or Microsoft Windows.

Not all SD cards are created equal, it seems, and some SD cards are known to work better than others. Some SD cards will refuse to work at all with your Raspberry Pi. It is worth checking the compatibility of any given SD card before you purchase. This has the potential to save much frustration further down the line.

Choose the right SD card for RPi
Choose the right SD card for RPi

It is recommended that you purchase an SD card with a minimum capacity of 2GB. Depending on which operating system you intend to use, it may be better to go for 4GB. Prices are coming down all the time to make these very affordable.

It’s not just the importance of SD cards, it’s the flexibility that they afford, too. Since changing the operating system in your RPi is as easy has swapping the SD card, it is possible to experiment with many different OSes simply by having a number of SD cards with a different system installed on each.

Tip: Before purchasing SD cards, it is worth checking their compatibility on this list of SD cards known to work with Raspberry Pi.

For the purposes of this tutorial I will be downloading Raspian, for Raspberry Pi.

The download will be compressed as a .zip file. You will need to extract the .img file before proceeding.

Tip: You can download a number of different operating systems, including RISC OS, Raspian, Raspbmc, Openelec and pidora, from the Raspberry Pi downloads site or you can download the NOOBS, New Out Of Box Software

Formatting an SD card is quite straight forward with Mac OS X. Start by pressingCMD SPACE to reveal the Spotlight search bar at the top right hand side of the screen. In this search bar, type disk utility and press return to launch the Disk Utilityapplication.

Select the SD card, in the left hand pane, and then select Erase ensuring that the format is MS-DOS (FAT).

Flashing an SD card is quite straight forward with Mac OS X. Start by pressing CMD SPACE to reveal the Spotlight search bar at the top right hand side of the screen. In this search bar, type terminal and press return to launch the Terminal application.

Insert the SD card into your Mac’s SD card drive.

To find the connected SD card, in the terminal window type:

Listing the volumes in OS Xs Terminal
Listing the volumes in OS X's Terminal.

Make a note of the identity of yours. In my example it is /dev/disk2 but yours may be different.

If the SD card was automatically mounted, as mine way, you will need to unmount it with the following command in Terminal. Remember to correctly identify your SD card if it is a different number to my example.

Unmounting the SD card is OS X
Unmounting the SD card is OS X

Navigate to the location that you downloaded and extracted the .img file from the .zip download. In my case it is the Downloads directory.

Navigate to the folder for the downloaded image
Navigate to the folder for the downloaded image

TIP: The dd command is very powerful and you risk serious corruption to your Mac if you use it incorrectly. Triple check your command before executing it, or use a different method (described below) to flash your SD Card if in doubt.

Ensuring that you replace the .img and destination, in my example, with the correct .img name destination disc for yours, enter the following command:

Flashing the SD card
Flashing the SD card

In my example, Terminal responded with Permission denied so, instead, I entered the following command, followed by my administrator password:

If you get Permission denied use sudo dd
If you get "Permission denied", use sudo dd

It will then take a few minutes to flash the SD card during which time no progress information will be shown. Be patient. On completion, you will get a confirmation with some information displayed in terminal.

Confirmation of completion in OS X Terminal
Confirmation of completion in OS X Terminal

You are now free to unmount the SD card for use in your Raspberry Pi.

If you are not comfortable, in flashing an SD card, using the command line interface (CLI) then you can instead download an app to do this for you.

I use RPi-SD card builder x1.2 which is a little friendlier. Download, extract and launch this app to avoid the CLI.

On launching RPi-SD card builder x1.2, you are presented with a Finder window in order to navigate and select your chosen .img file. The app, itself, will be running as a Raspberry Pi icon in the dock.

Locate and select the image and ensure that your SD card is plugged in and mounted.

Locating the OS image file
Locating the OS image file

You will be presented with a window asking you to select your SD card. Be extremely careful. All drives are selected by default and you could easily corrupt your Mac if you select the wrong disc. The clue is to look at the disc capacities and, in my example, you will see that the capacity of the SD card is only 8GB compared to 1TB for my Mac’s hard drive.

Pay attention to which volume you are selecting
Pay attention to which volume you are selecting - they are all selected by default and this could be catastrophic

Only when you are sure that you have selected only the correct SD card, enter your administrator’s password when prompted.

Enter your admin password to continue
Enter your admin password to continue

You are then given a warning not to remove the SD card whilst the app flashes the SD card. Click Continue.

Do not remove the SD card whilst flashing
Do not remove the SD card whilst flashing

You can monitor the progress of the operation by clicking on the rotating cog icon in the menu bar. The process to flash the SD card takes a few minutes, so be patient.

How to monitor the progress
How to monitor the progress

A dialogue box will advise you on the completion of the SD card being flashed. The SD card has already been unmounted, so you are safe to remove the SD card from your Mac for use in your Raspberry Pi.

Confirmation of completion
Confirmation of completion

The Linux distributions provided, for Raspberry Pi, are done so as a compressed image file. You will need to download, uncompress and then install onto your SD card.

For the purposes of this tutorial I am using Ubuntu, one of the most popular Linux distributions.

It may be necessary to format the SD card so that it can be read by your Raspberry Pi. If this is the case, you can use the Disk Utility application in Ubuntu.

Ubuntu Disk Utility
Use Ubuntu Disk Utility to format the SD card

Select your SD card and format as FAT.

Formatting the SD card using Ubuntu Linux
Formatting the SD card using Ubuntu Linux

Plug the SD card into the SD card drive on your Linux machine.

Open a terminal window and, to list the attached discs, type:

Listing the attached volumes in Ubuntu Linux
Listing the attached volumes in Ubuntu Linux

Identify the SD card and make a note of the device address, such as /dev/sdXwhere X denotes the storage device. Note, you can easily identify your SD card by looking at the capacities of the discs listed.

Once you have identified and formatted your SD card, you need to flash the SD card. This is done with the unix command dd.

Before proceeding, navigate to the directory that contains the downloaded and extracted .img file.

In a terminal window, enter the following, ensuring that the distribution name (in this example: if=2013-07-26-wheezy-raspbian.img) is correct and that the destination (in this example: /dev/sdb1) as they may be different to the ones used in this example:

Locating the downloaded image file
Locating the downloaded image file

TIP: You will need to exercise care using the dd command. Careless use may result in the corruption of your computer’s main hard drive if you incorrectly identify the drive required.

The process of flashing the SD card will take around two or three minutes during which time you are given no indication that anything is happening, unless your SD drive has a flashing LED.

Once the SD card has been flashed, you will see a further message in the terminal window.

Unmount the SD card and it is now ready for use in your Raspberry Pi.

Terminal confirmation of completion
Terminal confirmation of completion

Locate your SD card drive, in Windows Explorer, and secondary-click the mouse to bring up the context-senstive menu. From the menu select Format…. Ensure that the option FAT32 (Default) is selected and click Start.

Selecting an SD card to format
Selecting an SD card to format

A few moments later you will see a confirmation that the format has been completed and you SD card is now ready for the next stage.

Formatting the SD card
Formatting the SD card

In order to flash the SD card in Windows, it is necessary to first download a third-party application named Image Writer. (Here’s the direct SourceForge link for Image Writer)

Once downloaded, uncompress the .zip file by secondary-clicking it and selectingExtract all from the context-sensitive menu. This will normally place a folder of extracted files into the same folder that contains the downloaded .zip file.

Locate and open the folder of uncompressed files that you recently downloaded. Launch the Image Writer application by double-clicking the Win32DiskImager.exeprogram that you can see in the folder of extracted files.

If your PC asks you, give permission for the program to make modifications. This will open the Image Writer program.

Grant permission for the program to run
Grant permission for the program to run

In Image Writer click on the blue folder icon, to the right of the white box, and locate your .img file. This will be contained within a folder that you extracted from the downloaded .zip file. Select the .img file and click Open to populate the white box with the path to your image.

Selecting the image in Image Writer
Selecting the image in Image Writer

In the Device box, on the right, ensure that the drive letter for your SD card is selected.

Tip: You can double-check the correct drive letter, for your SD card, by pressing CRTL E to open Windows Explorer and locating the SD card drive.

When you are satisfied that the path to the .img file and the destination drive letter are both correct, click the Write button to start the process of flashing the SD card. The process will take four or five minutes and you will be shown a green progress bar during the course of the operation.

Image Writer progress
Image Writer progress

Upon completion, a confirmation window will be displayed and you will be free to close Image Writer and eject the SD card before removing it.

Confirmation message on completion of flashing the SD card
Confirmation message on completion of flashing the SD card
Advertisement

On booting your Raspberry Pi, with Raspian, after much activity on the screen, you will be asked to enter a username and password, which are:

Username: pi

Password: raspberry

Then, to start the Raspian GUI, enter:

On getting your Raspberry Pi out of the box, and plugging in peripherals, the task of flashing an SD card might seem quite daunting.

In this tutorial, I have shown you how to flash an SD card with Raspian using either Ubuntu Linux, Apple OS X or Microsoft Windows. With OS X, I have demonstrated flashing an SD card with both the command line and a third-party application.

This is not an exhaustive tutorial; there are many ways to flash the SD card. I have steered away from the command line as much as possible to make the process as easy as possible for beginners. Using the comments, below, let me know how you get on?


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值