How to Install Arch Linux and Support Graphics

In this article “How to install Arch Linux and support graphics“, I will help you install Arch Linux alongside support for GUIs on a single/multi-boot system. I will focus on UEFI while pointing out special actions for Legacy BIOS if needed. I will also cover Arch Linux Installation alongside Windows. At the same time, I will also explain each term and what each package/command does. This will answer lots of your questions like:

  1. How to mount a new hard disk during the boot automatically?
  2. How to make Arch Linux game ready?
  3. What is display manager and how to change it?
  4. How to partition and format a disk in Linux?
  5. How to block certain websites such as po*n sites?
  6. How to create a sandbox environment using arch-chroot?
  7. What is swap partition in Linux?
  8. How to manage user accounts? How to add a user to a group in Linux?
  9. How to use Live CD/USB to fix the unbootable Linux Computer?
  10. How to use existing Arch Linux setup instead of Live CD/USB to install Arch Linux on a separate computer?

Note: If you are uncomfortable with it, you can try it on Virtual Box, but be warned that it uses Legacy BIOS. To change it to UEFI, check the EFI tick box in Settings > System > Motherboard.

Enabling UEFI in Virtual Box
Figure: Enabling UEFI in Virtual Box

Table of Contents

1. Download Arch Linux ISO and Create a Bootable USB Drive

You first need to download the ISO file from the official website. Once the file is ready, you will need to create a bootable USB drive. For this, you can use either the Linux commands or GUI utilities.

1.1 Create Bootable Drive Using Linux Commands

The name of the USB drive can be found by using lsblk --path. Here, you need to be very careful – choosing the wrong drive will erase everything on it.

 Finding Name of Appropriate USB Device in Linux
Figure: Finding Name of Appropriate USB Device in Linux

After finding the drive’s name, use the following dd command to create the bootable USB drive (also known as “Live USB drive”):

# dd if=YOUR-ISO-FILE of=/dev/sdX status=progress

In the above command, replace YOUR-ISO-FILE with your downloaded *.iso file and /dev/sdX with the appropriate USB drive.

A sample example might look like this:

# dd if='/home/ajay/Downloads/Archlinux/archlinux-2021.09.01-x86_64.iso'
 of=/dev/sda status=progress

You can also use GUI tools as given below.

1.2 Create Bootable Drive Using GUI Utilities

Alternatively, if you are not comfortable with dd or if you are working from a Windows computer, you can also use GUI tools like Etcher or Rufus. Both are free and open-source and both work on Linux and Windows.

Etcher - A USB Forming Utility
Figure: Etcher – a USB forming utility

Now that you have created your bootable drive, you will use it to boot into the Live Environment. For starters, Live Environment is a temporary “Operating System” (in your case, temporary Arch Linux) and basically, it is used to install a full-fledged Operating System on a separate Hard Disk (or SSD).

2. Boot into the Live Environment

Before you boot, you need to disable UEFI’s Secure Boot because the Live Environment created above does not support it. You can enable it later after you are done with the installation.

2.1 Disable Secure Boot

To disable it, you can use the Boot Menu on your computer. To access this menu, follow the guide from your computer’s manufacturer. Alternatively, if you are installing the Arch Linux alongside Windows, you can access the menu directly from Windows (for Windows 10, Settings > Update & Security > Recovery > Advanced startup (Restart now) > Troubleshoot > Advanced options > UEFI Firmware settings > restart.).

Now, you can boot using the Live USB drive. If your computer is based on Legacy BIOS, your screen might look like this:

Boot into Arch Linux's Live Environment (BIOS)
Figure: Boot into Arch Linux’s Live Environment (BIOS)

And if it is based on UEFI, it might look like the following:

Boot into Arch Linux's Live Environment (UEFI)
Figure: Boot into Arch Linux’s Live Environment (UEFI)

In both cases, just hit Enter on the first selected item. After booting into the Live Environment, you will first configure Live Environment a little bit.

3. Configuration of the Live Environment

