Install Arch

Install Archlinux on VirtualBox

Booting from the Arch linux iso


Once you have configured your environment for VirtualBox, you simply need to click start to initiate the boot process. However, make sure you have an active network connection as this will be needed throughout the installation process.



Arch Linux VirtualBox VM Manager Console

After clicking start, you will be asked for the location of your installation image unless you specified this earlier on the storage tab.


Select Location of start up disk (iso image)


Click the small folder icon and navigate to the location of your installation media (iso image). Once selected, click on the "Start" button.


Arch Linux VirtualBox select iso location

Arch Linux Initial Boot Screen


Initially the following screen is displayed. Here you can make several choices. You can select to boot a 64bit version of the iso by selecting "Boot Arch Linux (x86_64) or choose the 32bit version by selecting "Boot Arch Linux (i686). Please note, a 32bit version will work on a 64bit system, however a 64bit version will not work on a 32bit system.

In this installation, I am using the 64bit version.


Arch Linux VirtualBox Initial Boot Screen

Arch Linux Initial root shell


After selecting the 64bit option, the system will load and you will be presented with a root shell where you will type in your commands.


Arch Linux VirtualBox root shell

At this point it is always a good idea to check your disk and internet connection. You can issue the command lsblk to display your disk allocation (list block device command). To check that you have been allocated an IP address issue the command ip a s. If all is ok you should see your disk allocation and have an IP addressed assigned.


Partitioning your Disk


At this point we need to partition our disks ready for our installation. For this example I am using a 20GB disk. I will be allocating 10GB of space to the root partition, 1GB of space for swap and the remaining disk will go to my home partition.


10GB - root Partition 1GB - Swap Partition Remainder of space allocated to home

To carry out the partitioning, there are many tools available. I have chosen to use "fdisk for this purpose. I have chosen fdisk as it is available on most Linux distributions and is very simple to use.


Using fdisk for partitioning


To start using the "fdisk" partitioning tool, we need to specify which disk we are going to be using (working with). As we saw from the previously entered "lsblk" command, our 20GB disk can be identified by the label "sda". Therefore the command we are going to enter to initiate the partitioning tool will be:


fdisk /dev/sda

Arch Linux Disk partitioning with fdisk

To view all the commands available to "fdisk" you can type the letter "m".



Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the DOS compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Create root partition with fdisk


Arch Linux Disk fdisk root partition

The following commands were issued to create our first (root) partition:

n - Creates a new partition
p - Selected a Primary Partition
Enter - To accept default starting sector.
+10G - Specify a size of 10GB
t - Select Partition Type
1 - Specify we are working with Partition number 1
83 - 83 was selected as this is used for a standard Linux partition (default is 83)


Note: Although we didn't need to specify a partition type of "83", it always good practice to specify a partition type. A full list of the available codes can be seen be issuing the command "L".


Create Swap Partition


Arch Linux Disk fdisk swap partition

The following commands were issued to create our swap partition:

n - Creates a new partition
p - Selected a Primary Partition
2 - Selected Partition Number 2
Enter - To accept default starting sector.
+1G - Specify a size of 1GB
t - Select Partition Type
2 - Specify we are working with Partition number 2
82 - 82 was selected as this is the type used for Swap


Create Home Partition


Arch Linux Disk fdisk home partition

The following commands were issued to create our home partition:

n - Creates a new partition
p - Selected a Primary Partition
3 - Selected Partition Number 3
Enter - To accept default starting sector.
Enter - To accept default end sector. (Uses all remaining space)
t - Select Partition Type
3 - Specify we are working with Partition number 3
83 - 83 was selected as this is used for a standard Linux partition (default is 83)


View Partition Layout


To view our proposed layout, we can issue the command p:


Arch Linux Disk fdisk view proposed partition layout

Now we should see our three partitions that we have defined. Note, although we have defined our partitions, they will not be written to disk until we issue the "w" command to write our entries.


Write our proposed partition layout


To write our proposed changes, we issue the "w" command:


Arch Linux Disk fdisk write changes

Create Filesystems and Format Partitions


The next step of the installation involves the creation/formatting of our partitions. For this part of the installation, we will be using the "mkfs" command to create our file systems and the "mkswap" command to create our swap space.

First work with our standard Linux partitions: /dev/sda1 and /dev/sda2. The sda part of the name corresponds to our disk. The number signifies the partition numbers we created earlier.

Commands Issued:

mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda3

We are going to use a filesystem type of "ext4". This is a popular choice as it incorporates journalling.


Arch Linux mkfs commands

Command Issued:

mkswap /dev/sda2
swapon /dev/sda2

The swapon command is used to activate the swap space.


