Arch Linux installation guide

Arch Linux installation guide

This guide walks you through installing and setting up Arch Linux from scratch like a pro

Arch Linux is yet another Linux distribution that follows the simple KISS principles which makes it very minimal. The image size of Arch Linux is just aroud 850 MB whereas other full setup Linux distributions are over 2 GB.

The minimalism of Arch Linux also means it is lightweight so good for low-end computers and faster in performance as there are not so many programs by default.

Now let’s install Arch Linux

Step 1: Download the Arch iso

The iso is the image of Arch Linux which you need to download and flash it in a USB.

Head over to archlinux.org/download.

Now there are so many ways to download the iso and you might get overwelhmd. But don’t worry I’m here to help 👮‍♂️.

If you have torrent

Then click on the Torrent for date link

If you just want to download from the web

  • Then scroll down and you will find mirrors all around the world.

  • Click on any link which is under the country of yours. It will open a new page and there will be so many links.

Don’t panic

  • Click on the link that says archlinux-year.month.day-x86_64.iso.

  • Also you can download the archlinux-year.month.day-x86_64.iso.sig. This is the signature key which will assure that the iso is valid and not modified.

But you really don’t need to verify as all mirrors are well trusted.

Step 2: Create the installation medium

Now you need to put the iso into a USB stick. I’ll tell you how to create a bootable medium on Windows or MacOS or Linux.

If you’re on Windows

  • Download and install Balena etcher.

  • Open etcher and select the just downloaded iso.

  • Insert a USB stick but make sure that it is atleast 8 GB in size.

  • Click flash it.

NOTE: Flashing will entirely delete all the data in the USB stick. So if you have something important, back it up first.

And that’s it, your live bootable USB stick is read 🥳️.

If you’re either on MacOS or Linux

You can do the same steps as mentioned for Windows but as both Mac and Linux are based on UNIX OSs and you’re also going to install Linux (which is almost like UNIX), I recommend to get familiar with the commandline at the beggening.

  • Plug the USB stick in

  • Open a terminal

  • Type lsblk and hit Enter/Return. There you can see some data on a table like format. Like this:

~ $ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   500M  0 part /boot/efi
├─sda2   8:2    0     4G  0 part [SWAP]
├─sda3   8:3    0    30G  0 part /
├─sda4   8:4    0   200G  0 part /home
└─sda5   8:5    0   150G  0 part
sdb      10:0   0  62.3G  0 disk
├─sdb1   10:1   0  200M   0 part
└─sdb2   10:2   0  52G    0 part

These are the disks your computer have. Now focus on the SIZE column and look for if the sizes matches or closer to the actual size of you USB stick.

For example, my USB is 64 GB and sdb is the closest to that size so that’s the block device name of my USB stick.

If you’ve noticed it, note it’s NAME.

NOTE: The NAME may not be sdb for you. It depends on which type of disk you have. For HDD and SSD it’s sd[a-z] where sd means solid disk and [a-z] is the alphabetical order. It can also also nvme[a-z] if you have a NVME disk installed.

After that use this comman below to flash:

dd if=/path/to/file.iso of=/dev/BLOCK_NAME status=progress

We have used the dd command which is responsible to write data from one file to other.

Now type the path to where is the iso file located as the if (input file) parameter.

And type the name of the block device as the of (output file) parameter.

Lastly, status=progress is to tell the dd command that we want to see a progress while flashing the iso to the drive.

Wait until the flashing is done and now you have succesfully made a bootable live USB stick.

Step 3: Boot it with Live USB

Poweroff your computer and boot in bootloader menu. This can be done by pressing some keys of combinations. Now typically each manufactures have different key combinations to boot.

Basically you have to power the computer on and as soon as the brand logo appears, continously press the keys to boot.

You can easily find out in Google which key combination is needed to boot to boot menu.

  • For Lenovo computers: press windows + F12
  • For Dell computers: press windows + F10

After booting to boot menu

In the boot menu there will be some boot options, you have to look for which says USE: Drive USB and select it by pressing the arrow up/down keys and press enter to boot.

In the live ISO

After booting into the live iso you will get a black screen white some text or options. Select the first option (it will be automatically selected) hit enter.

Wait until it loads, those text are logs saying what is actually being done.