This step involves setting up the keyboard layout, internet connection, and system clocks.

3.1 Set the Keyboard Layout

If you are from an English-speaking country, you should leave it to its default value – US to reduce complexities and move to the next step.

But, if you want to change it to other layouts, use the loadkeys command:

# loadkeys LAYOUT

Where the LAYOUT should be replaced with your desired keyboard layout. All available keyboard layouts can be found using the following command:

# ls /usr/share/kbd/keymaps/**/*.map.gz | less

Output:

Setting Keyboard Layout in Arch Linux
Figure: Setting Keyboard Layout in Arch Linux

For example, to set the keyboard layout to sun-pl as shown in one of the rectangles in the above figure, you will be using:

# loadkeys sun-pl

3.2 Connect to the Internet

By default, The Live Environment supports both Ethernet and Wi-Fi (wireless using iwctl).

Alternatively, You can use USB Tethering to connect through your smartphone. Just connect your USB cable, activate tethering from your phone, and that’s all.

Now, verify that the internet is working using the ping command:

# ping google.com

3.3 Update the System Clock

# timedatectl set-ntp true

Now check if this is updated using timedatectl status:

# timedatectl status

Sample Output:

               Local time: Wed 2021-12-22 14:52:32 UTC
           Universal time: Wed 2021-12-22 14:52:32 UTC
                 RTC time: Wed 2021-12-22 14:52:32
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Now that you have configured your Live Environment, you will use it to format, partition, and mount your hard disk (or SSD).

4. Partition, Format and Mount Your Drive

You will need to partition and mount your disk according to the following Partition Table:

Mount PointPartitionPartition TypeSuggested Size
[SWAP] (optional)/dev/swap_partitionLinux swapAt least 512 MiB; recommended – 1.5 times the size of your RAM
/mnt/boot/EFI /dev/efi_system_partitionEFI systemAt least 260 MiB
/mnt/dev/root_partitionLinux filesystem (/)The remainder of the device
The table was taken and modified from Archwiki

Note 1: The swap partition is a partition of your Hard Disk (or SSD) and it is basically used when your RAM runs out of space. It is also used to hibernate your laptop. But if you have RAM with higher capacity and don’t want hibernation, you can omit this.

Note 2: Instead of a swap partition, you can create a swap file.

Note 2: EFI partition is not needed for BIOS-based systems.

4.1 Partition Your Drive

To partition your disks, you can use the following fdisk command:

# fdisk /dev/disk_to_be_partitioned

Another such partitioning utility is parted.

But, I will recommend cfdisk which I find the most user-friendly among all three. Find your drive using lsblk --path. Then use cfdisk over it. For example:

# cfdisk /dev/sda

If you are asked about the label type, choose GPT which is the most suitable type for UEFI systems. For BIOS, choose DOS (also called MBR).

 Choosing GPT for UEFI in cfdisk
Figure: Choosing a label type in cfdisk

Your Screen might look like this:

Figure: Using cfdisk to partition the drive

To create the root partition, select the Free Space and the New button shown at the bottom using the arrow keys. Hit Enter. Then it will ask you the size of this partition. After choosing the size, the type ‘Linux filesystem’ will be assigned automatically.

To create the swap partition, follow the same method as above. One extra step will be to change the type to ‘Linux swap’ using the Type button shown at the bottom:

 Using Type button shown at the bottom to create Swap Type
Figure: Using Type button shown at the bottom to create Linux swap type

Similarly, for UEFI, you need to create the EFI partition with the appropriate size and type.

At the same time, if your computer already had the EFI partition, you should use that instead of creating a new one. For example, if you are planning to install Archlinux alongside Windows, you will be using the EFI partition created by Windows.

After partitioning the drive, use the Write button which will write everything to your drive. Do it at the very end after confirming everything. Now you need to format these partitions.

4.2 Format the Partitions

Format the root partition with ext4:

# mkfs.ext4 /dev/root_partition

Make the swap partition using mkswap:

# mkswap /dev/swap_partition