Arch Linux mkswap commands

lsblk - Use this command to verify


The "lsblk" command can be used to show our current layout:


Arch Linux lsblk command

Here we can see our partitions and the space that has been allocated. Before we can use this space, we need to mount our filesystems first.


Mounting Filesystems


The next step before the installation is initiated is to mount our filesystems. The commands used are as follows:

mount /dev/sda1 /mnt Our root filesystem is mounted on mount point "/mnt"

mkdir /mnt/home A mount point is created for the home filesystem.

mount /dev/sda3 /mnt/home Our home file system is mounted on "/mnt/home"

Note: There is no need to worry about our swap partition, this was initialized earlier.


Arch Linux Mount Filesystems

Choose the closest location for downloads


At this point we are going to modify a file called: /etc/pacman.d/mirrorlist

You can either manually edit this file leaving the closest locations present or you can install a package called "reflector". Reflector is a special script that can retrieve the latest mirror list from the MirrorStatus page, filter the most up-to date mirrors, sort them by speed and overwrite the file /etc/pacman.d/mirrorlist. Before we install and run reflector, it is a good idea to make a copy of the original file. To create a copy, we can issue the following command:

cp -vf /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup

When run, this command will make a copy of the original file and call it "mirrorlist.backup".


Install Reflector


To install reflector, we simply issue the following commands using the "pacman" package manager:

pacman -Syy


Arch Linux Sync Package Databases

pacman -S reflector


Arch Linux Install reflector

After issuing the above command, you need to reply "Y" to confirm the installation of reflector.


Using reflector


Once we have installed "reflector", we can now issue the following command to sort the five best mirrors for your location:

Command Issued: reflector --verbose -l 5 --sort rate --save /etc/pacman.d/mirrorlist


Arch Linux reflector command

The above command will now have generated a new mirrorlist file. This can be seen in the image below:


Arch Linux reflector mirrorlist

After making any changes to a mirrorlist, it is always advisable to re-issue the sync command: pacman -Syy


Installing the Base


The base installation is installed using a special script called "pacstrap". We will be installing the base group and also the base-devel group. The "based-devel" group is included as it contains some packages you may need at a later stage.

Command to be issued:

pacstrap /mnt base base-devel

Once you have issued these commands, the necessary packages will be downloaded. This may take several minutes depending on your connection speed and your proximity to the remote server (mirror).


Create /etc/fstab - mount table


This next step of the installation will create a mount table (/etc/fstab). The mount table is responsible for which filesystems get mounted automatically at boot time. Backup options may also be specified here. The creation of this file is easy as all that is required is for the following command to be run:

Command Issued: genfstab -U -p /mnt >> /mnt/etc/fstab


Arch Linux Create Mount Table

We can verify that the correct entries have been created by issuing the following command: cat /mnt/etc/fstab

You can also issue the "blkid" command against your partitions to verify this information. (blkid /dev/sdx) where x is is the partition number.


Chroot - Configuring the Base System


To start configuring our new installation we need to issue the "arch-chroot" command. The command is run as follows: arch-root followed by the new root directory as the first argument. The command that we will issue is:

arch-chroot /mnt /bin/bash

You can pass an optional argument to specify a particular shell. In this case we are using a bash shell. If this is omitted, then the default "sh" is used.


Configuring locale settings


At this point in the installation, we must configure the locale settings. These settings are used for the system language. A file is provided that contains these settings, however, all the entries are commented out.

The file is located in the following path: /etc/locale.gen

Using the editor of your choice, open the file and un-comment the locale setting that matches your language. In this example I am going to use the setting en_GB.UTF-8. To use this setting I simply remove the hash "#" from the beginning of the line.

Once you have made your selection, you will need to run the following command:

locale-gen


Arch Linux Create locale

Next we need to run the following command to create the /etc/locale.conf file. You will need to substitute your language setting:

Commands Issued:

echo LANG=en_GB.UTF-8 > /etc/locale.conf
export LANG=en_GB.UTF-8


Arch Linux Create locale.conf file

Next create the following file: /etc/vconsole.conf

Add the following line: KEYMAP=uk

You will need to amend this setting to match your country. If no setting is added, then the default "us" is used.


Configuring the Time Zone


To configure your Time Zone you need to create a link to a file called /etc/localtime

First take a look at the available zone information by issuing the following command:

ls /usr/share/zoneinfo/


Arch Linux displaying zoneinfo

Now we can check the contents of a directory belonging to a subzone:

ls /usr/share/zoneinfo/Europe


Arch Linux displaying zoneinfo

Once you have decided on the zone that matches your requirements, you need to create a link. This can be done with the following command (amend accordingly):

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

