Sunday, December 23, 2012

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 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 be 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 in 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 usbstick or whatever you do to get something bootable out of it. Then boot it! ;-) As the installation is for both supported architectures (x86 or x86_64) 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!!):

  1. change keyboard layout to fit your language, i.e. German:
    # loadkeys de

  2. change language (again German as example):
    vi /etc/locale.gen
    remove comment for
    en_US.UTF-8 UTF-8
    de_DE.UTF-8 UTF-8

    then:
    # locale-gen
    # export LANG=de_DE.UTF-8

  3. network connection (at least if you have a wired connection to your DSL router) should already be established, check by:
    # ping -c 3 www.google.com
    if not, see here

  4. 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

  5. create a filesystem, in my case:
    # mkfs.ext4 -L "/" /dev/sda1
    # mkfs.ext4 -L "/home" /dev/sda3

  6. 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:
    # mkswap /dev/sda2
    # swapon /dev/sda2

  7. mount the stuff:
    # mount /dev/sda1 /mnt
    # mkdir /mnt/home
    # mount /dev/sda3 /mnt/home

  8. edit pacman's mirror list:
    # vi /etc/pacman.d/mirrorlist
    (I removed all non-German mirrors)

  9. install the base system by:
    # pacstrap -i /mnt base base-devel
    (takes a few minutes)

  10. generate fstab for your new system:
    # genfstab -p /mnt >> /mnt/etc/fstab
    and check it by
    # vi /mnt/etc/fstab
    => only "/" should have "1" as last column!

  11. chroot to the new system:
    # arch-chroot /mnt

  12. now change the language again (this time for the installed system):
    # vi /etc/locale.gen
    Remove comment for desired language (German here and I always keep English as well), i.e.:
    en_US.UTF-8 UTF-8
    de_DE.UTF-8 UTF-8

    and run
    # locale-gen
    # echo LANG=de_DE.UTF-8 > /etc/locale.conf
    # export LANG=de_DE.UTF-8
    # loadkeys de

  13. set keys for console:
    # vi /etc/vconsole.conf
    insert:
    KEYMAP=de
    FONT=
    FONT_MAP=

  14. set the timezone (example for Germany and hardware clock set to UTC):
    # ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    # hwclock --systohc --utc

  15. set hostname:
    # 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

  16. enable network (example for dynamic IP with wired connection):
    systemctl enable dhcpcd@eth0.service

  17. configure package manager - usually there's nothing to do, but if you're running x86_64 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:
    # pacman -Syy

  18. create initial ramdisk:
    # mkinitcpio -p linux

  19. set root password and create a user (with it's own primary group):
    # passwd
    # groupadd YOUR_USERNAME
    # useradd -g YOUR_USERNAME -s /bin/bash -m -c "YOUR_FULL_NAME" YOUR_USERNAME
    # passwd YOUR_USERNAME

  20. install bootloader (example for non-EFI firmware, non-GPT partition table and sda as boot device):
    # 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

  21. edit grub configuration: if you want to see boot messages remove "quiet" from GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, then run
    # grub-mkconfig -o /boot/grub/grub.cfg

  22. now exit from change root, umount partitions and reboot:
    # exit
    # unmount /mnt/home
    # umnount /mnt
    # reboot

  23. 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:

# 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:

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

Install Nvidia driver:

# pacman -S nvidia lib32-nvidia-utils

(lib32-nvidia-utils recommended for x86_64)

This will blacklist the nouveau driver automatically. Though not installed I'd recommend rebuilding the init ramdisk now:

# mkinitcpio -p linux

Run the Nvidia configuration untility:

# nvidia-xconfig

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

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):

# pacman -S xf86-input-evdev xf86-input-synaptics

(xf86-input-synaptics needed for touchpads only)

Change X keyboard layout, i.e. German:

# vi /etc/X11/xorg.conf.d/10-evdev.conf

Search for 'Identifier "evdev keyboard catchall"' and add:

Option "XkbLayout" "de"
Option "XkbVariant" "nodeadkeys"


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

# startx

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

Audio


Install alsa:

# pacman -S alsa-utils

Login as your user (not root!) and run

# alsamixer

unmute the main channel (press "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:

# pacman -S gnome gnome-extra

Enable GDM login manager:

# systemctl enable gdm.service

You might also want to consider installing networkmanager:

# 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:

# 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

GRUB_GFXPAYLOAD_LINUX=1280x800x32

to /etc/default/grub

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

# 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 page or just search via pacman:

# 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 the wiki!!!

No comments:

Post a Comment