APC Australia

How to run Arch Linux on the Pi

Jonni Bidwell installs Arch Linux in less than three days and discovers the best way to browse the web is from the console.

-

The Raspberry Pi 4, thanks to its faster processor, USB connectivi­ty and networking, is oft-touted as a desktop replacemen­t. Be that as it may, we’re going to show you how even an early model Pi can run a desktop… of sorts. We’re going to use the community ARM port of Arch Linux to set up a lightweigh­t desktop running i3. To add insult to injury, we’ll combine the w3m browser, the mpv media player, and the popular youtube-dl script. This will enable you to browse YouTube (its many adverts and other streaming sites) from the comfort of a terminal window.

Arch Linux is generally recognised as being hard to install, and its ARM counterpar­t is certainly a far cry from installing Raspberry Pi Linux. However, once we’ve minted our SD card (which we’ll soon see is a bit of a rigmarole), we pretty much have a working system. If you already have Arch installed on your PC, you can follow the second half of the tutorial to join in the console web-browsing fun.

Prepare the SD card

Arch Linux ARM don’t provide an OS image that we can write (using Etcher or the like) directly to an SD card, they instead provide a filesystem tarball that we have to extract manually. So the first step is to prepare our media. We’ll assume you’re working on a Linux PC with an SD adapter (with at least a 4GB card inserted) for this part. We’ll also use GParted (a sudo apt install gparted away if you don’t have it) to do the partitioni­ng for us, but if you want to use fdisk at the terminal, follow the official instructio­ns at https:// archlinuxa­rm.org/platforms/ armv7/broadcom/raspberryp­i-2.

Open GParted and make sure the SD card is selected in the top right (it would be a grim start to the tutorial if you were to inadverten­tly delete hard drive partitions here). Make sure there’s nothing you care about on the card and then delete all the partitions.

Create a new partition using the button in the top-left. Leave it as a Primary Partition, make it 100MB and choose FAT32 for the filesystem. Then click Add. This will be our /boot partition. Create a primary data partition using the rest of the space, leaving the filesystem as ext4 this time. Hit the green check mark in the toolbar to apply the changes, heeding the subsequent warning.

Now open a terminal and mount our new partitions. SD partitions may be named as below, or as regular mass storage (for example, /dev/sdb2), or something else depending on your hardware. Use the lsblk command to make sure you get the right one:

$ sudo mkdir /mnt/piroot/ $ sudo mount /dev/mmcblk0p2 / mnt/piroot

$ sudo mkdir /mnt/piroot/boot $ sudo mount /dev/mmcblk0p1 / mnt/piroot/boot

Now fetch the Arch Linux ARM archives. If you’re running a Pi 3 or later, you may prefer to get the ARMv8 (64-bit) files instead in which case swap the 2 for a 3 (or 4) in the below:

$ wget http://os.archlinuxa­rm. org/os/ArchLinuxA­RM-rpi-2latest.tar.gz

Extract the filesystem onto your newly created mountpoint­s. Don’t be alarmed by the warnings about permission­s (which the FAT32 partition can’t handle).

$ sudo tar -xpf ArchLinuxA­RMrpi-2-latest.tar.gz -C /mnt/piroot $ sync

It’ll take a couple of minutes to extract all that data. While it’s doing that, dig up a monitor, keyboard and USB power for your Pi. The second command ensures all cached data is written before you remove the card.

We won’t cover setting up wireless here (refer to the Arch wiki for that), but we will cover other basic setup via Ethernet. Put the card in and boot your new mini computer. Log in with username and password root

then update the package keyring and database. For good measure, we’ll update the system too:

# pacman-key --init # pacman-key --populate archlinuxa­rm

# pacman -Syu

It’s good practice to set a system

locale at this point, otherwise we might run into all kinds of weird bugs later. To do this, edit the file / etc/locale.gen and uncomment a line that correspond­s to where you are. Australian residents should choose en_AU.UTF-8 UTF-8 for example. Then change /etc/locale. conf accordingl­y, so for Australia we’d say:

LANG=en_AU.UTF-8

Launch i3

Let’s jump straight in to getting i3 up and running with:

# pacman -S i3

Then hit enter to install the whole i3 group (which includes a screen locker and status writing scripts).

We’ll need the X.org server as well, but we won’t bother with a login manager. Instead, you’ll be starting the GUI from the terminal, which requires the Xinit scripts. We’ll also need a terminal emulator, and we’re going to go with the lightweigh­t, but Unicode capable, Urxvt (aka, rxvt-unicode).

# pacman -S xorg-xserver xorg-xinit rxvt-unicode

Now we need to create a simple .xinitrc in our home directory, so log out and log in as the standard user (username and password are both alarm , and you may want to create a new user later on).

$ echo exec i3 ≥ .xinitrc

Consider modifying your . bashrc if you want the GUI to start on login. Again, you’ll find how to do this on this, as well as lots of helpful snippets for your .xinitrc file, in the Arch Wiki. You should now be able to start the display server with a simple startx .

Hopefully i3 will start, in all its minimal glory. Use the Super (Windows) and Enter shortcut to start a terminal. It will be full screen (and slightly imposing) because that’s how tiling window managers are. See the box (right) for details of how to configure fonts and colour schemes. For now, we’ll get on with setting up glorious console web browsing. Switch to the root account with the su and then add the final pieces and return to the normal user account:

# pacman -S w3m mpv youtubedl # exit

Feel free to have a play with w3m, for example, w3m https:// techradar.com . You can navigate with the cursors, jump between links with Tab and open them with Enter. Check the manual for more.

Anyway, w3m isn’t quite ready for streaming video yet, so quit by pressing Q. W3m enables you to open URLs with different programs (so-called external browsers), so we’ll set up the hotkey O to open files with the mpv media player. Mpv has bespoke support for youtube-dl, so after this quick change, we should be ready to go. Edit w3m’s configurat­ion file at ~/.w3m/ config and scroll down to the extbrowser line. Change it to read extbrowser /usr/bin/mpv -ytdl and save the file. Now press O on video links and they should open in mpv! The ARM package for w3m may not give you a config file by default, but you can just use that line on its own.

Oh, and because it would be terrible to end this tutorial without showing you how to get out of i3, Super-Shift-e is the combinatio­n you need!

“Arch Linux is generally recognised as being hard to install, and its ARM counterpar­t is certainly a far cry from installing Raspberry Pi Linux. However, once we’ve minted our SD card, we pretty much have a working system.”

 ??  ?? Arch is all about doing things yourself, such as hand-crafting the partitions on an SD card.
Arch is all about doing things yourself, such as hand-crafting the partitions on an SD card.
 ??  ?? Theoldnet.com reminds us of simpler times. W3M can sometimes load more advanced sites, but this varies with the weather.
Theoldnet.com reminds us of simpler times. W3M can sometimes load more advanced sites, but this varies with the weather.

Newspapers in English

Newspapers from Australia