System images
In this section, we will give you the recipes to download, install, and update the Debian distribution firmware and software kernel that comes preloaded on your board. Finally, we will walk you through changing over from the currently shipping Debian 7.0 (Wheezy) to the newer Debian 8.0 (Jessie).
There are two basic methods to install and update your board's software: install the OS onto the eMMC solid-state internal drive or a compatible SD card (refer to the compatibility list in further chapters). In either case, the process is commonly called flashing the image, which is how we will refer to it.
Note
One of the signature features of the BBB is its ability to use many different flavors of Linux to run the board. In the further chapters, you will find references and material to install various versions of Linux, including Ubuntu, ArchLinux, and Android.
OS image flashing – internal drive boot
Although your board comes preloaded with a shipping version of Debian 7, you certainly want to understand how to replace it or update it when necessary. Here, we will discuss the recipe to flash the OS to your internal solid-state drive along with how to update to Debian 8.
As of the writing of this book, Debian 8 (Jessie) is still considered a testing option, whereas Debian 7 (Wheezy) is the official shipping firmware OS for the BBB. Additionally, you will notice "LXQt" as part of the URL download link. LXQt is a lightweight Qt variant of LXDE, the Lightweight Desktop Environment. Qt is a toolset to build cross platform applications that you can use on Mac OS X, Windows, and Linux. It uses the C++ programming language and has a nice GUI builder, so it is a popular choice for many open source-centric developers.
Getting ready
You will need the following:
- BeagleBone Black powered down.
- A 5V DC power supply. You can also use a 5V "wall wart" power adapter with a USB port on it as long as it can deliver 1A.
- A microSD card (4GB or greater).
- An SD card reader. You will insert the microSD card into the card reader and the card reader into an SD port on your desktop machine.
- A board connected to either an HDMI monitor or an LCD cape (as explained earlier in this chapter).
Note
If you had it connected, ensure that you remove the Ethernet cable before proceeding with this recipe as an Ethernet connection requires more current and will likely cause the software flashing to fail.
How to do it...
The following steps are used to flash the OS to your internal drive:
- Using the
wget
command, get the software and put it on your desktop computer.The latest version of the shipping OS, Debian 7 (Wheezy), is available at http://beagleboard.org/latest-images. So, you need to get the exact URL and append it accordingly in the following command:
$ wget https://rcn-ee.com/rootfs/bb.org/release/YEAR-MONTH-DAY/lxde-4gb/BBB-eMMC-flasher-debian-7.8-lxde-4gb-armhf-YEAR-MONTH-DAY-4gb.img.xz
The preceding link references a Rev. C board, the currently shipping version. If you have another version of the BBB, you can find software for prior releases at http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Debian_Build_Instructions.
Note
Debian testing version
You can also alternatively install Debian 8 (Jessie) using the same steps as the following, substituting the URL and appending the month, day, and year accordingly:
- Next, unpack, unzip, or unarchive the downloaded file using your favorite archive tool. On my Mac, I use Unarchive since it's easy to use and flexible. After unarchiving, there will be an
.img
file available in your chosen folder. - Now, we will flash the
.img
file to the microSD card. The easiest method is to use a GUI-type tool such as Pi Filler (originally designed for Raspberry Pi but works equally well on the BBB) for the Mac, or Win32 Diskimager on your Windows box.Wait for a prompt from the imaging software before actually inserting the SD card into the desktop's slot. Depending upon the speed of your desktop box's environment, the flashing/writing process will take anywhere from 15 to 30 minutes.
- Remove the SD card from your desktop after the flashing finishes and then remove the microSD card. Ensure that your BBB is powered down and then insert the card into the microSD slot on the BBB.
- Press and hold the Boot switch, which is the small button on the BBB above the microSD card slot. Take a look at the the following image to confirm that you are pressing the Boot switch and not one of the other switches:
- While holding this button down, insert the 5V supply into the power jack.
- As the board boots up, the array of LEDs next to the Ethernet jack at the other end of the board will begin flashing in a sweeping pattern.
- When the boot completes, all four LEDs should be lit and not blinking. Remove the power cable and then remove the microSD card from the BBB.
- Now, plug the 5V supply back into the board again. The BBB will boot directly from the eMMC.
- In your terminal window, we will now SSH into the board with the following command:
$ ssh debian@192.168.7.2
- When the login prompts appear, use the following credentials:
username: Debian password: temppwd
You should now be ready for action with the default graphical desktop showing the BeagleBone Black logo in the lower-right corner of the screen. This means that you are almost ready to go….
There's more…
Good practice to manage your system OS and files includes having enough room to add more packages, being able to clone your eMMC, and backing up your code image.
Expand your partition
Unless you use an SD card larger than 8 GB, you're likely to run out of space quickly on your card even after a modicum of packages are installed. So, save yourself a whole lot of hurt and expand your partition size….now! The following steps will be useful:
- Change to the root user with this command:
$ sudo -i
- Check the disk space usage using the following command:
root@beaglebone:~# df -h
- Go to this directory as follows:
# cd dir: /opt/scripts/tools
- Check the available files using this command:
# ls
You will see the
grow_partition.sh
script. This is a bash script included in the BBB distribution that will run a routine to expand your SD card space.Now, run the following:
# bash grow_partition.sh
Alternatively, you can also run the following command:
# sh grow_partition.sh
- Finally, running
ls
again on your drive will show a higher percentage of available space:# ls
Backing up a code image to a file
- Insert a microSD card into your desktop machine's card reader and confirm that it's recognized.
- On your desktop box (Mac, in our case), open Terminal and type the following:
$ diskutil list
- From the list shown, write down the ID for your SD card. In my case, it looks similar to this:
/dev/disk1
- Now, we will run a routine that backs up the content of the card to your desktop and simultaneously archives it to save space:
sudo dd if=/dev/rdisk1 bs=1m | gzip -9 > ~/Desktop/backupimage.img.gz
- Input your password at the prompt. When you do so, the routine will run and may take several minutes depending on the amount of data you're backing up.
OS image flashing – the SD card boot
In this section, you will learn the recipes to load the OS and boot from a microSD card. Much of the process is similar to how we flash the eMMC internal drive; however, it is important to take note of the differences.
Getting ready
You will need the following:
- BeagleBone Black powered down
- A 5V DC power supply or a USB tethered to the BBB.
- A MicroSD card (4 GB or greater)
- An SD card reader. You will insert the microSD card into the card reader and the card reader into an SD port on your desktop machine.
- A board connected to either an HDMI monitor or an LCD cape (as explained earlier in this chapter).
How to do it...
Perform the following steps:
- Using the
wget
command, get the latest software image and put it on your desktop computer.The latest version of the shipping OS is at http://beagleboard.org/latest-images. So, you will need to get the exact URL and append it accordingly in the following command. Note the URL difference from the prior recipe for flashing the internal drive:
$ wget https://rcn-ee.com/rootfs/bb.org/release/YEAR-MONTH-DAY/lxde-4gb/bone-debian-7.8-lxde-4gb-armhf-YEAR-MONTH-DAY-4gb.img.xz
The preceding link references a Rev. C board, which is the currently shipping version. If you have another version of the BBB, you can find software for prior releases at http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#Debian_Build_Instructions.
Note
Debian testing version
You can also alternatively install Debian 8 (Jessie) using the same steps by substituting the following URL and appending the month, day, and year accordingly:
- Next, unpack, unzip, or unarchive the downloaded file using your favorite archive tool. On my Mac, I use Unarchive as it's easy to use and flexible. After unarchiving, there will be an
.img
file available in your chosen folder. - Now, we will flash the
.img
file to the microSD card. The easiest method is to use a GUI-like tool such as Pi Filler for the Mac or Win32 Disk Imager on your Windows box.Wait for a prompt from the imaging software before actually inserting the SD card into the desktop's slot. Depending on the speed of your desktop box's environment, the flashing/writing process will take anywhere from 15 to 30 minutes.
- Remove the SD card from your desktop after the flashing finishes and then remove the microSD card. Ensure that your BBB is powered down and then insert the card into the microSD slot on the BBB.
Either with the USB tether or a 5V power supply, power up the BBB.
- In your terminal window, we will now SSH into the board with this command:
$ ssh debian@192.168.7.2
- When the login prompts appear, use the following credentials:
username: debian password: temppwd
Updating your current OS kernel
Sometimes, you want to stick with what you have already installed as it runs fine and does the job. But more often than not, you want the latest and greatest kernel, including updating to Debian 8.0, aka Debian Jessie. The following steps show you how:
- Ensure that you are logged in as the root user with the following command:
$ sudo -i root@beaglebone:~#
- Check the version of the kernel that you have currently installed:
# uname -r 3.8.13-boneXX
- Navigate to the directory with the update kernel script:
# cd /opt/scripts/tools/
- Run a command on the kernel you currently have installed that
pulls
down to your local drive information regarding any changes:# git pull
Note
We will explore the
git
command in a later chapter. - Now, we will run the script that takes advantage of the information we just pulled down and updates our OS:
# ./update_kernel.sh
- Time to reboot! Run the following command:
# reboot
- When the login prompts appear, use the following credentials:
username: debian password: temppwd
- Finally, verify that the script did what we expected through the following command:
$ uname -r 3.8.13-boneXX
Compare the preceding screen output with the version you wrote down in Step 2 of this recipe. You should, hopefully, see the new version kernel goodness.
See also
If you know a specific version you want, you can also update or modify your kernel with an alternative method using a series of command-line steps:
- Log in as root as follows:
$ sudo -i
- Check the kernel version with this command:
# uname -r
- Update your repositories with this command:
# apt-get update
- Find available kernel versions using this:
# apt-cache search linux-image
The screen output will deliver a long list of kernel options. Scroll the list until you find one with the label: Linux kernel, version 3.8.13-boneXX (with the XX being a two-digit number).
- Install the kernel you want by explicitly specifying a version number from the list in the prior step as follows:
# apt-get install linux-image-x.x.x-xx
- Reboot your board as follows:
# reboot $ uname -r
Your new kernel should now be installed on your board.