Raspberry Pi - Arch Linux Install Notes

From Wiki³

Image SD Card

Download and image your SD Card with the image located at Arch Linux ARM.


dd bs=1M if=/path/to/archlinux-hf-2013-07-22.img of=/dev/sdX


Download and install Win32DiskImager.

Initial Boot & Configuration

Go ahead and plug the SD Card back into the Raspberry Pi (RPi) and boot it up. You will eventually be greeted with the Arch Linux login prompt. Login to the system using the root account with the default password of root. Before you do anything it would be a good idea to change the root password.


System Update

First we need to update the system to make sure everything is current. Before you do so it would be a good idea to edit the /etc/pacman.d/mirrorlist in order to select a mirror that is closest to your location. I have found that the default auto-selection mirror doesn't work that well. Un-comment the mirror that best suits your location.

vi /etc/pacman.d/mirrorlist

Icon#Server = http://mirror.archlinuxarm.org/armv6h/$repo ... Server = http://ca.us.mirror.archlinuxarm.org/armv6h/$repo

You can also take this time to enable the Color option in the /etc/pacman.conf if you like.

vi /etc/pacman.conf

Icon# Misc options #UseSyslog Color #TotalDownload CheckSpace #VerbostPkgLists

Run pacman to update the system. After this it is safe to reboot to enact the changes.

pacman -Syu

systemctl reboot

Now that the system is up to date we can install packer and update the RPi firmware/kernel to the latest version. In addition to this we will be installing arm-mem which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes.

pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim

systemctl reboot


Upon login you should be able to see that you are now running the latest available kernel version. I now take the time to setup the actual system itself as if you just rebooted into a fresh Arch Linux installation.


After you have the RPi running the Linux kernel 3.x you will now have 8188eu wireless support. Next setup the wireless adapter for your local network.

cd /etc/netctl

cp examples/wireless-wpa wireless-home

vim wireless-home

Fill in your ESSID and Key, save the file and then change the permissions.

chmod 640 wireless-home

Next you can start up the interface and test your network connectivity (after unplugging your LAN connection).

netctl start wireless-home

ping google.com

If all goes well go ahead and enable it permanently.

netctl enable wireless-home


Begin by setting the hostname. I will be using the hostname archey.kyau.net.

hostnamectl set-hostname archey.kyau.net


Set the timezone. For me this is US/Pacific.

timedatectl set-timezone US/Pacific


Setup the appropriate locale. First edit the /etc/locale.gen file and un-comment the lines that correspond to your language selection. Generate the needed locales, set you keymap and finally set the with the system.

vim /etc/locale.gen

Iconen_US ISO-8859-1 en_US.UTF-8


localectl set-keymap us

localectl set-locale LANG="en_US.UTF-8"

Time/Date Syncing

Finally we can install and enable ntp. This is not required but as the RPi does not have a hardware clock it is useful to use a time syncing service.

pacman -S ntp

systemctl enable ntpd

User Management

With the system configuration out of the way it is time to create a user account, install sudo, give the user full access to sudo and then log off the root account. I will be using the username kyau for the extent of this write-up. Finally we can also change the root password.

useradd -m -g users -s /bin/bash kyau

passwd kyau

pacman -S sudo




At this point you can again safely shutdown the RPi. Once you see only the red LED lit you can safely pull the power.

systemctl poweroff

Parition Management

Next you will need to decide what you will be using as the main drive. If all you have is an SD Card use the second option. However if you plan on experimenting with overclocking or you happen to have an external USB hard drive or USB flash drive that is of adequate size it will be better in the long run to use this as your main drive instead. No matter which method you use you will always need an SD Card for at bare minimum the /boot partition.

Main Drive: USB Drive (OC-Friendly)

If you are going to be using a USB hard drive you should really consider moving the Arch install to the USB hard drive. This will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD corruption. Start by plugging your SD Card and USB hard drive into a separate Linux machine.


Pull up a list of all partition table information and locate the USB hard drive.

fdisk -l

Then launch fdisk on the USB hard drive. In my case this happens to be /dev/sdb.

fdisk /dev/sdb

Start by refreshing the drive to a DOS partition table, then create three partitions: a 15GB root partition, a 1GB swap partition, and finally the rest of the drive for the media partition.

IconWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): o Building a new DOS disklabel with disk identifier 0x2c00a6a4. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (256-976754644, default 256): Using default value 256 Last sector, +sectors or +size{K,M,G} (256-976754644, default 976754644): +15G Partition 1 of type Linux and of size 15 GiB is set Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): First sector (3932416-976754644, default 3932416): Using default value 3932416 Last sector, +sectors or +size{K,M,G} (3932416-976754644, default 976754644): +1G Partition 2 of type Linux and of size 1 GiB is set Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): First sector (4194560-976754644, default 4194560): Using default value 4194560 Last sector, +sectors or +size{K,M,G} (4194560-976754644, default 976754644): Using default value 976754644 Partition 3 of type Linux and of size 3.6 TiB is set

Next change the partition type of the swap partition.

IconCommand (m for help): t Partition number (1-3, default 3): 2 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'

Finally write the changes to the drive and format the partitions.

IconCommand (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

mkfs.ext4 /dev/sdb1

mkfs.ext4 /dev/sdb3

mkswap /dev/sdb2

Clone the Current System

Then mount the old and new system partitions and copy over the existing Linux installation.

mount /dev/sdb1 /mnt/usb

mount /dev/sdd5 /mnt/tmp

cd /mnt/tmp && cp -a * /mnt/usb

When finished un-mount both partitions and then mount the /boot partition from the SD Card.

cd && umount /mnt/{usb,tmp}

mount -t vfat -o rw,noauto,async,user,umask=1000 /dev/sdd1 /mnt/tmp

You will need to edit the cmdline.txt file and modify the boot line to boot off of the USB Drive instead of the the SD Card. If the USB Drive is the only external drive plugged into the RPi this will be /dev/sda.

vi /mnt/tmp/cmdline.txt

Iconipv6.disable=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=noop rootwait

You can now un-mount the SD Card and re-plug them into your RPi and continue.

cd && umount /mnt/tmp


Note that when booting off of USB there is an initial delay to initialize the USB drive right after you see the RPi logo. After you boot back into your RPi login and edit the /etc/fstab to reflect the new partitions.

sudo vim /etc/fstab

Icon# # /etc/fstab: static file system information # # <file system> <dir> <type> <options> <dump> <pass> /dev/sda1 / ext4 defaults,noatime 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/sda2 none swap defaults 0 0 /dev/sda3 /media ext4 defaults,noatime,nosuid,user 0 0 tmpfs /tmp tmpfs nodev,nosuid,size=2G 0 0

Then go ahead and reboot.

sudo systemctl reboot

Main Drive: SD Card

At this point remove the SD Card from your RPi and plug it into another Linux machine. Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with pre-defined partitions that are not sized to your entire SD Card. To fix this we will be making a backup of the install, then resizing the partition and finally re-formatting it with a different filesystem than before for better SD Card performance.

Use the fdisk command to display all of your devices and locate the device node of the newly inserted SD Card (it should look similar to below).

sudo fdisk -l

Icon   Device Boot Start End Blocks Id System /dev/sdc1 2048 186367 92160 c W95 FAT32 (LBA) /dev/sdc2 186368 3667967 1740800 5 Extended /dev/sdc5 188416 3667967 1739776 83 Linux

Backup Current Installation

First mount the SD Card to a temporary directory, then copy over (with permissions) the entire contents of the partition to a temporary folder.

sudo mkdir -p {/mnt/rpi,/mnt/rpi-backup/rpi,/mnt/rpi-backup/boot}

sudo mount /dev/sdc5 /mnt/rpi

cd /mnt/rpi

sudo cp -a * /mnt/rpi-backup/rpi/

When finished un-mount the partition before continuing.

cd && sudo umount /mnt/rpi

Expand the Linux Partition

Remembering the device node from earlier, go ahead and open it up in fdisk.

sudo fdisk /dev/sdc

Remove the Linux and Extended partitions.

Command (m for help): d Partition number (1,2,5, default 5): 5 Partition 5 is deleted Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 is deleted

Create new partitions using the entirety of the SD Card.

Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): e Partition number (2-4, default 2): First sector (186368-61405183, default 186368): Using default value 186368 Last sector, +sectors or +size{K,M,G} (186368-61405183, default 61405183): Using default value 61405183 Partition 2 of type Extended and of size 29.2 GiB is set Command (m for help): n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l Adding logical partition 5 First sector (188416-61405183, default 188416): Using default value 188416 Last sector, +sectors or +size{K,M,G} (188416-61405183, default 61405183): Using default value 61405183 Partition 5 of type Linux and of size 29.2 GiB is set

Write the changes to the partition table to exit fdisk.

Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.


F2FS (Flash-Friendly File System) is a file system created by Samsung intended for NAND-based flash memory. In my experience I have better results using this as apposed to ext3/4. If you are modifying the SD Card from an Arch Linux machine simply install the package for F2FS.

sudo pacman -S f2fs-tools

Format the new Linux partition on the SD Card with F2FS.