Connect to the internet

When you are on the terminal the first thing you do is to connect to the internet.

Ethernet connection

If you have an ethernet connection then you don’t have to do anything, you’re already connected.

Check if you’re online or not by doing ping google.com, if you see some data are written every after 1 second or 2 then you are good to go.

Wifi connection

Conneciton to Wifi is a bit tricky. Here are the following steps to connect to Wifi.

  1. Your wifi card would propably blocked so you have turn it on by doing rfkill unblock wlan0. Where wlan0 is the name of the Wifi card in Arch Linux.

  2. Now link up you IP by doing ip link set wlan0 up.

  3. Use the iwtcl to scan Wifi and connect.

iwtcl device scan
iwtcl station get-networks

You will see all the available Wifi networks, Find the name of your Wifi and do the next step.

  1. iwctl station connect *wifi_name*. Change wifi_name to your name of the Wifi. Now you surely have a password set to connect, iwctl will ask you to enter your password in the passphrase section. Simply enter your password and hit enter.

  2. Do ping google.com to check if you’re connected or not.

  3. Lastly if you’re connected enter dhcpcd wlan0 --nohook mtu to stay connected or your connection may get closed by rfkill again.

Your full commands will look like this:

rfkill unblock wlan0

ip link set wlan0 up

iwtcl device scan
iwtcl station get-networks
iwctl station connect wifi_name

dhcpcd wlan0 --nohook mtu

After sucessfully connected to the internet, it’s time to partition the disk.

Partition the disk

This is the most important step than all the other steps. You have to be very carefull while doing this step.

Type lsblk to list all the block devices, which we did while flashing the iso to the USB stick.

  • Now select your disk where you want to install Arch Linux.

  • If that drive has partitions, then delete all the partitions one by one, by selecting them and pressing d.

  • After deleting all partitions you will have one partition named as Free space.

Partitions you will need

While installing Linux it is always recommended to have multiple partitions. Here is my best strategy to create the perfect partitions.

PartitionNameSizeTypeMount point
/dev/sda1Boot512MEfi System/boot/efi
/dev/sda2Swap2GSwapNONE
/dev/sda3Root30GLinux root (x86-64)/
/dev/sda4HomeRemainingLinux file system/home

This is the perfect file system for any Linux distribution. Every important partitions are separated so there is very very low chance for a system break.

Now create the partitons as the above table:

  • Press n to create a new partition and give the size as mentioned
  • Press t to select its type as mentioned

After creating all the partitions like the table press w to write, type yes to confirm.

Format the partitions

Now it’s time to format them to create file systems. Here are some details of formatting partitions.

  • The Boot partition must be formatted with fat32 file system.

  • The Root and Home partitions can be in any file systems but ext4 is highly recommended.

Now let’s format them. Below the -L flag means label.

Format the /dev/sda1 (Boot)

mkfs.fat -F 32 -L boot /dev/sda1

Format the /dev/sda2 (Swap)

mkswap -L swap /dev/sda2

Format the /dev/sda3 (Root)

mkfs.ext4 -L root /dev/sda3

Format the /dev/sda4 (Home)

mkfs.ext4 -L home /dev/sda4

Mount the partitions

After formatting comes mounting. You have to mount each partition and they will be mounted automatically by fstab.

While formatting we have used the -L flag to add labels. Now we can use the labels instead of /dev/sdaX.

We generally use the mnt folder located at the top of the folders.

Do the same to mount all the partitions:

# mount root first
mount /dev/disk/by-label/root /mnt

mkdir -p /mnt/boot/efi
mkdir /mnt/home

# mount boot
mount /dev/disk/by-label/boot /mnt/boot/efi

# mount home
mount /dev/disk/by-label/home /mnt/home

# start the swap
swapon /dev/disk/by-label/swap

NOTE: While mounting, you have to mount the root first, then you can mount other partitions.

Install kernel and other packages

After mounted root and all the other partitions, it’s time for the longest part, installing packages.

As I have mentioned Arch Linux is very minimal, so minimal that it doesn’t come with a kernel or any other vital programs to run a system, we have to install them.

For kernel there are four main kernel to choose, linux, linux-lts, linux-zen and linux-hardend.

