Installing Arch Linux is not the easy way to get Linux up and running and neither should it be. The idea behind Arch is that your learn Linux. Nothing is hidden from you and you control everything. Using this approach you do gain real control over the Operating System you install adding only what you want and nothing more. There is not installer program, so all the steps of the install process has to be completed by you. By the end of the install you will already be an experienced Linux Administrator, although you may have done more than a little Googling only the way.
Downloading the ISO
Installing Arch starts with downloading the ISO file. This can be obtained from Arch themselves and the ISO is date based. The ISO file I use is dated 2016-11-01. As always, new features may be added in later releases of the installer disk. Downloading the DUAL version will allow you to install the 32 bit or 64 bit version of Arch. With the ISO downloaded you can install to a virtual machine or physical machine. Using the Linux command dd you may transfer the ISO contents to a USB drive.
- 32 bit Version >= 256MB
- 64 bit Version >= 512MB
When installing Arch Linux in the demonstration we will see that a Virtual Machine is used but this could equally be a physical machine on bare-metal. The requirements can be very low depending on what you want to do with the system. I will not use a GUI or run many services so I can get away with very small requirements. Using as low as 256MB RAM is possible for the 32 bit version and 512MB is required for the 64 bit version. This is one feature that Arch offers, is that nothing is added that you do specifically add in. We have no spurious services running in the background that you may or may not run.
Installing Arch Linux
Starting the VM or the Physical Box to run the install making sure that we do boot from the ISO or CD. In doing this we will boot to the live Arch installation system. The boot menu will allow us to choose to install the 64 bit or 32 bit version. We choose the 64 bit edition in the demonstration. Linux will load and login automatically as the root user to the ISO.
Setting the Keyboard Layout
Using the default keyboard layout is going to be fine if you have a US keyboard. Using other keyboard layouts may require you to set the layout to match the keyboard that you have. If you are only going to connect via SSH you may well be able to leave this at the default and your client layout will have the correct mapping no mater what your Arch Server is set to. For example, connecting from a UK SSH client will give you access to the UK keylayout.
The keymaps are stored in sub-directories below the /usr/share/keymaps directory. The UK layout would be /usr/share/keymaps/i386/qwerty/uk.map.gz. To use this layout we can use the command:
Since 2012 the network should load automatically where wifi is not required. So if you are using a wired connection with either a VM or Physical system you should have networking. Using the command ip we can verify the address settings:
ip addr show
The output will show that you have an IP Address.
Partitioning the Disk
We are now ready to start partitioning the disk. There are many scenarios that we could run here but we will make use of a swap partition and a single partition for the root filesystem. Initially, though, we can check the the disks we have available to the system.
We should see devices /dev/sda if we have a standard hard drive available or perhaps, /dev/vda if we are using XEN or KVM virtualisation. When portioning the disk you can use tools like parted, fdisk, cfdisk and sfdisk to manage this. Much depends on tools you have used before and are comfortable with. We will use fdisk but tools such as cfdisk provide more of a menu if this is what you prefer. We will create a swap portion and a single portion for the rootfs.
Using fdisk as the partitioning tool:
fdisk /dev/sda n enter # Create new partition enter # Create primary enter # Accept the default start +256M enter # Set size to 256MB t enter # Change type of partition enter # Accept the default of partition 1 82 enter # Set it for swap n enter # Create second new partition enter # Create primary enter # Accept the default start enter # Accept the default end being the rest of the disk a enter # Set the bootable flag enter # Accept that this will be on partition 2 the last use partition w enter # Save the changes lsblk #Confirm partitions
So we have the sda1 partition now which we will use for SWAP and sda2 which we will use for our root filesystem. We make use of the XFS filesystem for our root filesystem, you may choose other filesystems if you prefer.
mkswap /dev/sda1 mkfs.xfs -L ROOT /dev/sda2
Using the blkid command we can confirm that the label is set correctly:
With the filesystem comfortably on the partition we need to use for root, we can mount the filesystem through to the /mnt directory of the live CD. The swapon command is used to add the swap space to the system.
mount /dev/sdb2 /mnt swapon /dev/sdb1 swapon -s #Can be used to display swap space in use
While we continue install Arch Linux we do need to add some packages. We will add package groups to make this a little easier. The Arch Linux site has a list of package groups. We add the base package group, which as the name suggests, adds the minimal packages that we require. Adding in base-devel will give you tools like sed and gcc. We target the packages to be installed in the mount point the root filesystem was targeted at. As well as the package groups base and base-devel we can add individual packages.
The individual packages we add are listed below:
- grub: The GRUB 2 boot loader
- vim: Although the basic vi editor is included in the base group vim provides more functionality such as syntax highlighting.
- bash-completion: This package allows for tab completion on programs to be able to list sub-commands and options. Really useful to see which options are available to which sub-commands
- openssh: The OpenSSH Server so that we can connect remotely if required.
pacstrap /mnt base base-devel grub vim bash-completion openssh
This will take a little while to download, expand and install. Aim to leave 20 to 25 minutes or so for this process to complete
Create a New /etc/fstab File
The /etc/fstab file is used to mount filesystems at boot time, we of course, need to create this file. Installing Arch Linux in this way we get to see each process, whilst other distributions will use an installer process that will execute many of these task for you. Exposing these elements to you at installation does help you understand the installation better; even though it may seem a little frustrating if you are new to Linux. We still target the etc directory located in the mount point, as that is where the target root filesystem is located. The option -p will include psuedo-filesystems in needed and the -U option is to ensure that partition UUIDs are used in favour of partition devices.
genfstab -pU /mnt >> /mnt/etc/fstab cat !$ # Will display the /mnt/etc/fstab file, !$ is the last argument
We have now completed all the task that we need from the installation disk itself. We can now change the root directory to /mnt. In this ways all commands target our real root filesystem and not the installation disk.
Set Root User Password
We can now assign a password to the root user:
We will also take this opportunity to create a non-root user account. Adding the user to the wheel group which can be used for administrative purposes. The -m option ensure the user’s home directory is created and the -G option adds the user to the wheel group. We can use this membership of the wheel group later to allow this user access to administrative command via sudo.
useradd -m tux -G wheel passwd tux
Setting the Hostname and Hosts Entry
We can echo the name that we want to use for our host to the /etc/hostname file. This can be just the name to the Fully Qualified Domain Name if you want.
echo zeus > /etc/hostname
We normally will have a localhost record for that name, so we can append an entry to the local hosts file. Using >> will append to the file and the -e with echo allows for escape code to be used. We use \t for a tab.
echo -e "127.0.1.1\tzeus" >> /etc/hosts
Setting the Timezone
The timezone of the system means that we can accurate know the correct time from time servers around the world. The time is given as UTC time and we can adjust the display to match the timezone we are located in. We need to create a symlink /etc/localtime that points to the correct timezone file we use. On my system I am setting for UK time.
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
We can now make sure that the system time is synchronised back to the hardware clock, with the hardware clock using UTC time. This is normal as the system time will then add the offset to the Hardware Clocks UTC time.
hwclock --systohc --utc
Setting the Locale
The locale has regional specific information such as the way that the date is display and numerical separators. To set the locale when installing Arch Linux we first edit a template file that list the locales. We just uncomment the locales that we want to use on the system. Uncomment the locale that you want from the file /etc/locale.gen. In my case I only need to use en_GB.UTF-8 and this is the only locale that I uncomment. Once edited we can generate the lace information using the command locale-gen. Then add the default locale to the file /etc/locale.conf. In my case I add the line LANG=en_GB.UTF-8. To ensure that it is in use now we can also export the variable.
vim /etc/locale.gen locale-gen echo LANG=en_GB.UTF-8 > /etc/locale.conf export LANG=en_GB.UTF-8
Generate the InitRAMFS and Install GRUB
To create the ram disk for the kernel we run the following command
mkinitcpio -p linux
We can then install the GRUB boot loader and populate the grub.cfg file.
grub-install /dev/sda grub-mkconfig -o /boot/grub/grub.cfg
If we want to continue using DHCP on boot to obtain the IP Address we need to start the DHCP Client automatically and if we want to connect via SSH to the system we need to start the SSH Server on boot. Arch Linux is system based so we use systemctl to manage this.
systemctl enable sshd dhcpcd
Reboot the System
We are almost at the end of installing Arch Linux now. We first have to exit back to the ISO system from the chroot jail we entered. We then shutdown so we can remove the CD or ISO file before rebooting.
exit shutdown -h now
If it is a virtual machine we can disconnect the ISO file before rebooting.
With Arch now installed we can restart the system and login as the root user. Once looked in we can ensure that we have the correct keymap loaded on to load on boot.
localectl set-keymap uk
We can also set the default locale
localtectl set-locale LANG=en_GB.UTF-8
To allow the use we created to use sudo to run commands, this use was added to the wheel group, we run the command visudo and un-comment the entry for the wheel group.
The following video will step you through the complete installation process and is worthwhile watching the full 30 minutes.