Arch Linux basic installation - Pipe-Runner/dotfile-manager GitHub Wiki
Pre-installation
After booting from the live USB, we will be presented with a virtual zsh console as the root user.
Note: If you experience screen tearing because of Nvidia hardware, then reboot and go back to the grub screen of live USB. Select the arch linux install option and press e, now at the end of the string add nomodeset
Step 1 - Set keyboard layout (optional)
To list the keyboard layout (Won't need this as US layout works fine):
ls /usr/share/kbd/keymaps/**/*.map.gz
To change keyboard layout:
loadkeys <just-the-filename-not-path>
Step 2 - verify boot mode
UEFI ( Unified Extended Firmware Interface ) is a modern replacement for BIOS. UEFI cannot be installed and will come pre-installed with the mobo (no changes can be made). UEFI provides BIOS emulation so that old OS that expects a BIOS can also boot.
If UEFI mode is enabled on the mobo, then Archiso will boot Arch Linux accordingly via systemd-boot.
ls /sys/firmware/efi/efivars
If this directory does not exist then the system may be booted in BIOS or CSM enabled mode.
Step 3 - connect to the internet
Check available network interfaces using the following command:
ip link
LAN interface will be prefixed with
Preferably use **DHCP **for Dynamic IP.
Using LAN will not require configuration to establish connection. To check, just ping any url.
Step 4 - update system clock
timedatectl set-ntp true
timedatectl set-local-rtc 0
This will make sure system clock is in sync. We also want the hardware clock to be synced to UTC while the system clock to set time based on the time-zone we set. So local-rtc has been set to 0.
To check status use:
timedatectl status
Step 5 - partition the disks
The system will recognize storage devices and assign them as block device. These devices can read and write via buffered access.
Block devices names will start with sda/sde if they are being handled by kernel's SCSI driver subsystem. Else they will have nvme in their name if they are attached to the NVM Express slot.
To list the devices use:
fdisk -l
or
lsblk
The following partitions will be required:
BIOS with MBR (Not used in Windows anymore)
- /mnt (mount point) == /dev/sdx1 (partition) == Linux (/) (partition type)
- [SWAP] == /dev/sdx2 == Linux Swap == >512MB
UEFI with GPT (recommended)
- /mnt/boot or /mnt/efi == /dev/sdx1 == EFI system partion (ESP) == 260-512MB
- /mnt == /dev/sdx2 == Linux (/)
- [SWAP] == /dev/sdx2 == Linux Swap == >512MB
Note: As I am going to dual boot with windows (Windows being installed first), an additional EFI partion is not required as windows will have already created one. I will just have to mount this partition when the linux installation asks me to. Also it is important to keep in mind that we need to use whatever windows is using for installation, ie. UEFI on GPT (partition table) partitioned disk.
Note: On a fresh install where EFI partition has not been created already, allot 500MBs to it, and the rest to root. Add swap if needed.
cfdisk
Note: If you are using NVMe SSD drives, then you'll have to specifically mention that with cfdisk.
cfdik /dev/nvmenx
Step 6 - Format each partition
If the EFI partition was created by windows, then it should not be formatted again. If it was created by us, then it must be formatted to the **ExFAT **file system.
mkfs.fat -F32 /dev/sdax
The rest of the partitions need to be formatted to **ext4 ** file system.
mkfs.ext4 /dev/sdax
For swap space:
mkswap /dev/sdax
swapon /dev/sdax
Step 7 - Mounting the filesystem
If we are making just one root directory:
mount /dev/sdax /mnt
If we are creating a separate partition for home then we need the following command:
mkdir /mnt/home
mount /dev/sdax /mnt/home
Installation
Before making use of pacstrap, it is important that we rearrange the mirror list to give priority to the geographically closer servers. For this, edit the file:
vim /etc/pacman.d/mirrorlist
Note: Use this if you are in India https://www.archlinux.org/mirrorlist/?country=IN
Step 1 - Installing essential packages
We make use of the pacstrap script to get all the essential packages needed for the system to work. It needs to know where to install these packages, so we need to install them in the root directory. The packages that we are going to install are (This does not include all the packages available in the live USB):
- Arch base package
- Development tools like make, autoconf etc.
- Linux kernel (optional)
- Firmware for common hardware (optional)
pacstrap -i /mnt base base-devel linux linux-firmware vim
If screen tearing was experienced, then add nvidia to the list as well.
Note: More packages can be installed right now, or after chroot setup using pacman.
Step 2 - Configure system
While partitioning the drive, we manually mounted the file system on their respective partitions but after the installation completes and the system reboots we want Arch to know these file system mounts. For that to happen, we need to write a File system table that will be used to mount the file system automatically while booting. Write the file system table file in /mnt/etc/
genfstab -U /mnt >> /mnt/etc/fstab
Then we need to enter our new system using the arch-chroot script
arch-chroot /mnt
Adjust the local time by creating a symbolic link to the correct timezone:
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
To adjust the system clock (assuming hardware clock is set to UTC) the following command generates /etc/adjtime:
hwclock --systohc
To generate locale:
vim /etc/locale.gen
and uncomment 2 lines of en.US followed by
locale-gen
As I have not made any keyboard layout changes, so I don't need to make further changes for it to persist after reboot.
Step 3 - Network configuration
Set up host name:
vim /etc/hostname
Add a nice hostname for the machine
Make necessary changes to the etc/hosts to reflect these changes:
vim /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname
Step 4 - Initialize file system for RAM
This step is optional as pacstrap runs this step by default while installing the linux kernel.
Step 5 - Enable the network manager
We need a network manager to connect to the network when we reboot next time and we want the system to do that automatically. We will have to install a network manager first.
pacman -S networkmanager
Enable the deamon to start on every boot using systemd.
systemctl enable NetworkManager.service
Step 6 - Set a root password
passwd
Step 7 - Install and configure the boot manager
pacman -S grub efibootmgr
Note: If we are dual booting with windows, windows will have created the EFI partition already. Just mount that partition on boot/efi so that we can add grub entries.
mkdir /boot/efi
mount /dev/sdax /boot/efi
Note: Some unofficial docs will suggest mounting the ESP on /boot but this will unmount the contents that already exist in boot. These contents are necessary for grub to identify arch as an OS. So we are treating /boot/efi as the ESP and the following commands work on that assumption.
Now we can direct grub-installer to install grub on this partition and add itself as a boot manager.
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
For dual booting with windows
Now if we are planning to dual boot with windows. Mount the C: drive of windows in /win10. This will be needed for grub to identify Window's bootmanager and list it in its menu.
pacman -S os-prober
mkdir /win10
mount /dev/sdax /win10
Step 8 - Generate grub config file
grub-mkconfig -o /boot/grub/grub.cfg
Note: If everything has been done correctly, the output of the command will show that grub has detected both windows and linux.
Creating a new user
This steps includes installing the sudo application, and adding a new user.
pacman -S sudo
visudo
This will open the /etc/sudoers file using the vi editor. Here we are supposed to uncomment the following line to allow the wheel group to execute any command provided a password is given.
%wheel ALL=(ALL) ALL
Adding a new user
useradd -m -G wheel -s /bin/bash new_user_name
This will create a new user with the name new_user_name. After this, we have to set a password for this user.
passwd new_user_name
Finally
exit
reboot