Du er her

Setting up Arch Linux on a PI 3 (with all wistles and bells)

You need:

  • Enough experience to run a Linux Live CD and enter some commands on the bash command line.
  • A PC running windows (or Linux - then you can skip the making of the USB Live stick)
  • If your computer don't have a SD-card reader, you will need one of those for USB.
  • An USB stick with at least 2 GB capacity.
  • A Raspberry PI 3 With a good power supply. 2A is fine.
  • A Micro SD card. I recommend 8 GB or bigger. In this tutorial I am using a 32 GB one.
  • Screen, mouse and keyboard.
  • Internet connection (both wired and WiFi is best and what this tutorial is using).

Let us start:

If you as me have a windows computer besides the PI, you will need too boot your computer with Linux for this the formatting of the SD card and adding the OS to it.

I am using Linux Mint 18 Mate for this tutorial, but if you're used to another distro, that'll work too. Just be sure that «Gparted» is in it, since I use that application in this tutorial. Any later version of Mint will also work fine.

To put Mint on the USB stick you will need the windows version of «Unetbootin», So download and install that. It need no installing but comes as an executable file.

Now download the Linux ISO.

I do not know what condition your USB-stick or SD-card is. For all I know you have used it for Linux or Mac or whatever before, so you might have partitions on it that Windows cannot see. So for the USB-stick, download SDFormatter that is very good both for reclaiming USB-sticks and SD-cards. This time we'll only format the USB-stick with SD-formatter, since we'll do the SD-card from the live DVD in Linux,

Insert the memory USB stick and format it as FAT32:

Now, start Unetbootin. I am sorry that my screenshots of Unetbootin is Norwegian, but it follows my regional settings of my computer, and since you find things at the same place in any language I didn't bother.
You just click on the radio box marked «Diskimage» (Diskavtrykk) find the ISO, and click «OK» and you will be making your bootable Linux USB.
 

Next, reboot your computer from the USB disk...

 

In Linux (Mint):

The first thing you want to do is changing the keyboard layout (if English keyboard layout is wrong for you).

In the menu, find Preferences -> Keyboard.

Choose the flap called Layout an press the plus at the bottom left to add your keyboard.

 

Then find your layout, click it to choose it and then click «Add».

You will now have two keyboard layouts there. English (US) and your newly chosen one. Delete English(US) and close the window. You will now find the keys where you are used to finding them.

Next, insert your SD-card in the card reader. Start GParted to partition the SD-card. The card must in before you start GParted for it reads the disks only at startup, so any drive not available at startup won't be seen.

Once GParted opens, find your drive at the right top in the program and choose it.

Right click on all partitions on the card and unmount them.

Now, delete all partitions.

After that your whole SD-card contain one unallocated area. We need to add two partitions. One primary, FAT32 using 100 MB, Labeled BOOT and one primary, EXT4, using the rest of your disk, labeled ROOT. Do not forget to label them at this step, since it cannot be done at any later stage.
You make them by right clicking the unallocated place and fill in the form as shown:

When this is done, apply the things you have done to the disk:

Again, by right clicking the partitions, format them:

Once more, click the «Apply all operations»-button. When it's done, close GParted. Take out the card and re-insert it, so it gets mounted with the new partitions.

 

The command line operations:

First a disclaimer. When I made the command line operations part, I was leaning heavily on Arch's own page about installing the base system. I urge you to visit that page as it is where I got most of the commands from, and the page might change, rendering some of my instructions plain wrong. Thank you to the Arch team for the instructions.

Some people do not like the command line interface. I don't mind it. Its fast and it can do anything (in Linux). Well, if you can't stand the CLI, don't read any further. We'll be using it a lot! I mean a lot!

I will also put several commands on the same line separated by a semicolon «;». You can run them as they are written. They can also be run one by one, omitting the semicolon.

Ah, well, for those of you that are still here, start the command line interface or as it is called in Linux, the Terminal. If it's written in blue, it's commands you are to enter. I expect that you understand that you have to press [Enter] at the end of the command. If I want to specify something from the output of commands it'll be dark green.

 

Make two directories to mount the partitions of the cart in when we're going to work with them: mkdir root; mkdir boot

We need to know what the device names for the partitions are, so we can mount them where we want: df -h show you the devices and sizes for your disks.

