Post

Arch Linux

Though I was tempted to switch to Ubuntu’s latest release on my “main” computer I decided to give Arch Linux the promotion. Not that there’s anything wrong with “Quantal” aka “Ubuntu 12.10” - with the exception of the newly introduced shopping lens - but I wanted something different again. I ran Arch Linux some time ago and liked it a lot. It then came to my attention that it was missing one (at least for me) essential feature: package signing. There has been quite some discussion about this matter and I think it was this August when package signing became default for Arch’s package manager. Of course you can argue about the importance but I like to know that packages are as the package maintainer wanted them to be and that nobody messed with them while stored on all the different mirrors. However, I wanted to give it shot.

Arch Linux is kind of unique among linux distros:

  1. It’s not based on or forked from any other distro (though there are distros based on or forked from Arch Linux, i.e.: ArchBang, Cinnarch or Chakra).
  2. It has a rolling release cycle, so it’s install once and then upgrade the system through time.
  3. It has its own unique package manager called pacman.
  4. No fancy installer, all very, very simple and basic - not in a bad way! (If you want something to run - make it run)
  5. It is what I think the best documented linux distro (of course this is mandatory in order to get things running ;-) ) and I refer to its wiki even if I have problems with other distros.

From the above you may already guess Arch Linux is not meant for beginners. In order to install and/or use it you should feel comfortable using the command line and an editor like nano or vi. Secondly, you should be able to read Arch’s excellent wiki! While installing Arch Linux you should have a second PC/notebook/smartphone/tablet at hand to read the installation guide - or print it out first… (and I don’t mean that as a joke) You’ll be rewarded with a very fast and clean operating system with up-to-date software.

Installation

To get things running grab the latest installation media from here and burn the image to CD or copy to usb-stick or whatever you do to get something bootable out of it. Then boot it! ;-) As the installation is for both supported architectures (x86 or x8664) you may choose your desired one right away and once done you’ll face yourself in a command shell logged in as _root. Now pay close attention to Arch’s “Beginners’ Guide”, especially the “Installation” part. (I use my Android tablet for that - until I have X and a browser running in Arch ;-) ). Arch used to have some ncurses based installer but as it wasn’t maintained anymore it was removed and now you’ll have to do each step manually. I’ll sum up the for me important steps here (it’s all from Arch’s Wiki - if you do a fresh install you should go by instructions given there, as your mileage will vary):

  • change keyboard layout to fit your language, i.e. German:
    1
    
    $ loadkeys de
    
  • change language (again German as example):
    1
    
    $ vi /etc/locale.gen
    

    …and remove comment for

    1
    2
    
    en_US.UTF-8 UTF-8
    de_DE.UTF-8 UTF-8
    

    and:

    1
    2
    
    $ locale-gen
    $ export LANG=de_DE.UTF-8
    
  • network connection (at least if you have a wired connection to your DSL router) should already be established, check by:
    1
    
    $ ping -c 3 www.google.com
    

    if not, see here

  • partition your disk: mine already has partitions which I’d like to use, so I’ll skip this step - if you need it, see here

  • create a filesystem, in my case:
    1
    2
    
    $ mkfs.ext4 -L "/" /dev/sda1
    $ mkfs.ext4 -L "/home" /dev/sda3
    
  • Usually also the swap device is configured here, but they seem to have omitted this part and moved it here. Nevertheless, I create a swap space at this point as I have a dedicated partition for that:
    1
    2
    
    $ mkswap /dev/sda2
    $ swapon /dev/sda2
    
  • mount the stuff:
    1
    2
    3
    
    $ mount /dev/sda1 /mnt
    $ mkdir /mnt/home
    $ mount /dev/sda3 /mnt/home
    
  • edit pacman’s mirror list (I removed all non-German mirrors):
    1
    
    $ vi /etc/pacman.d/mirrorlist
    
  • install the base system by (will take a few minutes):
    1
    2
    
    $ pacstrap -i /mnt base base-devel
    (takes a few minutes)
    
  • generate fstab for your new system:
    1
    
    $ genfstab -p /mnt >> /mnt/etc/fstab
    

    and check it by

    1
    
    $ vi /mnt/etc/fstab
    

    => only “/” should have “1” as last column!

  • chroot to the new system:
    1
    
    $ arch-chroot /mnt
    
  • now change the language again (this time for the installed system):
    1
    
    $ vi /etc/locale.gen
    

    Remove comment for desired language (German here and I always keep English as well), i.e.:

    1
    2
    
    en_US.UTF-8 UTF-8
    de_DE.UTF-8 UTF-8
    

    and run

    1
    2
    3
    4
    
    $ locale-gen
    $ echo LANG=de_DE.UTF-8 > /etc/locale.conf
    $ export LANG=de_DE.UTF-8
    $ loadkeys de
    
  • set keys for console:
    1
    
    $ vi /etc/vconsole.conf
    

    insert:

    1
    2
    3
    
    KEYMAP=de
    FONT=
    FONT_MAP=
    
  • set the timezone (example for Germany and hardware clock set to UTC):
    1
    2
    
    $ ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    $ hwclock --systohc --utc
    
  • set hostname:
    1
    
    $ echo YOUR_HOSTNAME > /etc/hostname
    

    editing /etc/hosts does not seem to be required anymore, but I still have my hostname in the two _localhost _lines as well

  • enable network (example for dynamic IP with wired connection):
    1
    
    $ systemctl enable dhcpcd@eth0.service
    
  • configure package manager - usually there’s nothing to do, but if you’re running x8664 you might want to consider enabling the _multilib repository by removing the comments in /etc/pacman.conf and then refreshing the local package databases by:
    1
    
    $ pacman -Syy
    
  • create initial ramdisk:
    1
    
    $ mkinitcpio -p linux
    
  • set root password and create a user (with it’s own primary group):
    1
    2
    3
    4
    
    $ passwd
    $ groupadd YOUR_USERNAME
    $ useradd -g YOUR_USERNAME -s /bin/bash -m -c "YOUR_FULL_NAME" YOUR_USERNAME
    $ passwd YOUR_USERNAME`
    
  • install bootloader (example for non-EFI firmware, non-GPT partition table and sda as boot device):
    1
    2
    3
    4
    
    $ pacman -S grub-bios
    $ grub-install --target=i386-pc --recheck /dev/sda
    $ cd /usr/share/locale/en@quot/LC_MESSAGES && cp grub.mo /boot/grub/locale/en.mo
    $ cd
    
  • edit grub configuration: if you want to see boot messages remove “quiet” from GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, then run
    1
    
    $ grub-mkconfig -o /boot/grub/grub.cfg
    
  • now exit from change root, umount partitions and reboot:
    1
    2
    3
    4
    
    $ exit
    $ unmount /mnt/home
    $ umnount /mnt
    $ reboot
    
  • welcome to your new Arch Linux installation!

You now have a very basic installation which needs some additions to do it’s everyday job.

Customization

Firewall

Though connected by router I like to run a basic firewall configuration. To make this easy install ufw:

1
2
3
4
$ pacman -S ufw
$ ufw default deny
$ ufw enable
$ systemctl enable ufw.service

X server

First thing I do is getting X to work. For that I’d like to use Nvidia’s binary driver. Install X:

1
$ pacman -S xorg-server xorg-xinit xorg-server-utils mesa xorg-twm xorg-xclock xterm ttf-dejavu

Install Nvidia driver:

1
$ pacman -S nvidia lib32-nvidia-utils

(lib32-nvidia-utils recommended for x86_64)

This will blacklist the nouveau driver automatically. I’d recommend rebuilding the init ramdisk now:

1
$ mkinitcpio -p linux

Run the Nvidia configuration untility:

1
$ nvidia-xconfig

This will create /etc/X11/xorg.conf. Now edit this file and remove everything with the exception of

1
2
3
4
5
6
Section "Device"
Identifier     "Device0"
Driver         "nvidia"
VendorName     "NVIDIA Corporation"
Option         "NoLogo" "true"
EndSection

(The “NoLogo” part is optional). Then reboot.

Install input drivers (if not already installed):

1
$ pacman -S xf86-input-evdev xf86-input-synaptics

(xf86-input-synaptics needed for touchpads only)

Change X keyboard layout, i.e. German:

1
$ vi /etc/X11/xorg.conf.d/10-evdev.conf

Search for ‘Identifier "evdev keyboard catchall"’ and add:

1
2
Option "XkbLayout" "de"
Option "XkbVariant" "nodeadkeys"

Test X: login in as your regular user (not root!) and run

1
$ startx

This should bring up xterm. Exit from all terminals and you’ll be back to command line. X is working!

Audio

Install alsa:

1
$ pacman -S alsa-utils

Login as your user (not root!) and run

1
$ alsamixer

unmute the main channel (by hitting “m”). It should work then without any further doing.

Choose a desktop environment

I decided to go for Gnome, but of course there is KDE, Xfce or LXDE as well. So, if you’d like to install Gnome as well:

1
$ pacman -S gnome gnome-extra

Enable GDM login manager:

1
$ systemctl enable gdm.service

You might also want to consider installing networkmanager:

1
2
$ pacman -S --needed networkmanager network-manager-applet
$ systemctl disable dhcpcd@eth0.service && systemctl enable NetworkManager

For details and/or desktop customization please refer to Arch Wiki. Also, it’s a good idea to install/enable acpid:

1
$ pacman -S --needed acpid && systemctl enable acpid.service

Now reboot.

Grub

Now as we installed the Nvidia driver the boot process will show an ugly big font. To make it look nicer add

1
GRUB_GFXPAYLOAD_LINUX=1280x800x32

to /etc/default/grub (you have to be sure that the resolution is supported by your video adapter - check by vbeinfo, s. here), then run

1
$ grub-mkconfig -o /boot/grub/grub.cfg

Now it’s time to reboot and this time you may login to your newly installed desktop environment!

Packages

If you’re missing software it’s likely you’ll find it in Arch’s repositories. Check it out on their web site or just search via pacman:

1
$ pacman -Ss <PACKAGE>

If you do not find it there, you might want to to take a look at “AUR” (Arch User Repository) here. There you can find a lot of additional software, but be aware that this is contributed by users and packages are not maintained by Arch developers. And this is one of the nicest things about Arch: it’s package building mechanism is quite simple and straight forward! All you basically need is a PKGBUILD file. The information within this file is used to download the source code, check it’s md5 sum, compile it and finally build the software package to make it installable via pacman. In order to build a package from AUR this is what you want to do:

  • search for the package in AUR
  • download the tar ball (hyperlink to your right)
  • create your package directory (i.e. ~/mypackages)
  • unpack the tar ball within this directory
  • check the content (and I mean open the files in a text editor and see what they are actually doing!)
  • install the dependencies (“depends=(…)” part in PKGBUILD file, you won’t need any “dev” packages as it seems that Arch packages already contain their header files)
  • open a terminal, change to the directory of the unpacked tarball (where the PKGFILE is) and run (NOT as root): # makepkg
  • once the package is ready install it (of course as root): # pacman -U /path/to/package.xz

From the above you see it’s advisable that you’re aware of what you’re doing and that you understand what the PKGBUILD files (and probably other install files) will do in order not to harm your system. But after all it’s no rocket science! There also seems to be a front end for AUR called yaourt, but i never checked it out.You can find some information on building Arch packages here. You will also find some information on Arch’s ABS (Arch Build System), which is kind of similar to FreeBSD’s ports system. You can easily re-compile Arch packages with options which suit you more.

If you want to learn more about pacman: check the wiki!

Conclusion

All together Arch is not meant for absolute Linux beginners, it’s for those who either already have some Linux/Unix knowledge and for those willing to read the wiki and learn. Installation takes a little longer than common “live installers” and of course you need some more tweaking but once this is done you’ll keep it up-to-date for a “life time” - without re-installing. You should take a look at their news page from time to time to see if there are any troubles updating (keep in mind this is a rolling release distro!). I personally never had any big issues with Arch (so far! ;-) ) and it runs very stable. Just read their wiki!

This post is licensed under CC BY-SA 4.0 by the author.