For the newly created EFI partition, format it into fat32:

# mkfs.fat -F 32 /dev/efi_system_partition

4.3 Mount the partitions

Now, you need to mount all the partitions as given in the above Partition Table:

# mount /dev/root_partition /mnt

The swap partition is not mounted anywhere. Instead, it is enabled using swapon:

# swapon /dev/swap_partition

After that, mount your EFI partition:

# mkdir /mnt/boot/EFI
# mount /dev/efi_system_partition /mnt/boot/EFI

Now that you have mounted all your partitions, you will be installing your Arch Linux on them.

5. Install Basic Arch Linux

Here, you cannot use pacman because that will install the packages only into the Live Environment instead of the mounted partitions. Instead, use pacstrap:

# pacstrap /mnt base linux linux-firmware nano networkmanager man-db man-pages texinfo sudo
PackageApplication
baseminimum package set to define basic Arch Linux installation
linuxthe Linux kernel; alternatively, use linux-hardened (security-focused), linux-lts (stability focused), linux-zen (performance-focused such as gaming)
linux-firmwareaccording to Gentoo, linux-firmware contains proprietary drivers for some hardware (like AMD and Nvidia cards)
nanotext editor; alternatively use vim or emacs.
networkmanagernetworkmanager provides network management tools like nmcli, nmtui, and a daemon
man-db and man-pagesman-db and man-pages provide man pages
texinfotexinfo provides info pages
sudosudo gives certain users the power to run administrative commands
Table: Packages and Their Applications

After the basic installation of Arch Linux, you need to configure it as given below.

6. Configuration of the Arch Linux

6.1 Generate a Fstab File

In the previous steps, you mounted your partitions in the hard disk manually. The fstab file enables your computer to mount all the partitions without human intervention during boot. To create it, use genfstab:

# genfstab -U /mnt >> /mnt/etc/fstab

6.2 Change the Apparent Root

Now, make /mnt your apparent root directory by using arch-chroot:

# arch-chroot /mnt

The prompt changes from root@archiso ~ # to [root@archiso /] #

This enables you to use pacman to install any package on your hard disk. You don’t need pacstrap anymore. The same argument goes for any other command given below.

6.3 Set Your Time Zone

Find the (Time Zone) TZ using tzselect:

# tzselect
 Use tzselect to find the Time_Zone
Figure: Use tzselect to find the TZ

Now, use the above value of TZ and create a symlink using ln:

# ln --symbolic --force /usr/share/zoneinfo/TZ /etc/localtime

So, for TZ=’Europe/Paris’:

# ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime

After setting your time zone, set the hardware clock from the system clock as given below.

6.4 Set the Hardware Clock from the System Clock

ClocksDescription
Hardware ClockThe Hardware Clock is also known as CMOS clock, BIOS clock, and Real-Time Clock (RTC); runs even when the machine is powered off.
System ClockThe System Clock runs only when Linux is running.
Table: Hardware and System Clocks in Linux.

To set it use hwclock – an administration tool for these clocks:

# hwclock --systohc

6.5 Localization

You need to uncomment appropriate locales from a file /etc/locale.gen. For the English language and minimal complexity, uncomment en_US.UTF-8 UTF-8:

# nano /etc/locale.gen

Now, use locale-gen to generate locales based on the above file:

# locale-gen

Please notice that each locale in the above file /etc/locale.gen comprises two items separated by space. Now, set the LANG variable equal to the first of these two items:

# echo LANG=en_US.UTF-8 > /etc/locale.conf

Similarly, you need to set the KEYMAP variable in /etc/vconsole.conf. The value of this variable would be the keyboard layout set above in the Live Environment. This is done to set your keyboard layout permanently. Skip this step for the US layout.

# echo KEYMAP=YOUR-LAYOUT > /etc/vconsole.conf

6.6 Set Up Your Network

Create a short and memorable hostname (for example, thinkpad) for your computer. This is done by writing your hostname into /etc/hostname. This name will be used to identify your computer in your home network. I have set it to ‘thinkpad’:

# echo thinkpad > /etc/hostname

Now, you need to map a few IP addresses with their hostnames in a file /etc/hosts. Just put the following lines in this file:

127.0.0.1        localhost
::1              localhost
127.0.1.1        HOSTNAME

Few points to note in the above example:

  1. Replace HOSTNAME with your hostname. For the example mentioned above, it is ‘thinkpad’.
  2. If you have permanent ip address, use that instead of 127.0.1.1 in the third line.
  3. You can even use this mapping to ban unwanted websites such as po*n sites.
  4. For more information, look up manpage – man 5 hosts.

Now, enable the NetworkManager using systemctl:

# systemctl enable NetworkManager

6.7 Set Up User Accounts

First of all, set a password for the admin (i.e. root) account using passwd:

# passwd

Secondly, add a non-root user (for example, mcloven πŸ˜€) using useradd:

# useradd --create-home mcloven

Here, --create-home creates a home directory for the user. It will include Downloads, Documents, Music, Videos, .config, and other directories.

Now create a password for this user using passwd. My recommendation would be to use the same password for both root and non-root users for easy maintenance of your personal computer.

# passwd mcloven

Add this user to the following groups using usermod:

# usermod --append --groups wheel,audio,video,optical,storage mcloven

Here, the user is being added to the audio, video, optical, and storage groups to provide the user special privileges to operate on audio, video, optical, and storage devices respectively. To find a list of other such groups, follow this archwiki link. Similarly, the wheel group provides the power to use the sudo commands.

6.8 Configure Sudo

After adding the user to the wheel group, you need to edit sudo’s configuration file i.e. /etc/sudoers. You cannot edit this file directly. Instead, you need to use visudo command:

# EDITOR=nano visudo

Now uncomment %wheel ALL=(ALL:ALL) ALL to allow members of the group ‘wheel’ to execute root commands. They will still need to prepend the commands with sudo and enter their own passwords.

Or, uncomment %wheel ALL=(ALL:ALL) NOPASSWD: ALL. It is just like above but here no password will be asked. 

Personally, I will go with the first one for security reasons.

πŸ™‚ Fun Point: EDITOR=nano is prepended. The reason is the same as that in the crontab command.

6.9 Grub Bootloader

Grub is one of the best bootloaders. Most of the online tutorials are based on the grub. Systemd also provides a boot loader but that is very basic. Hence, I will be covering grub in this article. For this, install grub and related packages:

pacman -S grub os-prober efibootmgr mtools dosfstools
PackageApplications
os-prober os-prober is needed to detect other Operating Systems.
efibootmgrefibootmgr is used to write boot entries for UEFI (unnecessary for BIOS).
dosfstoolsdosfstools provides FAT utilities (mkfs.fat, fsck.fat and fatlabel) for FAT-formatted EFI partitions.
mtoolsmtools is used to access DOS disks.
Table: Packages and Their Applications

Now, for UEFI, execute the following grub-install command:

# grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck

And, for BIOS, it should be the following (please note the /dev/sdX; it is not /dev/sdX1 …):

# grub-install --target=i386-pc /dev/sdX

Here, the --target flag is used to tell the grub about the target platform.

After the grub-install command, you will need to generate grub’s configuration file using the grub-mkconfig:

# grub-mkconfig --output=/boot/grub/grub.cfg

If you get the message ‘Warning: os-prober will not be executed to detect other bootable partitions’, then uncomment/add the following line in the file /etc/default/grub and re-execute the above command.

GRUB_DISABLE_OS_PROBER=false

Now that you have finished configuring your Arch Linux, you need to reboot by following the next step.

6.10 Reboot

Before restarting your computer, first exit from the chrooted environment using exit:

# exit

This will put you back into the Live Environment. From the Live Environment, unmount all the previously mounted partitions using the umount:

# umount --lazy /mnt/boot/EFI
# umount --lazy /mnt

After unmounting all the partitions, shut down the computer using:

