In this guide, we will learn how to install Arch Linux. This takes into assumption that you already have an Arch ISO file in your pen drive and you booted into it
using your boot menu.
Just follow the commands below, and you should be good to go. I will be explaining what those commands do, as we go.
iwctl
You can skip this step if you have ethernet. If you don't, using this command you can connect to wi-fi.
Use this syntax: station [device ID] connect [SSID]
- You can see device ID by typing in
device list
and SSID by station [device ID] get-networks
- Type 'exit'. Now, you can use the
ping google.com
command to check for responses and see if network is okay.
cfdisk
This command is used to partition your disk. We will make 3 partitions - a boot partition, a home partition and a swap partition.
- Use the arrow keys to navigate the bottom bar, and delete every existing partition. Now select a free partition, click 'new', and write
100M
and press enter.
- Do the same to another free partition, and type
4G
. This will be your swap partition.
- Now select the last free partition, click 'new', and press enter. This will be your home partition. We need not specify a size, as it will take the remaining amount.
Now select 'write', and type yes
to confirm. Now select 'quit'.
lsblk
You can use this command to list your block devices/partitions. You can see the names of your partitions here. We will use these names in the next steps.
mkfs.btrfs /dev/sda3
Verify that this partition is the one with the most size. Using this command, it will create a btrfs filesystem on the home partition.
mkfs.fat -F 32 /dev/sda1
Verify that this partition is the one with 100M size. Using this command, it will create a FAT32 filesystem on the boot partition.
mkswap /dev/sda2
Verify that this partition is the one with 4G size. Using this command, it will create a swap filesystem on the swap partition.
lsblk
You can check if your block devices are set up correctly. Now we will mount these partitions. Before that, let's see what disk paritions we have:
- /dev/sda1 - boot partition - 100M
- /dev/sda2 - swap partition - 4G
- /dev/sda3 - home partition - leftover
mount /dev/sda3 /mnt
This command will mount the home partition to the /mnt directory.
mkdir -p /mnt/boot/efi
This command creates the directory that we will mount the boot partition into.
mount /dev/sda1 /mnt/boot/efi
This command will mount the boot partition to the /mnt/boot/efi directory.
swapon /dev/sda2
This command will enable the swap partition. We don't need to "mount" this anywhere.
lsblk
We can finally check all of our mounted paritions.
pacstrap /mnt base linux linux-firmware sof-firmware base-devel grub efibootmgr nano networkmanager
This command will install the base system, the linux kernel, linux firmware, sound firmware, base development tools, grub (boot manager), efibootmgr, nano (text editor) and networkmanager (wifi and ethernet manager).
If your PC is old and struggling, you can use the 'linux-zen' kernel. Just replace linux
with linux-zen
.
This will take some time. So, go grab a coffee or something.
genfstab /mnt > /mnt/etc/fstab
This command will generate the fstab file, which contains information about your partitions, and send it over to /mnt/etc.
arch-chroot /mnt
This command will change the root directory to /mnt. Now we will configure the system.
ln -sf /usr/share/zoneinfo/[your/location] /etc/localtime
This command will set the timezone. Replace [your/location] with your location. For example, if you are in India, you will type Asia/Kolkata
. If you don't know your time zone, just press [TAB] and you'll get something.
date
This command will show you the current date and time. If you set the correct timezone, this should be right.
hwclock --systohc
This command will set the hardware clock.
nano /etc/locale.gen
This command will open the locale.gen file. Uncomment the line that corresponds to your language. For example, if you want to use English (US) you will uncomment en_US.UTF-8 UTF-8
. Save and exit.
locale-gen
This command will generate the locale.
echo LANG=en_US.UTF-8 > /etc/locale.conf
This command will set the language. Alternatively, you can do it manually by editing/creating the file. Just do nano /etc/locale.conf
.
echo [hostname] > /etc/hostname
This command will set the hostname. Replace [hostname] with your desired hostname. If you don't know what hostname is, it's basically your computer's name. Mine's called 'nerv'!
passwd root
This command will set the root password. You will be prompted to enter the password twice. MAKE SURE YOU SET A STRONG PASSWORD FOR THE ROOT PARTITION.
useradd -m -G wheel -s /bin/bash [name]
This command will add a user. Replace [name] with your desired username. This will also create a home directory for the user. We have added the user to the 'wheel' group, which will make it easier for us to set them as a 'sudoer'.
passwd [name]
This command will set the user's password. You will be prompted to enter the password twice.
EDITOR=nano visudo
This command will open the sudoers file.
- Uncomment the line that says
%wheel ALL=(ALL) ALL
.
- Save and exit.
systemctl enable NetworkManager
This command will enable the NetworkManager service, which will manage your network connections. Make sure 'N' and 'M' are capitalised.
grub-install /dev/sda
This command will install the grub bootloader to the disk. Make sure you install it to the disk (sda, sdb, etc), not the partition (sda1, sda2, etc).
grub-mkconfig -o /boot/grub/grub.cfg
This command will generate the grub configuration file. DO NOT FORGET THE "-o" PART, OR YOU WILL NOT BE ABLE TO BOOT INTO YOUR SYSTEM. I have forgotten it an embarassing amount of times.
exit
This command will exit the chroot environment and come back to the ISO user.
umount -a
This command will unmount all the unused partitions. It is normal to see "target is busy" messages here.
reboot
This command will reboot your system. Remove the pen drive and boot into your new Arch Linux system!
This way, you can install Arch into your system. After booting and logging in, make sure to connect to wi-fi usinng nmtui
(if you don't have ethernet).
If you would like a desktop environment, this is how to do it:
We will be using GNOME desktop environment for this tutorial.
- Type
sudo pacman -S gnome
and install the packages.
- Type
sudo systemctl enable gdm
to enable GDM (GNOME Display Manager) upon startup.
- Type
sudo systemctl enable --now gdm
to start GDM now. Log in, and enjoy!