The above example shows that the Zone of Europe has been selected with a subzone of London.

syntax: ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime


Set Hardware Clock


Next we need to set the hardware clock. In this example, I have specified UTC as my setting.

Command Issued:

hwclock --systohc --utc


Set the Host Name of our System


Every computer on a network should have a unique hostname that can easily identify the system. To give our new system a hostname we can simply issue the following command:

echo myhostname > /etc/hostname
Amend the myhostname to a name of your choice. In this example I have issued the command: echo arch01 > /etc/hostname

Now we need to add the same hostname into our hosts file. The host file can be found in the following path: /etc/hosts

In the example below I have added arch01 as my entry. Once you have added your name, simply save your changes.


Arch Linux Adding entry to hosts file

Enable Multilib Repository


The multilib repository repository allows a user to run and build 32bit applications on a 64bit installation of Arch Linux. To add the multilib repository we simply add the following lines to the bottom of the file: /etc/pacman.conf

[multilib]
Include = /etc/pacman.d/mirrorlist

Once the lines have been added, we need to run the sync package command:

pacman -Syy


Arch Linux Adding multilib

Adding support for Yaourt Package Tool


To activate the Yaourt Package tool (for downloading and building AUR packages) add the following lines to the file: /etc/pacman.conf

[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
Once the lines have been added, we need to run the sync package command:

pacman -Syy


Arch Linux Adding repo for yaourt

Synchronise and Update Database Packages


At this part of the installation, I would recommend running the update system command:

pacman -Syu

Any new updates found will prompt you for installation. Simply reply to the confirmation with a "Y"


Create a password for the root account


Currently we have no password for the root account. To assign a password to the root account we need to issue the command: passwd


Arch Linux Adding password to root account

Adding a new user with sudo privileges


To add a new user we issue the command useradd along with a list of primary and secondary groups. The important group here is the wheel. Members of this group will be able to issue commands prefixed with sudo. This will allow the user to run a command as the root user. In the example below we have also specified the default shell to be "/bin/bash".

Command Issued:

useradd -mg users -G wheel,storage,power -s /bin/bash your_new_user

Simply change the "your_new_user" to that of the named account you wish to create.

Once you have issued this command, you will also need to assign a password to that account with the passwd command.


Arch Linux Adding a sudo user account

Installing sudo Package


Sudo is a useful package that when installed allows specified user to prefix a command with "sudo and run a command with escalated privileges. To install the sudo package we have to issue the following command: pacman -S sudo

Command Issued:

pacman -S sudo


Arch Linux installing sudo

Configuring a sudo - adding user to wheel group


Before a user can issue commands as the root user, we need to configure the sudo configuration file. To edit this file a special command called visudo is used.

After issuing the "visudo" command, you will need to uncomment the following line:

%wheel ALL=(ALL) ALL

Once this is done, simply save your changes.


Installing a Bootloader


The following commands will enable us to install a bootloader on the first system hard disk (/dev/sda). Commands Issued:

pacman -S grub
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Note: If you had a multi OS environment, you could install the "os-prober" package with "pacman -S os-prober" before running the "grub-mkconfig" command. Os-prober will detect other operating systems when generating the grub.cfg file.


Congratulations - Arch Linux is now installed


The next step is to exit out of the "chroot" environment and unmount our filesystems before a reboot.

Commands Issued:

exit
umount /mnt/home
umount /mnt
reboot


Boot from Existing OS


At the startup screen choose the option to "Boot existing OS".


Arch Linux Boot Existing OS

After making your selection, the traditional "Grub" bootloader menu will be displayed. You can press "Enter" to continue immediately, or wait for around for 3 seconds for the system to automatically boot.

Once the system has booted, you will be taken to a login screen. You will notice that the hostname you specified earlier has now been picked up.


Login Screen


From this login screen, you can login with the "sudo" user you created in an earlier step.


Arch Linux Login Screen

Configuring the Network


After the reboot, you will have lost your network connectivity. To rectify this we need to create a new definition for our interface. To identify the name of the interface we can issue the command "ip link


Arch Linux Network Interface Name

From the above output we can see that the our interface has a name of "enp0s3". Next issue the command: "sudo vi /etc/systemd/network/enp0s3.network". This will create an empty file with the name of our network interface. Once the empty file has been created and opened, you will need to add the following lines of information:

[Match]
Name=en*

[Network]
DHCP=yes

You will need to amend the network name to match that of your network interface. In this example we are also using DHCP to obtain our IP address.

Once the above lines have been added and you have saved your changes, the following commands need to be issued to active the network.

sudo systemctl restart systemd-networkd
sudo systemctl enable systemd-networkd


Arch Linux restart network

Hopefully we now have network connectivity. However, before we can connect to the internet, we need to add a nameserver to the "etc/resolv.conf" file. To edit the file we issue the following command:

Command Issued:

sudo vi /etc/resolv.conf

Once the file is opened, we are going to add the 2 name server entries. In this example, I am using Google's free public DNS servers.

Amend the file so that it resembles the entry below:

#
# /etc/resolv.conf
#
#nameserver ip
nameserver 8.8.8.8
nameserver 8.8.4.4

Once you have saved your changes, we can now test our network connectivity:

Commands Issued:

ip a s
ping -c 3 www.google.com

You should now see that we have been assigned an IP address and that we can "ping" google.com


Arch Linux check network

Run a Full System Update


Before we proceed to installing an X video environment and desktop, this is a good time to run a full system update. To run an update issue the following command:

sudo pacman -Syu


Installing the X Environment


Our next step of the installation is to install the necessary components for a graphical environment. To install the X environment, issue the following command:

sudo pacman -S xorg-server xorg-xinit xorg-utils xorg-server-utils mesa xorg-twm xterm xorg-xclock


Arch Linux install X Environment

In the above example Option "1" was chosen. You will need to confirm your installation be replying with a "Y" when prompted.

Next we are going to install some VirtualBox packages:

Command Issued:

sudo pacman -S virtualbox-guest-utils virtualbox-guest-dkms

Once these packages have been installed successfully, we can go onto test our environment.


Testing our X Environment


To simply test our installed environment, we can issue the command "startx". Command Issued: startx

After issuing the above command, you should now see a basic looking graphic environment as per the image below:


Arch Linux start X Environment

To exit out of this environment, simply type "exit" into the command line window. You will then return to your normal "shell".


Installing the Gnome Desktop


To install the "Gnome" desktop we need to issue the following command:

sudo pacman -S gnome gnome-extra gdm

The installation of the "Gnome" desktop may take a while depending on the speed of your connection and system. Press "Enter" to accept the defaults and reply "Y" where necessary to confirm the installation.


Install Networking Tools


The next package to install is that of the "net-tools" package. This package has some useful utilities and commands that can be used. To install this package, issue the following command:

sudo pacman -S net-tools

As a quick test we can issue the ifconfig command as this command comes as part of the net-tools package.


Installing popular packages


The following command will install some important package along with some popular software for your new system.

Command Issued:

sudo pacman -S pulseaudio pulseaudio-alsa pavucontrol gnome-terminal firefox flashplugin vlc deluge smplayer audacious qmmp gimp xfburn gedit gnome-system-monitor

The above will take a while to install. For a full list of available packages and software for Arch Linux,
visit the following link: Arch Linux Packages

Other popular installation packages are Thunderbird the popular email client and LibreOffice the full office suite. This can be installed with the following if needed:

sudo pacman -S LibreOffice
sudo pacman -S thunderbird


Installing Codecs


The following codecs are needed for the playing of Audio and Video. Simply issue the following command:

Command Issued:

sudo pacman -S a52dec faac faad2 flac jasper lame libdca libdv libmad libmpeg2 libtheora libvorbis libxv wavpack x264 xvidcore gstreamer0.10-plugins

Accept the defaults and reply "Y" when prompted.


Installing Yaourt Package Manager


To install community maintained software you will need to install the "Yaourt Package Manager". This can be installed with the following command:

sudo pacman -S yaourt


And Finally....Activate the Desktop Environment, Remove Installation media and then reboot the system


Once all the packages have installed successfully, we need to enable the Gnome environment to start automatically at system boot. This is done by issuing the following command:

sudo systemctl enable gdm

Next it is recommended that you remove the installation from your VirtualBox storage. From the VirtualBox Manager, highlight your Arch Linux system and click on storage. Now highlight the installation media icon (CD/DVD) and click on the attributes box. Now select "remove disk from virtual drive". Next step is to "reboot" the system. To reboot, issue the following command:

sudo reboot


Logging into to the Desktop


If all has gone well, you should now see a login screen similar to the image below:


Arch Linux Desktop Login GNOME

Now enter the password you created earlier and click on the "Sign in" button.

You should now see the "Gnome Desktop", to find your software click on "Activities".


Gnome Desktop


Arch Linux Desktop Login GNOME

Arch Linux Documentation and Helpful Resources


Main Arch Linux WebSite: Arch Linux Main WebSite

Arch Linux Forums: Arch Linux Forums

Arch Wiki: Arch Wiki

Arch Linux Beginners Guide: Arch Linux beginners Guide

Arch Linux Installation GuideArch Linux Installation Guide