Reference

Install ArchLinux on BeagleBone Black (Updated)

A few things have changed since I last wrote about installing ArchLinux on BeagleBone Black. This is an updated tutorial for release 4.13.0.

Tags: archlinux beaglebone

Overview

ArchLinux is a great operating system for low-cost ARM based embedded devices, such as the Raspberry Pi and BeagleBone Black. The development team for the ARM port is doing an excellent job optimizing and updating the package repository.

There were some changes to the installation steps since I wrote about how to Install ArchLinux on BeagleBone Black. Below you can find the condensed summary of the installation steps that I take on BeagleBones now.

Prerequisites

Before you can start with the installation, you have to prepare a bootable SD card with ArchLinux that will be used to install the operating system. If your desktop PC is also an ArchLinux system then you can follow the SD Card Creation steps on the official web site. Insert the SD card into the BBB and power on the system.

Many developers always boot their BBB’s from an SD card, and if you are one of them, you can skip the next section. I prefer to install the OS on the on-board 2GB or 4GB eMMC flash memory, so that I can use the SD card slot for other things.

Install ArchLinux to eMMC

After the BeagleBone booted from the SD card, log into ArchLinux using the default credentials root / root. We are now ready to install the image in the BeagleBone’s on-board flash memory. The steps are the same as the ones for SD card creation, except we are installing to the mmcblk1 drive now. First, zero out the drive and partition it:

# dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=8
# fdisk /dev/mmcblk1

Inside fdisk, type o to clear out any partitions, then type p to verify that there are no partitions left, then type n to create a new partition, then p for primary, then 1 (one) for the first partition on the drive, 2048 for the first sector, and ENTER key to accept the default last sector. Finally, write the partition table and exit by typing w.

Next, create and mount the file system on the flash drive’s newly created primary partition:

# mkfs.ext4 /dev/mmcblk1p1
# mkdir mnt
# mount /dev/mmcblk1p1 mnt

Now, download and extract the root file system into the partition. It looks like wget is no longer part of the ARM image, so we’ll use curl instead:

# curl -LO http://os.archlinuxarm.org/os/ArchLinuxARM-am33x-latest.tar.gz
# bsdtar -xpf ArchLinuxARM-am33x-latest.tar.gz -C mnt
# sync

Finally, install the boot loader:

# dd if=mnt/boot/MLO of=/dev/mmcblk1 count=1 seek=1 conv=notrunc bs=128k
# dd if=mnt/boot/u-boot.img of=/dev/mmcblk1 count=2 seek=1 conv=notrunc bs=384k
# umount mnt
# sync

That’s it, the OS installed and boot loader are now installed on the eMMC memory. Power down the system, and wait until all the LEDs go out:

# poweroff

Power off the BBB, remove the power chord, remove the SD card, and plug the power chord back in. Your BBB should now boot from eMMC.

Configure ArchLinux

Now that the system is up, log in as root / root and change the password:

# passwd
Enter new UNIX password: YourNewPassword
Retype new UNIX password: YourNewPassword

You can take a look at the system log to check whether there are any problems:

# dmesg

Then edit the package mirror list and uncomment the download servers that work best for you:

# nano /etc/pacman.d/mirrorlist

Let’s update all installed packages, so that the system is up to date:

# pacman -Suy

Set the system’s language and locale:

# nano /etc/locale.gen
  uncomment the entries you need, i.e. en_US.UTF-8
# locale-gen
# echo LANG=en_US.UTF-8 > /etc/locale.conf
# export LANG=en_US.UTF-8

Identify your time zone and set it permanently, i.e. /usr/share/zoneinfo/America/New_York:

# ls /usr/share/zoneinfo/
# ln -fs /usr/share/zoneinfo/<Zone>/<SubZone> /etc/localtime
# hwclock --systohc --utc

Set the machine’s host name:

# echo YourNewHostName > /etc/hostname

Create a new user account that you will use to log in from now on, and set its password. Also disable the default alarm user account:

# useradd -m -g users -G wheel,storage,power -s /bin/bash YourNewUserName
# passwd YourNewUserName

Finally, disable the default alarm account and reboot the device:

# passwd -l alarm
# reboot

Optional Post-Install Steps

Your BeagleBone Black is now fully set up and ready to go. I usually perform the following additional steps before putting it to work.

Install the base-devel packages if you want to compile code on the BBB:

# pacman -Syu base-devel

Install sudo, which will allow you to perform administrative tasks using the previously created new user account:

# pacman -S sudo
# EDITOR=nano visudo
  uncomment the following line
  %wheel ALL=(ALL) ALL

To further reduce the attack surface of your device, it is recommended to lock the root account. Note that you can always re-enable it later by setting a password for it:

# passwd -l root

Install auto completion for bash, so it is easier to find packages:

# pacman -S bash-completion

The BBB has an on-board entropy source for random number generation, so let’s use it instead of the software based one:

# pacman -S rng-tools
# nano /etc/conf.d/rngd
  update RNGD_OPTS to: RNGD_OPTS="-o /dev/random -r /dev/hwrng --no-tpm=1"
# systemctl enable rngd
# systemctl start rngd
# systemctl stop haveged.service
# systemctl disable haveged.service

And that’s it!

Related Resources

For tips on how to enable networking via USB and finding the BBB via Bonjour, check out Mark Conway Wirt’s blog post.