Beginners’ guide to installing Arch Linux

Introduction

In this tutorial you will lean how to install Arch Linux on VirtualBox, create a regular user account and install a desktop environment. It is also compatible with setting up Arch Linux on a real machine. Arch Linux is a GNU/Linux distribution, which aims for simplicity and full control to the end user. Please take note that this distribution may not be suitable for beginners. However, if you still wish to proceed then this guide is an excellent choice to getting you started with Arch Linux–although it is not a one-stop Arch Linux installation tutorial. It is still best to refer to the Arch Linux manuals. VirtualBox is a free and open-source virtualization software by Oracle corporation. It allows users to run nearly any operating system on a single machine and to freely switch between operating system instances running simultaneously.

Requirements

This tutorial assumes that you already have VirtualBox installed on your computer and have downloaded the Arch Linux installer ISO, which you can get from archlinux.org.

Arch Linux Virtual Machine

To begin with the installation open up virtualbox and click on New. On the Name type Arch Linux and it will automatically select the Type and Version of the operating system for you. Click on Next, here you can choose how much RAM you wish to give our virtual machine. I am just going to leave it to the default 1 gb and click on Next. Now we are asked if we would like to create a virtual hard disk, choose Create a virtual hard disk now and click on Create. For the hard disk file type we will go with VHD (Virtual Hard Disk) and click on Next. Select Dynamically allocated so it only uses space on your physical hard disk as needed and click on Next. Finally, we choose the size we like for our virtual hard disk to have. I’m going to give mine 80 gb of space and click on Create.

We are now done creating our virtual machine.  The next step is to insert the Arch ISO into our virtual CD-ROM. To do that click the title that says Storage, and under Controller: IDE select the icon that looks like a CD that says Empty. On the left most c2017-03-18-222949_674x444_scrotorner of the window there is another icon that looks like a CD, click on that and select Choose Virtual Optical Disk File… This option allows us to choose the image that we would like to load, in this case it is the Arch ISO installer. Now navigate to where you downloaded the Arch ISO, open it and click on Okay.

Now we are ready to start our virtual machine. Click on Start to begin our installation. On the opening screen choose Boot Arch Linux (x86_64) and press enter. This will boot to our live CD and automatically log in as root user. If we type ls then enter we can see an install guide that is included in the live CD in a text file named install.txt. We’re going to use the less command to view the contents of our install guide, so less install.txt allows us to scroll up and down using the arrow keys. To carry out with the installation without closing our install guide we can switch between terminals. On VirtualBox this is done by pressing the host key, which is the right ctrl key plus the function key that is bound to the terminal end. We are currently on TTY1 terminal, which is bound to F1 function key on our keyboard. So to switch to TTY2 terminal we press the right ctrl key plus F2. Just type in root to login to TTY2. To go back to TTY1 terminal just press the right control key plus F1. On a real machine the key combination is ctrl+alt+Fn.

The installation guide is divided into 3 parts. The first part is the pre-installation, the second part is the installation and the last part is configuring the system.

Pre-installation

So for the first part, the first step is to check for internet connection. Of course it has already been automatically configured when we created our virtual machine, but on a real machine depending on your set up, you just have to read through the installation guide on how to get your internet connection working and possibly open another computer and read through the manuals from Arch Linux specific to your internet connection. Please be aware that I may skip some steps in the installation process as the goal of this tutorial is to keep it as simple as possible. Again on a real machine you may have to deal with setting the keyboard layout and verifying the boot mode of your machine. Now let’s move on to updating the system clock. This is done with the timedatectl set-ntp true command. To check the status we type timedatectl status.

Next is to format our hard disk to have separate partitions for boot, swap, root and home directories. fdisk -l lists the devices available on your system. I know that /dev/sda is my hard disk because of its size. Type fdisk /dev/sdx where x is the device letter for your hard disk to begin format. To add a new partition type n. Select p for primary partition, 1 for partition number, just press enter for the first sector, and type +100M for the last sector then press enter. This will be our boot partition. Type n again to create our swap partition. Select p for primary partition, 2 for partition number, just press enter for the first sector, and type +4G for the last sector then press enter. Type n again to create our root partition. Select p for primary, 3 for partition number, just press enter for the first sector, and type +20G for the last sector then press enter. Type n again to create our home partition. Select p for primary, just press enter for the first sector and enter again for the last sector. Type p and enter to print the partition table. You should see the same output as shown in the screenshot provided. Now we are done partitioning our hard disk. Type w to save the changes and exit fdisk. VirtualBox_Arch Linux_18_03_2017_22_39_22

