Wednesday, September 4, 2013

Multi-flavor Raspberry Pi

In this post I'll  show you how to setup the BerryBoot boot loader.

In a previous post I walked though setting up Raspbian Wheezy. While Wheezy is a great operating system, with plenty of support and flexibility, it isn't the ultimate solution for everyone's needs. For instance, you might want to use your Pi as a media server or home theater PC (HTPC). While you can certainly do this with Wheezy, there are other choices that make this task even easier. So, as previously with Wheezy you'll need to download the new operating system (in this case OpenELEC  might be the OS of choice), then install it on an SD card. That's good, but what about some of those other cool OSs you wanted to check out? Ok, so maybe you should grab a few more SD cards at the store, just in case! Before you clear the shelf of SD cards, there's a better way! A way better way! It's called BerryBoot. BerryBoot is a boot loader. You're probably familiar with this already from Windows or Linux, but if not, a boot loader allows you to install multiple OSs and selectively pick one you wish to load at startup time. The nice part about BerryBoot is that it does this, but also does so much more, as you'll soon see.

First Things First
To begin you'll need to download and install BerryBoot from the link I provided above.  As a basic overview, you need a fresh SD card to which you can download the BerryBoot kernel. This kernel is responsible for loading BerryBoot and displaying the configuration menu. The first time you run BerryBoot you'll see options to verify the screen size and to use either a wired or wireless connection (as seen below). Once you've made the appropriate selections you'll be presented with an option to choose where you'd like to store any operating systems you choose to install. By default you can store them directly on the same SD card where you've installed BerryBoot, but the real power of BerryBoot lies in the fact that you can also choose to install it to other USB devices, such as a USB stick or hard disk.  

Stick To It
If you have a USB stick/external hard disk handy, you can insert it in the Pi and use BerryBoot to install your OSs of choice. Since the Pi only has two USB ports, you obviously may be port challenged. In my case I use VNC and a wifi-adapter, so there's still an available port. My other setup uses Ethernet and a wireless keyboard/mouse adapter, so this combination also gives me a free USB port. But, if neither of these setups work for you there's always the option to add a powered USB hub to one of the Pi's ports. Once you've chosen the setup that's suits your situation you'll want to connect a USB stick/hard disk to one of the available USB ports. Keep in mind that the next step will overwrite all of the data on this USB stick/hard disk. 

The Disk Selection screen presents you with options regarding where you want BerryBoot to store the installed OS's. Typically you'll see the USB stick/hard disk as the sda device (as seen in the screen shot below). Again, please verify the destination carefully because once selected all data is overwritten and cannot be restored. Once you've chosen the appropriate destination, press the Format button. You'll receive a warning...proceed with caution. There's no going back!

So Many Choices
Once formatting is complete BerryBoot presents you with a screen where you can select the OS's you wish to install (something similar to the screen below this section). I mentioned previously that BerryBoot was much more than simply a boot loader and there's the proof! With BerryBoot you can install multiple operating systems simply using point and click, while BerryBoot handles all the tedious details of downloading and installing them to your disk of choice. As with anything, there are some tradeoff's with this approach. BerryBoot maintains its own distribution repositories, since operating systems are stored in a compressed (i.e. squashed) manner. In practice that means you may not get the latest and greatest distros out of the box. But, typically you can still use sudo apt-get dist-upgrade to get them to the latest version after you've installed them.

A New Look
Once you've chosen and installed at least one operating system, BerryBoot is good to go. Now, each time you boot the Pi you're presented with BerryBoot's selection menu (as in the sample seen below). On the screen you can pick the operating system you wish to load and press Boot. Note that the default operating system will load after the specified timeout.

If you wish to change the default settings, timeout and so forth you can do that by pressing the Edit menu button. This presents you with the screen below. To set the default simply select an operating system in the list and press the Make Default button at the top of the menu. Now, when you boot the Pi it will automatically load the default operating system after a timeout. Typically the timeout is 20 seconds. You can change this value by clicking the >> button on the right of the screen and selecting Advanced Configuration. This presents you with a text editor. There you can select the cmdline.txt tab and set the bootmenutimeout value to the number of seconds you wish to wait before loading the default operating system. If you'd like BerryBoot to wait until you make your own selection you can do so by replacing the bootmenutimeout=xx value with nobootmenutimeout.

Add It Up
If you wish to add additional operating systems to your BerryBoot menu you can do so by choosing the Add OS button. This presents you with the screen above where you can select an operating system to install. Again, this list shows all of the available squashed operating system versions available through BerryBoot. For advanced users BerryBoot allows you to install your own squash-file operating system images by clicking on the down arrow next to the Add OS button. Basically, you'll need to create your new image on another Linux computer. I actually attempted creating one on the Pi. I wouldn't recommend it! It took hours and the image it produced was corrupted and unusable (your mileage may vary). But, in theory here's how this goes...use a tool such as Win32DiskImager (as mentioned in my previous posting) to save a current SD card image. Follow the steps on this BerryBoot page and create an image that you can add using BerryBoot. You'll need to place the image on a USB stick to load it (the only option). 

I hope this quick overview of the BerryBoot bootloader is helpful. I've found BerryBoot quite indispensable in allowing me to quickly check out new operating systems. Also, (crossing my fingers here) I've found the USB stick a much less error-prone way to load OSs. I've managed to crash Wheezy many times by overclocking, which often left the SD card with a corrupt filesystem and non-bootable. That hasn't happened yet with the USB stick. Each of the distros I've been testing with are still running well. 

In my next post I'll talk about how to play YouTube videos on the Pi. Until then, happy baking!

No comments:

Post a Comment