Installing Arch linux: Part 1

Installing Arch linux: Part 1


Arch Linux is a general purpose GNU/Linux based operating system which follows the rolling release model, which keeps the system up-to-date with the latest software. The design approach of Arch Linux is based on KISS Principle(Keep It Simple, Stupid) which focuses on elegance, code correctness, minimalism and simplicity, and expects the user to be willing to make some effort to understand the system’s operation. More information can be found on the Wikipedia page. Without further ado, lets get started.

Create a bootable Installation medium

I would personally recommend grabbing a USB pendrive, minimum 1 GB of size. Download the latest Arch Linux ISO file. Then, create a bootable USB drive with the following command:

1
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdX status=progress oflag=sync

Remember to replace X with your device ID and Do not append partition number to the command. You can list available device using fdisk -l command.

Boot into the installation medium

After successfully creating the bootable drive, boot into the USB. You will be automatically logged into the root account of archiso. Follow the steps below to proceed with the installation:

Connect to the Internet:

Assuming you are on a UEFI based system[^1], connect to the internet. If you have a LAN connection, you can skip this step. Otherwise, you can connect to your wireless network using:

1
wifi-menu -o

Test the connection using ping archlinux.org command.

Update system clock:

1
timedatectl set-ntp true

Partition disks:

fdisk provides a great interface for this purpose. Identify your hard drive on which you wish to install Arch Linux using fdisk -l and partition that drive using the following command:

1
fdisk /dev/sdX

Remember, you should’nt include any partition number as mentioned earlier. This command will take you to the fdisk shell. Type m to view help. More information can be found here.

Minimum two partitions are required, one for EFI System Partition with mount point /boot, whereas the other for the root partition with mount point /. If dual-booting Arch Linux with Windows, please see [^note]. A swap partition is optional, but recommended. You can refer to this table for deciding on the size. A swap file is more flexible way of creating this. We will cover the creation of swap file in the upcoming sections.

Format the partitions:

Ext4 is a stable and reliable filesystem. To format your partitions with ext4, run the following command, replacing N with the partition number:

1
mkfs.ext4 /dev/sdXN  # Replace X with device number and N with partition number

We will create and mount the swap file during mounting stage.

Mount the filesystems:

First, mount your root partition to /mnt:

1
mount /dev/sdXN /mnt

Next, create a boot folder inside /mnt to mount the EFI System partion:

1
2
mkdir /mnt/boot
mount /dev/sdXN /mnt/boot

Follow the same steps for any other remaining partitions. For example, if you wish to mount another partition to /home, just run:

1
2
mkdir /mnt/home
mount /dev/sdXN /mnt/home

Remember to substitute the appropriate values for X and N.

Finally, create the swap partition and mount it[^2] :

1
2
3
4
fallocate -l size /mnt/swapfile
chmod 600 /mnt/swapfile # Set appropriate permissions
mkswap /mnt/swapfile # Format as swapfile
swapon /mnt/swapfile # Activate the swap

where size can be 512M for 512 MB, 2G for 2 GB and so on.

Installing base system:

Simple run the following to install a working base system:

1
pacstrap /mnt base base-devel

Configuring base system:

Fstab:
1
genfstab -U /mnt >> /mnt/etc/fstab

Edit /mnt/etc/fstab to remove the /mnt entry prefixed in the swap field.

Chroot:
1
arch-chroot /mnt
Time Zone:
1
2
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc # Set hardware clock to UTC
Locale:

Uncomment required locales in /etc/locale.gen and run:

1
locale-gen

Set the LANG variable:

/etc/locale.conf
1
LANG=en_US.UTF-8

Network configuration:

Create the hostname file and matching entries in hosts:

/etc/hostname
1
myhostname

/etc/hosts
1
2
3
127.0.0.1	localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname

Install netctl dependencies and enable systemd services:

1
pacman -S dialog wpa_supplicant

If you are planning to install full-blown Desktop Environments like Gnome, KDE, skip this step, else:

1
2
3
pacman -S wpa_actiond ifplugd
systemctl enable netctl-ifplugd@interface.service # For wired devices
systemctl enable netctl-auto@interface.service # For wireless devices

You can get the interface value for respective devices by running ip addr show.

Set root password:
1
passwd
Install intel microcode firmware:
1
pacman -S intel-ucode
Install Boot Loader:

Assuming you are install Grub:

1
2
3
pacman -S grub efibootmgr os-prober
grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB # esp=EFI System Partition mount point
grub-mkconfig -o /boot/grub/grub.cfg

Reboot:

Umount all mounted partitions:

1
2
umount -R /mnt
reboot

Remove the installation media, enter your BIOS setup, make necessary changes to boot sequence, save and exit. You will now be booted into your freshly installed Arch Linux 😃

Post Installation:

Necessary configurations and tasks related to getting a working system such as creating user, installing Xorg, configuring drivers, etc will be covered in the second part of the post. Till then, stay tuned! Link to the follow-up post: Part 2

[^1]: Most of the modern systems are UEFI based.
[^2]: If you are using other filesystems except ext, please verify the compatibility of swap partition.
[^note]: For dual-booting with windows, you don’t need to create an EFI System Partion. Simply mount the Windows boot drive(generally formatted as FAT32) to /boot. Do not format this partition, else you will loose Windows boot data.




Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×