Raspberry Pi and Installing Arch Linux

Raspberry Pi and Installing Arch Linux

Getting Arch Linux installed on a Raspberry Pi 2 was a challenge for me. Hopefully this post will help you set it up.

Arch Linux is a very robust Linux version. It only installs the base default packages to get running. Everything else must be installed as it is needed. You may find yourself needing to run the package installer often. (pacman -S) It was also nice that the network interface was setup with DHCP by default. All I had to do after install was to plug it into an ethernet cable.

In the process of a successful attempt to get Rocket.Chat and MongoDB running on the Raspberry Pi 2 from CanaKit I found that the only way I could get the correct version of MongoDB 3.2 that works with Rocket.Chat was to install Arch Linux. I outlined how I installed Rocket.Chat in another post called Installing Rocket.Chat on Raspberry Pi 2.

The major issue is that as of NOOBS 1.5 there was no support to install Arch Linux on the Raspberry Pi 2 using the NOOBS installer. NOOBS does display the option to install Arch Linux but it would then tell me that it could not find the right version of Arch Linux for Raspberry Pi 2. This required me to write the package to the SDcard and boot from there.

All the directions I could find indicated that the installation of Arch Linux boot files could be done from a computer. Unfortunately the computer had to be Linux but not Macintosh OS. I have a Mac and a Windows computer.

So I started up my handy Oracle VirtualBox running Ubuntu. But now I learn that VirtualBox and Ubuntu do not support the SD card port on the Macintosh with help from Mayur Rokade. He suggested using cell phone to connect as a USB device.

Old Smartphone as USB drive

I could not get this to work but then I found I had a usb to SD card adaptor from a Eye-Fi card.

SD Card USB Adapter

But Ubuntu still would not see the device. So a post from mayurrokade.com was helpful. I ended up having to “eject” the USB device from Finder. Then start Ubuntu in VirtualBox. Then it started appearing. Ubuntu did not see it until the Mac released it.

Now following the official directions at archlinuxarm.org I continued the setup.
Replace sdX in the following instructions with the device name for the SD card as it appears on your computer. To see what your device gets named use the command in the Ubuntu terminal.

sudo lsblk

This will display the names of the drives that are attached. On my computer it was: sdb

Start fdisk to partition the SD card:
fdisk /dev/sdX
At the fdisk prompt, delete old partitions and create a new one. This will delete all data on the SD card.
Type o. This will clear out any partitions on the drive.
Type p to list partitions. There should be no partitions left.
Type n, then p for primary, 1 for the first partition on the drive, press ENTER to accept the default first sector, then type +100M for the last sector.
Type t, then c to set the first partition to type W95 FAT32 (LBA).
Type n, then p for primary, 2 for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.
Write the partition table and exit by typing w.
Create and mount the FAT filesystem. These commands will create a folder called boot and root in whatever directory you are in. I recommend using /home/<username>. One partition is for booting up and has to be a FAT partition. The Root partition which is bigger needs to be a ext4 partition.

mkfs.vfat /dev/sdX1 mkdir boot mount /dev/sdX1 boot

Create and mount the ext4 filesystem:

mkfs.ext4 /dev/sdX2 mkdir root mount /dev/sdX2 root

Download and extract the root filesystem (as root, not via sudo):

wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

You will need to install the bsdtar package with pacman:

pacman -S bsdtar

This will expand the file and put Arch Linux in the root folder which is on the SD card.

bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root sync

Move boot files to the first partition called boot:

mv root/boot/* boot
Unmount the two partitions:
umount boot root

Insert the SD card into the Raspberry Pi, connect ethernet, and apply 5V power.
Use the serial console or SSH to the IP address given to the board by your router.
Login as the default user alarm with the password alarm.
The default root password is root.

Follow this blog and volumeint twitter to find out about the next posts on how to get a free SSL certificate for your chat server and future post on functional programming.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *