Arch Linux Installation Guide

This Arch Linux installation guide is customized for my hardware and my needs. Anyone may use these instructions to setup a system of their own, but they are not guaranteed to work on all hardware nor they are the “official” way of doing things.

Disclaimer: software components, specially the ones that I block out are my personal choice, and anyone else referencing this article should substitute their own choices.

For a generic installations instructions see the official Arch Linux Installation Guide.

Installation done using archlinux-2013.07.01-dual.iso


Preparing Partitions

Create the following partitions on disk(s) using fdisk.

Single disk setup

Partition Type Size Device Node
(assumed)
/ primary, ext4, +boot 10GB /dev/sda1
swap logical, swap 2GB /dev/sda5
/home logical, ext4 remainder /dev/sda6

Dual disk setup

Partition Type Size Device Node
(assumed)
/ primary, ext4, +boot 10GB /dev/sda1
/home logical, ext4 remainder /dev/sda5
swap logical, swap 2GB /dev/sdb5
/var/disk2 logical, ext4 remainder /dev/sdb6


Format each partition

# mkswap /dev/sda5
--- output not shown here ---
# mkfs.ext4 /dev/sda1
--- output not shown here ---
Note: make sure you format all ext4 partitions.


Prepare for base installation

Mount file system

Mount new partition to a temporary location (/mnt) and create root directory structure.

# swapon /dev/sda5
# mount /dev/sda1 /mnt
# mkdir -pv /mnt/{boot,dev,etc/wpa_supplicant,home,proc,root,run,sys,tmp,var/{cache/pacman/pkg,disk2,lib/pacman}}
mkdir: created directory '/mnt/boot'
mkdir: created directory '/mnt/dev'
mkdir: created directory '/mnt/etc'
mkdir: created directory '/mnt/etc/wpa_supplicant'
mkdir: created directory '/mnt/home'
mkdir: created directory '/mnt/proc'
mkdir: created directory '/mnt/root'
mkdir: created directory '/mnt/run'
mkdir: created directory '/mnt/sys'
mkdir: created directory '/mnt/tmp'
mkdir: created directory '/mnt/var'
mkdir: created directory '/mnt/var/cache'
mkdir: created directory '/mnt/var/cache/pacman'
mkdir: created directory '/mnt/var/cache/pacman/pkg'
mkdir: created directory '/mnt/var/disk2'
mkdir: created directory '/mnt/var/lib'
mkdir: created directory '/mnt/var/lib/pacman'

Connect installation environment to WIFI/Internet

Enable WIFI connection using WPA2. When using a wired connection this steps in this section may be skipped partly or completely.

# wpa_passphrase ESSID uber_secret_key|sed '/#psk=/d' > /mnt/etc/wpa_supplicant/wifi.conf
# wpa_supplicant -B -D wext -i wlp1s0 -c /mnt/etc/wpa_supplicant/wifi.conf
# dhcpcd wlp1s0

Modify pacman configuration

Block Mono platform from being installed in the system, thus block any software components depends on them. Then include the archlinux.fr repository to enable the yaourt installation.

# sed "s/#\(IgnorePkg\s*=\)/\1 mono mono-tools jre7-openjdk-headless/" \
> /etc/pacman.conf > /mnt/etc/pacman.conf
# cat >> /mnt/etc/pacman.conf << EOF
>
> [archlinuxfr]
> Server = http://repo.archlinux.fr/\$arch
> SigLevel = Optional
> EOF

Mount cache server into /var/cache/pacman/pkg of the installation environment.

# mkdir -p /var/lib/pacman/sync
# mount -o nolock server_name:/path/to/sync /var/lib/pacman/sync
# mount -o nolock server_name:/path/to/cache /var/cache/pacman/pkg

For the installation you can use mirror closest to you and later do a full system upgrade using an up-to-date repository. Select the closest mirror and move it to the top of /etc/pacman.d/mirrorlist

Install base system

Note: Only ignore linux package when prepared to build a custom kernel.

# pacman -Sy -r /mnt --config /mnt/etc/pacman.conf \
> --ignore jfsutils,reiserfsprogs,xfsprogs,vi,nano,lvm2,netctl,linux,linux-firmware,heirloom-mailx,mdadm,pcmciautils\
> base base-devel syslinux wireless_tools wpa_supplicant gvim sudo yaourt rsync wget git nfs-utils ntp bc

Installation will replace our pacman.conf and we need to restore it

# mv -v /mnt/etc/pacman.conf{,.pacnew}
'/mnt/etc/pacman.conf' -> '/mnt/etc/pacman.conf.pacnew'
# mv -v /mnt/etc/pacman.conf{.pacorig,}
'/mnt/etc/pacman.conf.pacorig' -> '/mnt/etc/pacman.conf'

Pre-boot configuration

Chroot into the new system

Mount dev, proc and sys to be used in chroot, also bind the /tmp into chroot directory.

# mount -t devtmpfs udev /mnt/dev
# mount -t proc proc /mnt/proc
# mount -t sysfs sys /mnt/sys
# mount --bind /tmp /mnt/tmp
# chroot /mnt /bin/bash

/etc/fstab

For a single disk system.

# cat >> /etc/fstab << EOF
> 
> /dev/sda1 / ext4 defaults,noatime,nodiratime,discard,errors=remount-ro 0 1
> /dev/sda6 /home ext4 defaults,noatime,nodiratime,discard,errors=remount-ro 0 1
> /dev/sda5 swap swap sw,noatime,nodiratime 0 0
> EOF

For a dual disk system.

# cat >> /etc/fstab << EOF
> 
> /dev/sda1 / ext4 defaults,noatime,nodiratime,discard,errors=remount-ro 0 1
> /dev/sda5 /home ext4 defaults,noatime,nodiratime,discard,errors=remount-ro 0 1
> 
> /dev/sdb5 swap swap sw,noatime,nodiratime 0 0
> /dev/sdb6 /var/disk2 ext4 noauto,x-systemd.automount,defaults,noatime,nodiratime,errors=remount-ro 0 2
> EOF

Also make the pacman cache server directory mount on boot.

# cat >> /etc/fstab << EOF
> 
> server_name:/path/to/cache /var/cache/pacman/pkg nfs noauto,x-systemd.automount,noexec,nolock,noatime,nodiratime,rsize=32768,wsize=32768,timeo=14,intr 0 0
> EOF

/etc/hostname and /etc/hosts

Machine name used here must also be entered into /etc/hosts as an alias to the localhost.

# echo 'machine-name' > /etc/hostname
# sed 's/\(localhost\)$/\1 machine-name/g' -i /etc/hosts

Time zone and clock settings

Setting time zone to Asia/Colombo.

# echo 'Asia/Colombo' > /etc/timezone
# ln -s /usr/share/zoneinfo/Asia/Colombo /etc/localtime
# hwclock --hctosys --utc
# date
Sun Aug 26 02:06:34 IST 2012

Set NTP service/daemon to start on boot, and point to the local NTP server.

# ln -sv /usr/lib/systemd/system/ntpd.service /etc/systemd/system/multi-user.target.wants/
'/etc/systemd/system/multi-user.target.wants/ntpd.service' -> '/usr/lib/systemd/system/ntpd.service'
# sed 's/\(server\s\+.\+\)/#\1/' -i /etc/ntp.conf
# echo 'server server_name' > /etc/ntp.conf

Optionally, if the system time need to be changed:

# date MMDDhhmmYYYY
# hwclock --systohc --utc
# date
DDD MMM DD hh:mm:?? IST YYYY

Generate locale

# cat >> /etc/locale.gen << EOF
> en_US.UTF-8 UTF-8
> en_US ISO-8859-1
> si_LK.UTF-8 UTF-8
> EOF
# locale-gen
Generating locales...
  en_US.UTF-8 UTF-8... done
  en_US ISO-8859-1... done
  si_LK.UTF-8 UTF-8... done
Generation complete.

Install bootloader (syslinux)

# rm -fr /boot/syslinux
# cat > /boot/syslinux.cfg << EOF
> DEFAULT linux
> PROMPT 0
> TIMEOUT 60
> 
> LABEL linux
>   MENU LABEL Arch Linux (Custom Kernel Configuration)
>   LINUX kernel
>   APPEND root=/dev/sda1 ro quiet
> EOF
# extlinux -i /boot
/boot/syslinux is device /dev/sda1
# dd if=/usr/lib/syslinux/mbr.bin of=/dev/sda bs=440 count=1
1+0 records in
1+0 records out
440 bytes (440 B) copied, 0.00345276 s, 127 kB/s

Kernel

If you have the pre-compiled kernel binaries, copy them in to respective locations, otherwise compile and install the kernel.

Systemd adjustements

Stop console clearing at login prompt

# sed 's/\(TTYVTDisallocate=\)yes/\1no/' /usr/lib/systemd/system/getty\@.service \
> > /etc/systemd/system/getty\@.service
# rm /etc/systemd/system/getty.target.wants/getty\@tty1.service
# ln -sv ../getty\@.service /etc/systemd/system/getty.target.wants/getty\@tty1.service
'/etc/systemd/system/getty.target.wants/getty@tty1.service' -> '../getty@.service'

Limit number of TTYs

# sed 's/#\(NAutoVTs=\).\+/\12/' -i /etc/systemd/logind.conf

Limit journal disk usage

# sed 's/#\(SystemMaxUse=\).*/\116M/' -i /etc/systemd/journald.conf

Make wireless connection on boot

Type of the dhcpcd@.service is changed to idle in order to avoid login prompt pollution.

# sed 's/\(Type=\).\+/\1idle/' /usr/lib/systemd/system/dhcpcd\@.service |\
> sed 's/\(Before=.\+\)/\1 var-cache-pacman-pkg.mount/' |\
> sed '/Before=/i After=wpa_supplicant@wlp1s0.service'
> > /etc/systemd/system/dhcpcd\@.service
# ln -sv ../dhcpcd\@.service /etc/systemd/system/multi-user.target.wants/dhcpcd\@wlp1s0.service
'/etc/systemd/system/multi-user.target.wants/dhcpcd@wlp1s0.service' -> '../dhcpcd@.service'
# mkdir -pv /etc/systemd/system/dhcpcd\@wlp1s0.service.wants
mkdir: created directory '/etc/systemd/system/dhcpcd@wlp1s0.service.wants'
# ln -sv /usr/lib/systemd/system/wpa_supplicant\@.service \
> /etc/systemd/system/dhcpcd\@wlp1s0.service.wants/wpa_supplicant\@wlp1s0.service
'/etc/systemd/system/dhcpcd@wlp1s0.service.wants/wpa_supplicant@wlp1s0.service' -> '/usr/lib/systemd/system/wpa_supplicant@.service'
# ln -sv wifi.conf /etc/wpa_supplicant/wpa_supplicant-wlp1s0.conf
'/etc/wpa_supplicant/wpa_supplicant-wlp1s0.conf' -> 'wifi.conf'

Unmount pacman cache before shutdown/reboot

Modify the

# mkdir -pv /etc/systemd/system/var-cache-pacman-pkg.mount.wants
mkdir: created directory '/etc/systemd/system/var-cache-pacman-pkg.mount.wants'
# ln -sv ../dhcpcd\@.service /etc/systemd/system/var-cache-pacman-pkg.mount.wants/dhcpcd\@wlp1s0.service
'/etc/systemd/system/var-cache-pacman-pkg.mount.wants/dhcpcd@wlp1s0.service' -> '../dhcpcd@.service'


Exit chroot, unmount and reboot

# exit
exit
# umount /mnt/{dev,proc,sys,tmp,var,}
# umount /var/cache/pacman/pkg
# reboot

First-boot configuration

pacman mirror list

Get latest mirror list and enable required mirrors

# wget http://www.archlinux.org/mirrorlist/?use_mirror_status=on -O /etc/pacman.d/mirrorlist

Initialize package keys

In order to generate entropy during the key initialization, switch to another console and run ls -Ra / >/dev/null or use haveged.

In order to install haveged you may need to temporarily set SigLevel to TrustAll for the [community] repository.

# pacman-key --init
--- output not shown here ---
# pacman-key --populate archlinux
--- output not shown here ---

Although it might nor be necessary for a net installation, do a system update.

# yaourt -Syyua
--- output not shown here ---

Create user(s)

# useradd -m -s /bin/bash -G audio,network,power,scanner,storage,systemd-journal,video,wheel -U new_username
# passwd new_username
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

You may need to add lp and optical groups to if you are planing to use those devices or applications.

Add this user to /etc/sudoers as we will be blocking root from login in the system.

# cat >> /etc/sudoers << EOF
> new_user ALL=(ALL) ALL
> EOF

Lockout root from login into console or from SSH in. Optionally remove the password hash for root from /etc/shadow

# rm /etc/securetty
# sed 's#\(root:x:0:0:root:/root:/bin/\).\+#\1false#' -i /etc/passwd
# sed 's/\(root:\)[^:]\+\(:.\+\)/\1x\2/' -i /etc/shadow

Disable webcam

# cat >> /etc/modprobe.d/modprobe.conf << EOF
> blacklist uvcvideo
> EOF

Driver installation and configuration

Sound: ALSA Support

ALSA support must be enabled in the Kernel. Following installs a set of utilities for configuration and integration need that applies to all hardware.

# pacman -S alsa-utils alsa-oss alsa-plugins
--- output not shown here ---

Do the necessary adjustments using alsamixer and test and save settings.

$ alsamixer
$ speaker-test -c 2
--- output not shown here ---
# alsactl store

Optionally, make the necessary changes to the configuration files to load ALSA daemon on boot.

Touch Pad: FSPPS/2 Seltelic

SINX-450

# pacman -S xf86-input-synaptics
--- output not shown here ---

Video: ATI Graphics Card

IBM R52

# pacman -S xf86-video-ati
--- output not shown here ---

Video: GMA500 (Intel)

SINX-450

# pacman -S xf86-video-fbdev
--- output not shown here ---

Add gma500_gfx module to modules array on /etc/mkinitcpio.conf and build initramfs

# mkinitcpio -p linux
--- output not shown here ---

Video: Intel Graphics Card

Acer V5-571PG, Acer 4738, HP/Compaq 6720s

# pacman -S xf86-video-intel
--- output not shown here ---

Note: for Acer V5-571PG see also settings up NVIDIA Optimus

Optionally, add i915 module to modules array on /etc/mkinitcpio.conf and build initramfs

# mkinitcpio -p linux
--- output not shown here ---

Video: NVIDIA Graphics Card

Lenovo 3000 N100

# pacman -S xf86-video-nouveau nouveau-dri
--- output not shown here ---
# cat > /etc/X11/xorg.conf.d/20-nouveau.conf << EOF
> Section "Device"
>   Identifier "Nvidia card"
>   Driver "nouveau"
> EndSection
> EOF

Acer V5-751PG (Optimus)

# yaourt -S xf86-video-intel intel-dri bumblebee nvidia-dkms
--- output not shown here ---
# systemctl enable bumblebeed

WIFI: Broadcom BCM4311

IBM R52

$ yaourt -S b43-firmware rfkill
--- output not shown here ---
# systemctl enable rfkill-unblock\@wifi
might have to add 'RFKILL_UNBLOCK=“wifi”' to /etc/conf.d/rfkill


WIFI: Broadcom BCM43228

SINX-450

$ yaourt -S broadcom-wl-dkms
--- output not shown here ---

WIFI: Realtek RTL8191SEvB

SINX-450 Acer V5-571PG

# systemctl enable rfkill-unblock\@wifi

Xorg

# pacman -S xorg-server xorg-utils xorg-server-utils xorg-xinit mesa mesa-demos
--- output not shown here ---

Configure X to start on user login.

# cp -v /etc/skel/.xinitrc ~
'/etc/skel/.xinitrc' -> '/home/username/.xinitrc'
# cat >> ~/.bash_profile << EOF
> 
> if [[ -z \$DISPLAY ]] && [[ /dev/tty1 = \$(tty) ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
>   exec startx
> fi
> EOF

Fonts

$ yaourt -S ttf-dejavu ttf-droid ttf-lklug
--- output not shown here ---

Following fonts may also be needed for a better UI experience.

  • ttf-bitstream-vera
  • ttf-cheapskate
  • ttf-freefont
  • ttf-inconsolata
  • ttf-indic-otf
  • ttf-junicode
  • ttf-liberation
  • ttf-linux-libertine


XFCE

Install every member of the xfce4 and xfce4-goodies package groups.

$ yaourt -S --ignore mousepad xfce4 xfce4-goodies xfce4-places-plugin gvfs
--- output not shown here ---

To start XFCE with the Xorg start up, modify the ~/.xinitrc as follows.

# cat >> ~/.xinitrc << EOF
> 
> xbacklight -set 0	# 0 may turn off some monitor in some systems
> xset -dpms		# Disable energy star features ?
> xset s off		# Screen server off
> 
> exec startxfce4
> EOF


Theme & Icons: Numix Holo + elementary

Clone Numix Holo themes and elementary-xfce icon themes from github. Also install dependencies gtk-engines-murrine and gtk-engines-unico

$ pacman -S gtk-engine-{unico,murrine}
--- output not shown here ---
$ mkdir -pv ~/src
mkdir: created directory '/home/suda/src'
$ cd ~/src
$ git clone https://github.com/duskp/numix-holo.git
$ git clone https://github.com/shimmerproject/elementary-xfce.git
# ln -s /home/suda/src/numix-holo /usr/share/themes
# ln -s /home/suda/src/elementary-xfce/elementary-xfce /usr/share/icons
# ln -s /home/suda/src/elementary-xfce/elementary-xfce-dark /usr/share/icons


iBus

$ yaourt -S ibus
--- output not shown here ---
# cat >> ~/.bashrc << EOF
> 
> export GTK_IM_MODULE=ibus
> export XMODIFIERS=@im=ibus
> export QT_IM_MODULE=ibus
> export XIM_PROGRAM=/usr/bin/ibus-daemon
> EOF

Install ibus-sayura (Sinhala input scheme) from GIT.


Other Software

Software Application Repository Package AUR Package Other Package
Chat & social media pidgin-libnotify hottot 1)
Cloud & file sharing tools transmission-gtk dropbox, thunar-dropbox
Encryption tools truecrypt, keepassx
Email client thunderbird
Graphic tools gimp
Multimedia vlc gpodder 2)
Network tools dnsutils
Office & productivity tools libreoffice, gnucash, gnome-calculator, evince, aspell-en 3), hunspell-en, ispell
Remote access openssh, filezilla
Software development tools geany-plugins, meld, ghex
Shell & file handling tree, dosfstools, ntfs-3g, file-roller, unrar, zip, unzip, p7zip, arj, guake screen 4)
Virtualization virtualbox
Web browsers firefox, chromium
Web development tools php-apache, mariadb-clients


Sample scripts

~/.bash_profile

.bash_profile
  1. #
  2. # ~/.bash_profile
  3. #
  4.  
  5. [[ -f ~/.bashrc ]] && . ~/.bashrc
  6.  
  7. if [[ -z $DISPLAY ]] && [[ /dev/tty1 = $(tty) ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
  8. 	while true; do
  9. 		read -p 'Start X? (Y/n): '
  10.  
  11. 		if [ -z "$REPLY" ]; then
  12. 			REPLY="Y"
  13. 		fi
  14.  
  15. 		case $REPLY in
  16. 			[Yy]) printf '\n'; exec startx ;;
  17. 			[Nn]) break ;;
  18. 			*) printf '%s\n' 'Please answer y or n.' ;;
  19. 		esac
  20. 	done
  21. fi

~/bin/startup.sh

To be used as a start up script for XFCE.

startup.sh
  1. #!/bin/bash
  2.  
  3. (hotot &) &&
  4. (sleep 3 && pidgin &) &&
  5. (sleep 5 && guake)


1) , 2) , 4) GIT
3) Create ~/.vim/spell/en.utf-8.add symbolic link to ~/.aspell.en.pws so Vim share the aspell dictionary