Raspberry Pi - Arch Linux Install Notes

From Wiki³
Revision as of 15:48, 11 September 2013 by Kyau (talk | contribs) (→‎Xorg Install)

Image SD Card

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

Linux

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

Windows

Download and install Win32DiskImager.

Initial Boot & Configuration

System Update

First we need to update the system to make sure everything is current. Login to the system using the root account with the default password of root and 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-headers-raspberrypi-latest linux-raspberrypi-latest vim

systemctl reboot

Configuration

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.

Hostname

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

hostnamectl set-hostname archey

Timezone

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

timedatectl set-timezone US/Pacific

Locale

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

locale-gen

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

visudo

Iconkyau ALL=(ALL) ALL

passwd

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

Partition Management

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

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.

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

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 packer -S openbox-git

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.

sudo pacman -S lxappearance lxappearance-obconf notify-osd rxvt-unicode stalonetray ttf-liberation

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

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

sudo packer -S terminus-font

Packages that need you to edit the PKGBUILD: docbook-to-man openbox-git volumeicon-git gtk-engine-mist gtk-theme-elementary-bzr