Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

Build an Arch Linux system from scratch

Arch Linux has two distinct advantages over most systems: it’s customisable and it’s educational. Michael Reed shows us how building Arch is also a lesson in how Linux works...

Arch Linux from Scratch

The installation procedure for Arch Linux means that it is not suitable for Linux newcomers or users who have a phobia about using the command line. However, if you’ve ever wondered what is really going on while Linux boots, this is definitely the project for you.

Although installing Arch Linux can be an educational experience, please don’t dismiss the distro as merely an educational tool or a novelty. It’s a fully featured distro and perfectly easy to maintain, once it is up and running. It comes with its own package management system, called pacman, which is roughly equivalent to Apt or YUM.

The /etc/rc.conf file is the centrepiece of Arch Linux configuration and a model of simplicity. In particular, configuration of the network and startup daemons resides in this file. That said, Arch makes use of other, standard Linux files where appropriate for compatibility.

In this example, we’re going to introduce Arch by installing a typical desktop system within a VirtualBox VM, but it will give you the experience and skills set to build any type of Linux system.

Step by Step

Arch Linux from Scratch
Begin with the basic ISO

Step 01 Obtain the boot disk

Grab the either the 32-bit or 64-bit ISO image. Arch uses rolling releases for updates and the current disk is a recent snapshot. Upon booting, select ‘Boot Arch Linux’. This places you at a Linux command line and ready for installation or system maintenance.

Step 02 Set up the keymap

By default, Arch uses a US keymap. To select the UK one, use the command ‘loadkeys uk’. Note that ‘loadkeys’ only affects the keymap for virtual consoles. We’ll be changing the settings for the GUI later on.

Step 03 Configure the network

The Arch boot disk now sets up the network automatically using DHCP. Test it by typing:


For more complicated setups, see the Arch Wiki article on Wireless Setup or Netcfg.

Step 04 Partition your disk

Cfdisk is a text mode partitioning tool. You can boot into a different system and use a GUI tool such as GParted if preferred. Create a root partition, a home partition (at least a few GB each, and both of type ‘Linux’) and a swap partition.

Step 05 Format your partitions

All of the usual Linux file systems are supported, but for these examples we’ll stick with ext4. Do ‘fdisk [drive] -l’ to list the partitions, and ‘mkfs.ext4 [/dev/name of partition]’ for the root and home partitions. Activate the swap ‘mkswap [swap partition]’, and then ‘swapon [swap partition]’.

Step 06 Mount your partitions

Mount the root partition by using mount [/dev/name of partition] /mnt. Createamountpointusingmkdir /mnt/home andthenmountitwithmount [/dev/name of home partition] /mnt/home.

Step 07 Choose a text editor

Although vi is available, these examples make use of nano. Invoke nano with ‘nano [file]’. If the file does not exist (as will be the case with many of the examples), it will be created. Hit Ctrl+O to save an edited file and Ctrl+X to exit nano – it really is that easy!

Step 08 Select a local mirror

The default package mirror may be throttled, so give preference to a local one. Open the list of mirrors with:

nano /etc/pacman.d/mirrorlist

Use Ctrl+K to cut the line and Ctrl+U to paste it at the top of the list.

Step 09 Install the base system

For a basic installation, type:

pacstrap /mnt base base-devel

In our test, this brought through 150MB of data and consumed 550MB of disk space. On subsequent installations, you might want to add more software at this stage.

Arch Linux from Scratch
Create the user accounts

Step 10 Generate fstab and Install bootloader

Generate fstab with:

genfstab -p /mnt >> /mnt/etc/fstab

Check that this looks sane using nano. You can install GRUB, but we’ll use SYSLINUX instead as it’s simple to work with. Type:

pacstrap /mnt syslinux

11 Configure bootloader (SYSLINUX)

To open the config file, type:

nano /mnt/boot/syslinux/syslinux.cfg

Find the ‘LABEL arch’ section and change the partition referenced on the ‘APPEND’ line to the correct one for your root partition.

