Monday, December 16, 2013

Setting up Arch Linux on Raspberry Pi

I've had a Raspberry Pi for almost a year now and despite my intention to use it for development it's ended up being used to run Raspbmc. I couldn't let it go a year without it being used for something more interesting so I spent some time this evening getting it configured for use.

I gave RISC OS a go first, thinking it'd be fun to use something completely alien to me but the novelty wore off within the first few minutes of using it. So I decided to scrap that idea and install Arch instead.

I've not used Arch since the move to systemd so it seemed like a good opportunity document the install process as my previous post about installing Arch is a little out of date.

To start with you need an SD Card with a recent Arch image. Here is my bash history from preparing the memory card:
$ diskutil list
$ diskutil unmountDisk /dev/disk1
$ sudo dd bs=4m if=archlinux-hf-2013-07-22.img of=/dev/disk1
$ diskutil eject /dev/disk1
Now is also a good time to change the root password. With that done, set the timezone and locale info. Start by uncommenting the line for your locale (in my case en_GB) from '/etc/locale.gen'. Now generate the locale settings:
# locale-gen
You'll also need to run the floowing two commands with the appropriate language and timezone:
# localectl set-locale LANG="en_GB.UTF-8"
# timedatectl set-timezone Europe/London
I'm using a Belkin wireless-N adapter with my Pi so I needed to setup my wifi using the following:
# install -m640 /etc/netctl/examples/wireless-wpa /etc/netctl/home-wifi
Then edit the '/etc/netctl/home-wifi' file with the correct SSID and password. Once done enable it:
# netctl enable home-wifi
You should now have internet access so do an update pacman -Syu then install vim:
# pacman -S vim
To get rid of some unsightly black borders on my monitor (overscan) I needed to edit the boot config:
# vim /boot/config.txt
Uncomment the line 'disable_overscan=1'. I also chose to uncomment 'hdmi_drive=2' as I only ever intend to force audio over HDMI.

I find the default console font a little small on a 1080p monitor so I also decided to create a /etc/vconsole.conf file with the following:
While on the subject of fonts, it may be worth installing these if you need some nice truetype fonts:
# pacman -S ttf-dejavu ttf-droid ttf-linux-libertine ttf-ubuntu-font-family
Before creating a user account install the sudo package and configure it so that all users in the wheel group can use sudo:
# pacman -S sudo
# EDITOR=vim visudo
Uncomment the line '%wheel ALL=(ALL) ALL'.

I'm using a 32GB SD Card for the installation so I had to resize the root partition. This can be done within Arch by using fdisk to delete the extended partition then recreate a new extended partition using the remaining space and another logical partition. Once the changes are written you'll need to reboot then run resize2fs. See Growing the RPi root partition for full details.

Most Linux users stick to using bash but I want my user account to default to Zsh, so have installed the package prior to creating the user account:
# pacman -S zsh
# useradd -m -g users -G audio,lp,optical,storage,scanner,video,wheel,games,power -s /usr/bin/zsh USERNAME
Set a password for the new user then exit and login as the newly created user.

To have a little colour in your zsh prompt add something like the following to the end of your .zshrc file:
PS1="%{%F{cyan}%}%n%{%F{red}%}@%{%F{blue}%}%m %{%F{yellow}%}%~ %{$%f%}%% "
As I'm going to be doing development on the Pi I also installed Java7, Python, NodeJS, Ruby, and a C compiler:
# pacman -S python python-pip ruby clang nodejs jdk7-openjdk openjdk7-src maven

No comments: