This blog post is about installing Arch Linux on a PC. You can follow these steps to install the OS on a MBR PC. These instructions are compiled from my personal experience with the installation.
-
Download arch linux ISO from the official website.
For the sake of this installation, we assume the downloaded file is at home/user/Downloads/archlinux-2020-x86_64.iso
-
Change to the superuser account. This will make the installation process easy.
sudo su
-
Connect the flash drive to your USB port and see the USB port address by using the command lsblk
For the sake of this installation, we assume the flash drive is at /dev/sdc
-
Write the iso file to the flash drive
dd if=/home/user/Downloads/archlinux-2020-x86_64.iso of=/dev/sdc status="progress"
-
Reboot the PC and boot from the flash drive.
- Switch to super user so you can easily do everything without typing sudo
sudo su
-
Check whether the system is booting through MBR.
ls /sys/firmware/efi/efivars
This command will not show any folder by this name is the system is on MBR.
But the folder will be there is the system is on UEFI. In that case, go to the motherboard settings and change the system to MBR.
-
Check whether the internet conneciton is working by pinging to google.
ping google.lk
If it is not working, you can use wifi-menu to setup wifi.
If wifi is not working at all, try connecting through an ethernet cable.
-
Get time and date from NTP (Network time protocol)
timedatectl set-ntp true
-
Check the partitions and hard disks by typing lsblk
Assume that you get a partition list like this:
/dev/sda
/dev/sd1
/dev/sd2
/dev/sdb
/dev/sd3
/dev/sd4
Here, sda and sbd are hard disks or pen drives. sd1 and sd2 are partitions of sda. sd3 and sd4 are partitions of sdb.
- If you want to change the partitions in the hard disk sda
fdisk /dev/sda
-
We are going to assume that 3 partitions are being used for the installation. sd1 for / (root director, where everything is installed), sd2 for /home (the home directory for user files) and sd3 for swap.
-
Format the partitions. It is advicable to format all partitions for storing files as ext4 and the swap partition as swap.
mkfs.ext4 /dev/sd1
mkfs.ext4 /dev/sd2
mkswap /dev/sd3
-
Make folders to mount the partitions. We can send the / partition to /mnt (/mnt folder is already there).
mount /dev/sd1 /mnt
-
We need a folder for /home partition.
mkdir /mnt/home
mount /dev/sd2 /mnt/home
-
Install the base of arch-linux along with some important packages (linux-firmware is used for wifi and other drivers, base-devel has compilers for software development, vim and nano are useful text editors.)
pacstrap /mnt base linux-lts linux-firmware base-devel vim nano
- Save the file system table by UUID
genfstab /mnt -U >> /etc/fstab
-
Until now, you are working on the OS on the flash drive. We have to change the root to the hard disk OS, which is at /mnt
arch-chroot /mnt
-
Install NetworkManager and enable the auto start. This is useful for internet connections.
pacman -S networkmanager
systemctl enable NetworkManager
-
Install grub (which is the software that can create a bootloader that boots up archlinux and other operating systems). Please note that this step does not create the bootloader.
pacman -S grub
-
Since we are using sda hard disk for the computer, we have to install a bootloader on sda.
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
-
Add a sudo password for admin access
passwd
-
Set up the locale. We pick en_US here. First, open the locale file by nano text editor.
nano /etc/locale.gen
You have to uncomment the following two lines (remove the HASH)
en_US.UTF-8 UTF-8
en_US ISO-8859-1
Save the file by pressing CTRL + X and Y.
Now, generate the locale
locale-gen
-
Add the language to locale.conf file. First open it by nano text editor.
nano /etc/locale.conf
Add the following line
LANG=en.US.UTF-8
Save the file by pressing CTRL + X and Y.
-
Find your timezone name. If you are in Asia you have to first run
ls /usr/share/zoneinfo/Asia/
Then make a symbolic link from YOURTIMEZONE to /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/YOUR_TIME_ZONE /etc/localtime
-
Put a name for your PC
.
First open the /etc/hostname file in nano text editor
nano /etc/hostname
Then type the name in the file. Close the file by saving CTRL+X and choose Y
-
Create a user account for you. Assume that your name is abcxyz
useradd abcxyz --home /home/abcxyz
-
It is good to add abcxyz user account to SUDO users (so you can use the sudo command from this account).
[To be added]
-
Unmount the pen drive
umount –R /mnt
-
Exit chroot since you need to go back to the OS on the pen drive to reboot.
exit
-
Reboot the system (remove the pen drive before your system boots again)
reboot
-
To be continued......
[Written on : 8th July, 2020. Last edited : 17th Feb, 2021]