Now type :

/usr/sbin/syslinux-install_update -iam

Step 12 Chroot

Chroot into the system by typing:

arch-chroot /mnt

This means that you can edit files as if you booted from the system. In addition, you can now use pacman rather than pacstrap for package management. Type ‘exit’ if you need to exit back to the boot environment.

Step 13 Edit hostname

Use nano to create etc/hostname. Add a single word to act as the hostname for this computer. Now edit /etc/hosts. There should be two uncommented lines. Alter the last element of each to reflect your hostname.

Step 14 Configure networking

Open /etc/rc.conf and uncomment all of the parameters in the networking section. On a wired network with DHCP, simply change the first entry of that section to ‘interface=eth0’ and leave the other parameters blank.

Step 15 Localisation settings (UK)


ln -s /usr/share/zoneinfo/Europe/ London /etc/localtime

You can browse the directory to find other time zones. UTC time is preferred. Type:

hwclock –systohc –utc

to enable it. If you have a Windows partition that uses Local Time, use ‘hwclock –systohc –localtime’ to avoid a mismatch between systems. Open up /etc/locale.gen and then uncomment the line for your geographical location (‘en_GB.UTF-8 UTF-8’ for the UK). Use nano to create /etc/locale.conf and add the line ‘LANG=en_GB.UTF-8’, save the file and exit. Run ‘locale-gen’.

Step 16 Virtual console fonts

Using nano:

nano /etc/vconsole.conf

Add ‘KEYMAP=uk‘ ‘FONT=’ ‘FONT_MAP=’ on separate lines. Note that this controls the keymap selection for text consoles and has no effect on either terminal applications that run within the GUI or the GUI itself.

Step 17 Create accounts

Type ‘passwd’ and enter a password for the root user. Type ‘adduser’ to create a normal user account. This is an interactive tool, and the Arch docs recommend adding a desktop user to the ‘audio,games,lp,optical,power,scanner, storage,video’ groups.

Arch Linux from Scratch
You should now be able to boot into your system

Step 18 Reboot

Type ‘exit’ and then ‘reboot’. If everything has worked, you should now have rebooted and can now log in as root. If things don’t work as planned, boot off the Arch ISO again and go over each step.

Step 19 Update the system

Perform a full system update by typing ‘pacman -Syu’. Remember that Arch is a rolling distro. If an upgrade causes a problem, use pacman to install ‘downgrader’, a tool to revert a package to an earlier version. Note that this is in Arch User Repository.

Step 20 Explore the AUR (Arch User Repository)

The Arch User Repository – also known as AUR – makes use of packages, downloadable from the web, which contain the source code along with build instructions. Search the Arch wiki for ‘AUR helpers’ for tools to integrate the AUR into Arch itself.

Step 21 Install a graphical environment


pacman -S xfce4 xorg ttf-dejavu

In this example, we’ve installed Xfce 4, but ‘xfce4’ could have been substituted with ‘gnome’ instead, for example. You can launch Xfce 4 by typing ‘startxfce4’.

Step 22 Install a login manager

We’ll install LXDM as our login manager by typing:

pacman -S lxdm

Now open rc.conf and add ‘lxdm’ as the last element on the DAEMONS line. Log in as your regular user and type:

cp /etc/skel/.xinitrc ~

Now type:

nano ~/.xinitrc

and add the line ‘exec startxfce4’.

Step 23 Add VirtualBox modules

To enable features such as a common cut and paste buffer between hosts and guests, first attempt to load the modules manually by typing:

modprobe -a vboxguest vboxsf vboxvideo

If this works, add the three modules to /etc/modules-load.d/vbox.conf.

Step 24 Complete the system


pacman -S acpi

to install ACPI support for hardware reset/ shutdown, which is also important if you are using Arch within a VM. Add PulseAudio and ALSA to the system with the following to finish your install: pacman -S pulseaudio pulseaudio -alsa

Arch Linux from Scratch
Finally, enable sound