Jumat, 03 Juli 2015

How to set up your Raspberry Pi in Linux

How to set up your Raspberry Pi in Linux

Getting prepared

If you've never used Linux before, don't worry. 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. We recommend Ubuntu, as it's ideal for beginners, but these instructions will work for nearly any other version of Linux – replace the Ubuntu Software Centre with your package manager of choice and ignore the desktop specifics.

Raspberry Pi Linux

Linux is also a good failsafe option, because it can be run from a live CD without installing anything. Just 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.

Getting started

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 on to 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.

Raspberry Pi Linux

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.

Install ImageWriter

We're going to use a tool called ImageWriter as a graphical front-end for writing the Raspbian image. 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.

Raspberry Pi Linux

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 card.

Write the Raspbian Image

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 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.

Raspberry Pi Linux

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, '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 15 minutes, but the progress indicator kept us updated, and when complete it was time to test the new SD card.

Test the SD card

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.

Raspberry Pi Linux

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.

Failsafe Install

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 it if nothing else works.

This method involves the command line and the dd command. This takes a raw input 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.

Raspberry Pi Linux

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 not a GUI in sight.











July 03, 2015 at 09:56PM
Linux Format

Tidak ada komentar:

Posting Komentar