Installing Debian on the Beaglebone Black

Published September 29, 2013, by .

Last updated October 14, 2013.

()

The Beaglebone Black can boot from an internal eMMC ROM chip (on which the Angstrom GNU/Linux distribution is installed) or from a microSD card. In this post I describe the process of installing the Debian GNU/Linux operating system onto a microSD card for booting a Beaglebone Black.

The advantage of using a microSD card is that it can be removed (or copied) and used with another board easily.

You will need:

By following these instructions you should end up with a Beaglebone Black booting Debian from a microSD card, which you can log in to and execute commands on, from another computer on the same local network. Below is an illustration of this setup (it will not be necessary to be connected to the Internet):

The setup of the Beaglebone Black

Step 1: Get the Debian image

The first step is to download the Debian image and copy it to a microSD card.

Get the image:

$ curl -O http://s3.armhf.com/debian/wheezy/bone/debian-wheezy-7.0.0-armhf-3.8.13-bone20.img.xz

Next, copy this image onto the microSD card. To do so, determine the name of the card in the /dev directory.

On GNU/Linux, insert the card and run the following command:

$ dmesg | tail

The name of the card (sdb, sdc, or mmcblk01, etc.) should be listed.

On OS X, run the following command before and after inserting the card:

$ diskutil list

The name of the card (disk2, disk3, etc.) should be listed.

Now copy the image onto the microSD card. (On OS X, first download and install the xz utility from macpkg.)

$ xz -d debian-wheezy-7.0.0-armhf-3.8.13-bone20.img.xz
$ sudo dd if=debian-wheezy-7.0.0-armhf-3.8.13-bone20.img of=/dev/SDCARD

where SDCARD is the name of the card as determined above.

Step 2: Boot Debian

To boot from the microSD card, first power off the Beaglebone Black and connect it to a network switch with an Ethernet cable.

Then insert the microSD card, and while pressing down the boot button, plug in the board’s power. Continue to hold down the boot button until the LED start blinking.

The board will boot Debian and start an SSH server to log in to.

Step 3: Change the default password

Now that the Beaglebone Black boots Debian, log in with SSH from another machine on the same local network (connected to the same network switch):

$ ssh debian@192.168.1.2

The default user name and password is ‘debian’. Above, 192.168.1.2 is the IP address of the Beaglebone Black on the local network (LAN). To determine this address from the other machine on the LAN, simply ping addresses 192.168.1.2, 192.168.1.3, …, until the Beaglebone Black responds:

$ ping 192.168.1.2
$ ping 192.168.1.3
...

Note that 192.168.1.1 is the address of the switch.

Next generate a random password and write it down:

$ dd if=/dev/urandom bs=1 count=128 | sha1sum | cut -b-8

Change the default password to this new password:

$ sudo passwd debian

Log out and back in with the new password:

$ exit
$ ssh debian@192.168.1.2

Step 4: Restrict access to SSH

Next restrict access to the SSH server on the Beaglebone Black to machines on the local network:

$ sudo tee /etc/hosts.deny
ALL: ALL
^D
$ sudo tee /etc/hosts.allow
sshd: 192.168.1.
^D

The tee command will echo back what you type; end the input with an end-of-transmission character (^D) by typing Control-D on a new line.

Disallow root logins:

$ sudo tee -a /etc/ssh/sshd_config
PermitRootLogin no
^D

Finally, restart the SSH server, and log out and back in:

$ sudo service ssh restart

Step 5: Upgrade Debian

Next ensure that the software is up to date.

First choose a mirror from the list at http://www.debian.org/mirror/list.

Then edit the file /etc/apt/sources.list:

$ sudo nano /etc/apt/sources.list

so that it contains the following lines:

deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb http://ftp.us.debian.org/debian/ wheezy-updates main
deb-src http://ftp.us.debian.org/debian/ wheezy-updates main
deb http://ftp.us.debian.org/debian/ testing main contrib
deb-src http://ftp.us.debian.org/debian/ testing main contrib

replacing http://ftp.us.debian.org/debian/ with the mirror of your choice.

Next enable APT pinning by editing the file /etc/apt/preferences so that it contains the following:

Package: *
Pin: release a=stable
Pin-Priority: 900

Package: *
Pin: release a=testing
Pin-Priority: 500

Update: Ensure that there is a blank line between the first three lines and the second three lines above!

Update and upgrade the system:

$ sudo apt-get update
$ sudo apt-get upgrade

Finally, reboot:

$ sudo reboot

Step 6 (update)

Note that the image provided by armhf.com is only about 2 GB in size. That is, when the image is written to the microSD card in Step 1 above, the root partition will be less than 2 GB, even though the card may be larger.

If you plan on installing software on Debian once it is installed on the microSD card, you may run out of disk space. Therefore, resize the root partition on the microSD card so that it fills the card as much as possible.

To resize the root partition (labelled “rootfs”) on the microSD card with OS X, use the Disk Utility application. On GNU/Linux, use GParted: unmount the partition; resize it to fill the card; and apply the operation.

Conclusion

The Beaglebone Black will now boot Debian whenever the microSD card is present and the boot button is held as the power is turned on. It is now possible to log in from another machine on the local network and run commands.

In a future post I will explain how to install and log in to a graphical environment over the local network, rather than using the command line.

← Return to blog index