sudo mkfs.f2fs /dev/sdc5

Mount the new partition, edit the /etc/fstab in the backup to reflect changing to F2Fs and then copy back the Arch Linux installation.

sudo mount /dev/sdc5 /mnt/rpi

cd /mnt/rpi-backup/rpi

sudo vim etc/fstab

Icon# <file system> <dir> <type> <options> <dump> <pass> /dev/mmcblk0p5 / f2fs defaults,noatime,discard 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0

sudo cp -a * /mnt/rpi/

Un-mount the Linux partition. Mount the FAT32 boot partition.

cd && sudo umount /mnt/rpi

sudo mount -t vfat -o rw,noauto,async,user,umask=1000 /dev/sdc1 /mnt/rpi

Edit the cmdline.txt file to change the filesystem type from ext4 to f2fs. The file should now look something like the following.

Icon... console=tty1 root=/dev/mmcblk0p5 rootfstype=f2fs elevator=noop rootwait

You can now return the SD Card to the RPi and turn it back on. Your RPi will boot into the new F2FS partition which if you check df you should confirm it has been expanded to accommodate all the space available on the SD Card.

User Setup

Next I download and restore my RPi home directory backup.

wget http://kyau.net/kyau-rpi.tar.bz2

tar zxvf kyau-rpi.tar.bz2

rm kyau-rpi.tar.bz2

Re-login to enact all the changes.

Xorg Install

With the RPi fully configured let's move on to installing Xorg. Before we begin we must install the base development package group in order to build packages on the RPi.

sudo pacman -S base-devel git

Then proceed by installing the base for Xorg along with the proper video driver for the RPi.

sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa xf86-video-fbdev

Next install a window manager and some basic applications, themes and fonts.

sudo pacman -S openbox

sudo pacman -S lxappearance lxappearance-obconf obconf rxvt-unicode terminus-font

sudo pacman -S mirage thunar tumbler thunar-archive-plugin file-roller unrar zip unzip

sudo pacman -S gnome-icon-theme gnome-icon-theme-extras

sudo packer -S gtk-engine-mist elementary-icon-theme gtk-theme-elementary-bzr

Here you will encounter the first package that refuses to compile, the following message is roughly what you will see.

Icon==> ERROR: docbook-to-man is not available for the 'armv6h' architecture.

The solution is actually really quite simple, rerun the install command and this time choose to edit the PKGBUILD of that package. Modify the arch line to look like the following.

Iconarch=(i686 x86_64 armv6h)

The package should now build properly, you will encounter this a couple of times during the following steps use this exact method to remedy the problem every time.

Packages that need you to edit the PKGBUILD: gtk-engine-mist gtk-theme-elementary-bzr


Now that the Arch Linux baseline is finished let's get to installing XBMC.

sudo packer -S xbmc-rbp-git

The latest version they forgot to fix some permissions on the RPi with Arch. Let's add these now, create the following file and dump the contents into it.

sudo vim /etc/udev/rules.d/raspberrypi.rules

IconSUBSYSTEM=="vchiq|input", MODE="0777" KERNEL=="mouse*|mice|event*", MODE="0777"


With XBMC installed we can now configure Arch Linux to autologin to your user account.

sudo mkdir /etc/systemd/system/getty@tty1.service.d

sudo vim /etc/systemd/system/getty\@tty1.service.d/autologin.conf

Icon[Service] ExecStart= ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I 38400 linux Type=simple

Start X at Login

Finally let's get Xorg starting upon login.

vim ~/.bash_profile

Icon# Start X at Login [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

Auto-Launch XBMC

First we will need a utility called fbset.

sudo pacman -S fbset

The following is a pasted copy of the script I use to launch XBMC on start, I run this script from ~/.config/openbox/autostart. Modify it accordingly to update your resolution upon exiting XBMC.

Icon#!/bin/bash xbmc-standalone sudo fbset -depth 16 -xres 1920 -yres 1080 (sleep 1 && xrefresh) exit 0


Synergy is an application that allows you to utilize a single keyboard and mouse on a host computer to then operate multiple client computers from the single host. It is intended for scenarios where each client has its own monitor and will allow you to seamlessly scroll between screens/machines.

Install synergy on your host machine. If you need assistance with this there is a great video over at YouTube.


Open synergy and click "Configure Server".

Then drag one of the monitors in the upper left onto the grid location that represents that client monitors actual position in relation to your host machine.

Double click on the new client monitor.

Name the screen: archey


Install synergy.

sudo pacman -S synergy

Then use synergy to connect as a client to your host machine (mine happens to be named chloe).

synergyc --name archey chloe