Now we need to format the partitions to Linux file system. We are going to format all partitions to ext4 file system except for swap. To format the boot partition type mkfs.ext4 /dev/sda1 then enter. Do this for the boot and home partitions replacing 1 in /dev/sda1 with their corresponding partition number. A swap is created with mkswap command so type mkswap /dev/sda2 and press enter. To activate our swap type swapon /dev/sda2.

After partitioning our hard disk, we can now mount our root to /mnt. The command is mount /dev/sda3 /mnt where /dev/sda3 is our root file system. The next step is to create the /mnt/boot and /mnt/home directories and mount our file systems accordingly. Type mkdir -p /mnt/boot && mkdir -p /mnt/home to create the boot and home directories, then mount with mount /dev/sda1 /mnt/root && mount /dev/sda4 /mnt/home where /dev/sda1 and /dev/sda4 are the root and home file systems respectively.

Installation of system files

Now we move on to the second part of the install guide, which is the installation of the system files. The first step is selecting the mirrors. Mirrors are computer servers that are copies of our primary Arch Linux server. These mirrors are defined in the /etc/pacman.d/mirrorslist file. We’re going to edit this file using the nano editor and move the mirror that is geographically closest to you to the top of the list because the higher a mirror is placed in the list, the higher priority it is given. So type nano /etc/pacman.d/mirrorlist and select the mirror that is closest to you. Pressing ctrl+k cuts the current line into buffer while ctrl+u pastes the line from the buffer. When you are finished editing, press ctrl+o to save the file and then ctrl+x to exit nano.

We can now install the base packages with pacstrap /mnt base.

Configuring the system

We can now move on to the last part of the install guide, which is configuring the system. The first step is to generate an fstab file with genfstab -U /mnt >> /mnt/etc/fstab. Check the resulting file afterwards with cat /mnt/etc/fstab and edit it in case of errors. Next is to change root with arch-chroot /mnt command. To set the time zone type ln -sf /usr/share/zoneinfo/Region/City /etc/localtime where /Region/City are your zone information. To adjust the time and generate /etc/adjtime type the command hwclock --systohc. To generate your locale, edit the /etc/locale.gen file and uncomment #en_US.UTF-8 and other needed localizations by removing the hash sign at beginning of the line, save it and exit then type locale-gen. Set the LANG variable by creating a /etc/locale.conf with nano and adding the line LANG=en_US.UTF-8. Now we need to create the hostname. The hostname is the name that you would like to give to your computer. To do that create a file /etc/hostname with nano and add the name that you desire. Next is to edit the /etc/hosts and add the line 127.0.1.1 myhostname.localdomain myhostname where myhostname is your chosen hostname. It is now time to set the root password. Type passwd and type your root password twice. This will be the password, that you are going to use when you log in as root. We are almost done and the second to the last step is to install the boot loader. Type pacman -S grub and wait for it to finish. When it is finished installing type grub-install --target=i386-pc --recheck /dev/sdx where x is the device letter for your hard disk. This will install grub boot loader to our hard disk. To create a grub config file first move the old config file to another file because the mkconfig cannot overwrite the old config file. So type mv /boot/grub/grub.cfg /boot/grub/grub.cfg.sav. Now type grub-mkconfig -o /boot/grub/grub.cfg to make a new grub config file. Exit the chroot environment by typing exit or pressing ctrl+d. From here we can type reboot and boot to our newly installed Arch Linux virtual machine. Optionally, for security reasons you may unmount /mnt first, but this is done automatically when you type reboot. To unmount it manually type umount -R /mnt. Reboot the system and log in as root user and type in your password. If everything goes well then you will be logged in as root. Congratulations! You have succesfully installed Arch Linux on VirtualBox.

Post-installation

Adding a regular user account

It is not wise to use our system always as the root user, so we want to create a regular user account with permission to perform root functions under sudo. This leads us to the second part of the installation which is creating a regular user account and installing a desktop environment. To create a new user type useradd -m -G wheel -s /bin/bash username. To give our new user permission to use sudo, we edit the configuration file with EDITOR=nano visudo and locate the section marked as # User privilege specification and uncomment the line that says # %wheel ALL=(ALL) ALL by deleting the hash sign at the beginning of the line. Now save the file and exit. Set the password for our user with passwd username. Type logout then relogin as the regular user. Notice the change of the prompt from # to $. This helps you know if you are logged in as root or not.

Installing LXDE desktop environment

Debian-lenny-lxde

The last step is to install a desktop environment. The first thing to do is to install xorg for graphical display. This is done with sudo pacman -S xorg xorg-xinit xorg-server xorg-server-utils xterm and then install LXDE with sudo pacman -S lxde. Before you launch LXDE, define a configuration file xinitrc with nano ~/.xinitrc and add the line exec startlxde to it then save it and exit. To launch LXDE just type startx. And that is it. I hope this tutorial has been useful in helping you get started with Arch Linux.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s