2013年8月13日 星期二

How to install Raspbian on Raspberry Pi from a USB stick

If you've never used Linux before, don't worry. These days, it's just as easy to use as any other operating system, and in many ways, it's easier. There are no drivers to chase and new applications are always installed through the Linux equivalent of an app store.
And, as you're going to be installing and using Linux on your Raspberry Pi, it makes good sense to create your SD card from within a Linux environment. It doesn't make the installation any better, but it gives you a great opportunity to try it out before plugging in your Raspberry Pi.
1. Share the features

step 1
We recommend the Ubuntu distribution, as it's ideal for beginners, but these instructions will work for nearly any other version of Linux - just replace the Ubuntu Software Centre with your package manager of choice and ignore the desktop specifics.
Linux is also a good failsafe option, because it can be run from a live CD without installing anything. Insert the CD and boot your machine from the optical drive. After a few moments, choose the Try Ubuntu option from the menu, rather than Install. This will take you to the Ubuntu desktop without needing to install anything on your machine.
2. Be prepared

step 2
The one problem with using the live CD for an installation is that you won't be able to download the Raspbian image. There isn't enough RAM allocated for storage space on the desktop session, so you'll need to download the image onto some external storage (but not the SD card we're using for the Raspberry Pi). Users with Linux installed won't have to worry about this, and they can just download the latest image directly to their hard drive.
With the image sorted, you should also check the state of your SD card. Insert this into a card reader and it should appear on your desktop with a window for each partition on the drive. All this data will be lost when we install Raspbian, so you need to make sure there's nothing you want to keep.
As Ubuntu loads the contents of each partition, regardless of the way each partition is formatted, you can check every spare byte of your storage if you need to.
3. Install ImageWriter

step 3
We're going to use a tool called ImageWriter as a graphical front-end for writing the Raspbian. This can be installed from Ubuntu's Software Centre application, which can be launched by clicking on the basket icon in the Launch Bar. Search for 'imagewriter'. A single result should be returned.
Double-click on this and the next screen will announce this is available from the 'universe' source. This is an additional repository for software, and it's not enabled by default, but you need to click on the Use This Source button to access it. Wait for the progress button to finish updating the internal package list then clear the search field and search for 'imagewriter' again.
You should find that the package has been updated, and when you select it, an Install button appears. Click on this and the package will be downloaded and installed automatically.
You might wonder why this worked when you're using a live CD, but the answer is that there's enough room in the memory to install quite a few packages, just not enough to hold the entire Raspbian image. With ImageWriter installed and your SD card mounted, you're now ready for writing the Raspbian image to your SD card.
4. Write the Raspbian Image

step 4
ImageWriter needs to be launched with your SD card connected, otherwise it won't run and instead complain it can't find any storage.
When the main application window appears, you need give it one or two parameters. The first is the location of the Raspbian image you want written to the USB stick, and the second is the device you wish to write the image to.
It's the second that's most important because if you've got more than one device connected - such as to read the image off an external drive while you write it to the SD card - the wrong selection could overwrite your data. Both Windows and OS X suffer from the same problem, but at least with Linux it will only let you choose an external USB storage device. It will also display the name of the manufacturer so you can be sure you've selected the correct device.
When you're ready, click on Write to device. If you've got the correct one, the activity LED for the SD card should start flickering to indicate data is being written. If not, it's wise to close the ImageWriter window as soon as possible to halt the process. The Write process can take a while, as it depends on the speed of your storage and USB ports. Ours took about 15 minutes, but the progress indicator kept us updated, and when complete it was time to test the new SD card.
5. Test the SD card

step 5
Unlike with both Windows and OS X, Linux is the only operating system that can read both of the partitions created by the write process. The first is formatted with a Windows FAT filesystem and is almost 60MB in size. This is how the USB stick boots the Raspberry Pi, as this partition is read first before passing control on to the second partition.
The second takes up the best part of 2GB and contains the root Linux filesystem. As both of these partitions will be mounted when you next insert the SD card into Ubuntu, you'll be able to take a closer look at the files both partitions contain. The Linux one will be very similar to the desktop version of Ubuntu you might be running, and this is because they're both derived from the same 'parent' distribution, called Debian.
The home folder, for example, contains a user's own folder, where they can store their files and settings. Raspbian is pre-configured with only a single user, called 'pi', although this can be easily changed when you've got the distribution running, and you can see this folder and the files it contains when you click on Home. When you've finished, unmount the device from the file manager and insert the card into your Raspberry Pi.
6. Failsafe Install

step 6
There's one other method for installing Raspbian on the SD card, and we want to cover it because it's useful as a fallback. But this method does make it easy to accidentally overwrite your data, so we'd only recommend this if nothing else works. This method involves using the command line and the dd command. This takes a raw feedback and copies it - byte for byte - to another device.
Get the destination device wrong, and you'll be overwriting a hard drive with your precious photos on it.
To get the device correct, first disconnect your SD card and look for and launch Terminal from Ubuntu. This will open the interface to the famous Linux command line, but it's really not all that difficult. Now type tail -f /var/log/syslog and insert your SD card. What you're doing is displaying the output logs of the system, and you need to look for a line that looks like sdb: sdb1. This means the system has detected a new device and given it a node on your file system of sdb (sdb1 is the first partition on sdb).
There should be lots of other output as your Linux box attempts to read the filesystem and mount it. If it is mounted, unmount it from the GUI and then type sudo dd bs=1M if=raspbian. img of=/dev/sdX, replacing both the IMG filename and the /dev/sdX node with those of your specific configuration. The image will now be written to the SD card with out a GUI in sight.
Fixing faults

Raspberry Pi LEDs
The big difference between your Raspberry Pi and your PC is that the Pi doesn't have a BIOS. It's the BIOS you see first when you turn on your computer - the retro-looking splash screen or the text detailing CPU, memory and storage, only it appears too quickly to read.
If there's a problem with your PC, the BIOS can often be used to troubleshoot the booting, and it will also create noise and flash LEDs if bad memory or a dodgy CPU is detected. But without the facilities of a BIOS, the Raspberry Pi doesn't have the same level of fallback, and while, hopefully, your Pi will boot first time without problems, the more you play with your Pi the more likely it's going to be you encounter a boot problem. Which is what these two pages are for.
What the LEDs mean

The only clues you get about how the process is doing is from the bright bank of LEDs next to the audio jack and USB ports. The Model B sports five LEDs, while the Model A has only two, although the printed labels remain.
LED1: Green, labelled ACT: SD Card Access
LED2: Red, labelled PWR: 3. 3 V Power is present
LED3: Green, labelled FDX: Full Duplex (LAN) connected
LED4: Green, labelled LNK: Link/Activity (LAN)
LED5: Yellow, labelled 100: 100Mbit (LAN) connected
As the Model A has no wired networking, the last three LEDs aren't present on the PCB, and you'll find the labelling is slightly different on earlier revisions of the Model B, although their functions are identical.
When you first connect the Pi to a power source, the red LED2 should light. This indicates the device is getting the correct amount of power, and this LED should remain lit for the entire period your Raspberry Pi remains on. Even when there's no network connection, or if the SD card isn't connected, this LED should stay lit. If it flickers, or if it goes off, you've got a problem with the way your device is receiving power, and the first thing you should check is the cable and the power supply unit.
With the SD card connected, the edge-side LED should be the next to light. This is the LED that signals that data is being read from the inserted SD card.

沒有留言:

張貼留言