If you wish to launch synergy on boot merely add the previous line to your ~/.config/openbox/autostart.

vim ~/.config/openbox/autostart

Icon# Set Background Color xsetroot -solid steelblue4 # Connect to Synergy (sleep 5 && synergyc --log ~/synergy.log --no-tray --name archey chloe) # Autostart XBMC xbmc-start &


If you want the Windows computers on your network to be able to access the media shares you will need to install Samba.

sudo pacman -S samba

Then copy the default config file and edit it to reflect your workgroup and a share for /media.

sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf

sudo vim /etc/samba/smb.conf

Icon[global] # workgroup = NT-Domain-Name or Workgroup-Name workgroup = KYAU # server string is the equivalent of the NT Description field server string = Archey Media Server ... [media] comment = Media Library path = /media public = yes read only = yes write list = @users

Setup samba to load on boot and then launch it now.

sudo systemctl enable smbd

sudo systemctl enable nmbd

sudo systemctl start smbd

sudo systemctl start nmbd

Finally don't forget to add your user to Samba and change the permissions for your shared folder.

sudo pdbedit -a -u kyau

sudo chown -R kyau:users /media/

Raspberry Pi Tweaks

If you are looking to get more out of your RPi consider doing any or all of the tweaks listed in this section.

RPi Config

The following is my RPi config.txt in its default mode (no overclocking enabled). You will need to un-comment and edit in your license keys and modify the gpu_mem parameter accordingly.

cat /boot/config.txt

Icon## Memory # Disable ARM access to GPU's L2 cache. Needs corresponding L2 disabled kernel. #disable_l2cache=1 # GPU memory in megabyte. Sets the memory split between the ARM and GPU. # ARM gets the remaining memory. gpu_mem=256 # Disable adjusting the refresh rate of RAM every 500ms (measuring RAM # temperature) #disable_pvt=1 ## CMA - Dynamic Memory Split # When GPU has less than cma_lwm (low water mark) memory available it will # request some from ARM. #cma_lwm=16 # When GPU has more than cma_hwm (high water mark) memory available it will # release some to ARM. #cma_hwm=32 #cma_offline_start=16 ## Camera # Turn off the red camera LED when recording video or taking a still picture. #disable_camera_led=1 ## Video # Disable overscan if your display has a black border of unused pixels visible # and your display can output without overscan. #disable_overscan=1 # Overscan adjusting. Positive numbers if console goes off screen and negative # if there is too much border. #overscan_left=16 #overscan_right=16 #overscan_top=16 #overscan_bottom=16 # Force a console size, default is display's size minus overscan. #framebuffer_width=1280 #framebuffer_height=720 # Console framebuffer depth in bits per pixel. #framebuffer_depth=16 # Disable alpha channel. (helps with 32-bit) #framebuffer_ignore_alpha=1 # Enable test sound/image during boot for manufacturing test. #test_mode=1 # Signal strength of the HDMI interface. #config_hdmi_boost=4 # Rotates the display clockwise on the screen or flips the display. #display_rotate=1 ## Licensed Codecs # License key to allow hardware MPEG-2 decoding. #decode_MPG2=0x12345678 # License key to allow hardware VC-1 decoding. #decode_WVC1=0x12345678 ## Boot # Avoids the rainbow splash screen on boot disable_splash=1 ## Overclocking ##None #arm_freq=700 #core_freq=250 #sdram_freq=400 #over_voltage=0 ##Modest #arm_freq=800 #core_freq=300 #sdram_freq=400 #over_voltage=0 ##Medium #arm_freq=900 #core_freq=333 #sdram_freq=450 #over_voltage=2 ##High #arm_freq=950 #core_freq=450 #sdram_freq=450 #over_voltage=6 ##Turbo #arm_freq=1000 #core_freq=500 #sdram_freq=500 #over_voltage=6 # vim:ft=conf


For a noticable difference in performance create the file ~/.xbmc/userdata/advancedsettings.xml and paste in the following.

vim ~/.xbmc/userdata/advancedsettings.xml

Icon<advancedsettings> <videolibrary> <cleanonupdate>true</cleanonupdate> </videolibrary> <network> <cachemembuffersize>5282880</cachemembuffersize> </network> <fanartheight>560</fanartheight> <thumbsize>256</thumbsize> <gui> <algorithmdirtyregions>3</algorithmdirtyregions> <nofliptimeout>0</nofliptimeout> </gui> <lookandfeel> <enablerssfeeds>false</enablerssfeeds> </lookandfeel> <bginfoloadermaxthreads>2</bginfoloadermaxthreads> </advancedsettings>