As shown by the last entries in the mount table, in my file system they are at /dev/mmcblk0p1 and /dev/mmcblk0p2

Now we can unmount the disks and mount them where we want: sudo umount /dev/mmcblk0p1; umount /dev/mmcblk0p2
Then we mount them where we want: sudo mount /dev/mmcblk0p1 ~/boot; mount /dev/mmcblk0p2 ~/root

The «sudo» in every command gives you root credentials for that command, allowing you to do manual mounts and unmounts.

Download the root file system: wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

In order to extract the file system correctly we need to install a program for that as it isn't installed on the live DVD: sudo apt-get install bsdtar

Then extract it: bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
Just to be on the safe side, synchronize the disks: sync

The boot files must be moved to the boot partition: mv root/boot/* boot

And then, finally, unmount the partitions:sudo umount boot root

Your new Linux!

Now remove the SD-card and insert it in your PI 3 and connect it so it boots. Be sure to have a cabled network as that will work straight away. We will configure WiFi once X-windows and the XFCE desktop environment are installed.

WARNING!
This tutorial does not explain configuring of the CLI, as we will get all done from a X-terminal, so we do not need that for this tutorial. You need some things to do after this tutorial ends too.

On this install there are two users installed: Your login user «alarm» with the password «alarm» and of cause «root» with the password «root».

First you log in as root. Normally that is a no-no, but for now we'll do only administrative tasks, so for now, use the root account.

Update the OS: pacman -Suy Answer «Y» when you get asked.

Sound won't work! You need to edit /boot/config.txt, adding a line at the end: echo dtparam=audio=on >> /boot/config.txt After rebooting (later), the sound will work.

Install alsa utils: pacman -S alsa-utils.

Getting X and XFCE4

The X server with utils and xinit: pacman -S xorg-server xorg-server-utils xorg-xinit Press [Enter] to confirm all default values.

Xorg driver: pacman -S xf86-video-fbturbo-git

Your desktop environment: pacman -S xfce4

You need to make X start automatic at startup. That means installing and invoking a display manager.
We'll use SLiM that's a small nice login manager. SLiM is highly configurable. I urge you to read about it here: Arch's page about SLiM

pacman -S slim
systemctl enable slim

Now is the time to make your own user just change «username» with your own username in the following:

useradd username
passwd username

mkdir /home/username
chown username.username /home/username
chmod 700 /home/username
echo exec startxfce4 >> /home/username/.xinitrc
chown username.username /home/username/.xinitrc

Then let's boot and see the new system at work. Login as your newly made user.

reboot

If you get a graphical login page and after login in a desktop with a mouse on it, pat your self on the back. You're not done yet, but you have set up a basic system with a working windows installation!

 

Moving on, moving on...

So the next thing to do is fixing the keyboard layout. It's done the same way as we did on the live DVD way further up in this tutorial.
Go Applications -> Settings -> Keyboard, choose Layout click +Add and add your own and delete the one you do not need anymore.

Well, now I am writing this on my PI 3. In order to do that i needed a net browser and a screenshot-tool.

You'll need those things too, I suppose, so here we go!

Open a terminal and enter the command: su
After writing the root password you have a terminal in which you are root.
Now is a good time to change password on the root user, so: passwd

Firefox: pacman -S firefox
Screenshot app: pacman -S xfce4-screenshooter

To make this document I probably need GIMP too. So do you , sooner or later: pacman -S gimp

Enough about my needs! It's time to get rid of that network cable!

pacman -S wpa_supplicant
pacman -S wireless_tools
pacman -S networkmanager
pacman -S network-manager-applet
pacman -S gnome-keyring

And then, a little configuring:

Add yourself to the network group: gpasswd -a username network Change username to your username.

systemctl enable NetworkManager.service

systemctl disable dhcpcd.service
systemctl disable dhcpcd@.service
systemctl stop dhcpcd.service
systemctl stop dhcpcd@.service
systemctl enable wpa_supplicant.service
ip link set down eth0
ip link set down wlan0
systemctl start wpa_supplicant.service
systemctl start NetworkManager.service

Now, just log out and in again, and it should work!

A menu editor is a must: pacman -S alacarte

You'll find it under Applications -> Settings -> Main menu.

 

The last thing:

Then  there is one more thing, the graphical software manager: pacman -S gnome-software

Have a glorious time with your PI3 running Arch!