# shutdown now

Now remove the Bootable USB drive from your computer and start your computer. When you start the computer, you will be prompted for a user and its password. Use either root or mcloven.

πŸ“”Note: if while booting, you other OS such as Windows is not being shown, boot into the new linux installation and rerun the grub-mkconfig command shown above.

7. Install Microcodes

Install amd-ucode or intel-ucode for AMD or Intel CPUs respectively. These are microcodes and are used to improve system stability. If you are installing Arch Linux on a removable disk, you need to install both.

# pacman -S amd-ucode intel-ucode

After installing the above microcodes, regenerate grub configuration files using grub-mkconfig:

# grub-mkconfig --output=/boot/grub/grub.cfg

That’s all. The installation of Arch Linux is complete. But to have support for Graphical User Interface (GUI) applications, follow the next heading.

8. Support for GUI Applications

You need 3 packages in general:

  1. A “display server” (example – xorg-server)
  2. A “login manager” also known as “display manager” (example – lightdm and sddm). It will provide a nice login window. Alternatively, use xorg-xinit for minimal setups.
  3. “Desktop environment” (example- gnome-desktop and xfce4) or “window manager” (example- i3-gaps and openbox).

Instead of xorg-server, you can install a package group called xorg which includes not just the xorg-server but other packages as well. This is better if you are a beginner and want to avoid further complexities:

# pacman -S xorg sddm gnome-desktop

Enable the sddm using systemctl:

# systemctl enable sddm.service

Now, to improve the graphical performance, install special video drivers as well.

9. Install Video Drivers

9.1 For AMD GPUs

Install mesa, xf86-video-amdgpu, vulkan-radeon or amdvlk:

# pacman -S mesa xf86-video-amdgpu vulkan-radeon

If you are planning to run 32-bit applications like Steam to play games, you need to install these packages’ 32-bit versions as well. To install any 32-bit package in Arch Linux, you will need to enable its multilib repository by uncommenting two lines in the file /etc/pacman.conf:

/etc/pacman.conf

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

Now, install respective 32-bit packages:

# pacman -S lib32-mesa lib32-vulkan-radeon

Here,

packagesapplication
mesa and lib32-mesa3D acceleration
xf86-video-amdgpu2D acceleration
vulkan-radeon and lib32-vulkan-radeonfor Vulkan support
Table: Packages and Their Applications

To push the graphical limit even further, see AMDGPU page in Archwiki.

9.2 For Intel GPUs

# pacman -S mesa vulkan-intel
packagesapplication
mesa and lib32-mesa3D acceleration
xf86-video-intel2D acceleration
vulkan-intel and lib32-vulkan-intelfor Vulkan support

However, xf86-video-intel is buggy. Ubuntu and Fedora do not install it. Use Xorg’s built-in basic facility instead.

Extra Information: Another reason to prefer AMD hardware in Linux.

For more information, see the Intel Graphics page in Archwiki.

9.3 For Nvidia GPUs

Install nvidia, nvidia-utils, and lib32-nvidia-utils (for 32-bit support) for Nvidia drivers. If they are installed, Xorg gives them priority over built-in nouveau drivers.

# pacman -S nvidia nvidia-utils

For more information, see the Nvidia Graphics page in Archwiki.

9.4 For Virtual Box

Install xf86-video-fbdev:

# pacman -S xf86-video-fbdev

10. Way Ahead

That’s all. Reboot and then you can also say “BTW, I use arch πŸ™‚”.

But, if your system is not booting ☹️, follow these steps:

  1. Use the Live USB drive and boot into the Live Environment.
  2. Do not format your partitions. Instead mount them.
  3. Use arch-chroot /mnt command to chroot into the unbootable environment.
  4. Now, troubleshoot it using the internet.

Thank you for staying so long. If there are some mistakes or suggestions, comment below.

Further Setup:

Set a battery charging threshold on your laptop.

Install any package from AUR (ft. Yay).

Leave a Comment

Your email address will not be published. Required fields are marked *