For my experience, linux-lts is the best kernel to choose.

Okay, now install the kernel and other packages:

pacstrap -K /mnt linux-lts base sudo micro grub efibootmgr networkmanager

Generate fstab data

Fstab is a file which contains data to mount your system. To generate a data file, use the command below:

gen-fstab -U -p /mnt >> /etc/fstab

Switch from live system to newly created system

Yes, generating fstab and installing kernel means your system has been created! But it’s not over yet. First switch to the new system, in Arch we call it changing root hence the command name is also same.

arch-chroot /mnt

Your prompt will change when you change root. Now do the following configurations:

Set timezone

Set your timezone for the clock.

timedatectl list-timezones

You will see a list of Country/Ciys. Now you can scroll up and down by presing Arrow Up / Down keys but the easy way is to press / and type your country name, hit enter and lines with the country you have typed will be highlited. Now just look for the city and press q to quit of it.

Then use timedatectl set-timezone Country/City, replace Country with your country and City with your city.

Setting up locale

You must set up a locale or some apps might not work probably. To set up a locale edit the /ete/locale.gen file with micro editor which we have installed while installing packages.

micro /etc/locale.gen

While you’re in the file, hit CTRL + F to open finder and type your locale. Now for American English type en_US and hit enter to seach.

All the lines are started with a # which means comment. You have to uncomment you locale by removing the # and that’s it.

Now do CTRL + S to save and CTRL + Q to quit.

I have used micro because it has very basic key bindings unlike nano which is also easy but can be difficult. At least it was difficult for me.

Generate locales

To generate locales do locale-gen and do export LANG=en_US.UTF-8.

Create hostname

Now create a hostname for the computer. A hostname is the name of you computer so you can give it any name you want (without any spaces).

echo thisPC > /etc/hostname

I gave a my computer’s name thisPC

Also create a DNS host file for networking too.

micro /etc/hosts

Put the following same as below:

127.0.0.1 localhost
::1 localhost
127.0.1.1 thisPC.localdomain localhost

NOTE: The last line it must be the same name which you’ve written in /etc/hostname file.

Remember we downloaded networkmanager while installing the packages? Now it’s time to enable it too.

systemctl enable NetworkManager

From now on, Network Manager will manage all the networking.

Create home and root user

The root user would have all priviliges which is not good to have all the priviliges all the time so we will also create a home user.

The home user have to enter for password everytime they need admin priviliges.

Now the root user is already created by default, you just have to set a passwod.

Set password for the root user

passwd

Enter a super secured password and repeat the secured password to complete.

Create a home user

To create a home user:

useradd -m username

username should be small cpas and no spaces.

Add the user to some important groups.

# Must add to the **wheel** group
usermod -aG wheel,audio,network username

Groups are the rights for specific commands or utilities. The sudo user has rights of all the available by default but not the home user so you have to add it by yourself.

Now create a password for the home user, password for the home user should be different from the root user.

passwd username

Enter a strong and complicated and repeat the strong and complicated to complete.

Now the home user does not have rights to use sudo command. To change this do micro /etc/sudoers to edit the sudoers file.

Again press CTRL + F to find and type wheel, hit enter.

Uncomment (remove the #) from the line where saying %wheel ALL=(ALL:ALL) ALL

CTRL + S to save followed by CTRL + Q to quit out of micro.

And all the needed configurations are done! Last is to install a bootloader.

Install bootloader

This is the last step of the whole process. Now there are several bootloaders to choose. For the most convinient, Grub is always a popular choice.

If you’ve remembered we have already installed grub while installing kernel. So we just have to create the bootloader.

grub-install --target=x86_64-efi --bootloader-id='Arch Linux' --efi-directory=/boot/efi

# Then create the config
grub-mkconfig -o /boot/grub/grub.cfg

--efi-directory will be where we created and mounted the boot partition.

Congragulations! You have successfully installed Arch Linux through the commandline. 🥳️

Unmount partitions and reboot to enjoy

Now all is left to do is to unmount as we are currently in the newly created system.

  • Press CTRL + D quite a few times until you see the old prompt which was before changing root.

  • Do umount -R /mnt to unmount all the partitions on the /mnt folder.

  • Do reboot to reboot to your newly created Arch Linux system.

More from linux