Skip to content

Instantly share code, notes, and snippets.

@Rellotscrewdriver
Last active April 7, 2024 11:52
Show Gist options
  • Save Rellotscrewdriver/4553c16c95a76fa1776432fe6d3ebf5b to your computer and use it in GitHub Desktop.
Save Rellotscrewdriver/4553c16c95a76fa1776432fe6d3ebf5b to your computer and use it in GitHub Desktop.
Guide to install Arch Linux and other optional things

arch linux installation and configuring guide

This guide is mostly for beginners in a friendly guide if you want to install arch manually without the automated method and actually want to understand the commands you're running in an easier way, this guide is for both UFEI and Legacy BIOS in step 7, we will install sway which is a replacement of i3 in wayland.

Step 1: Bootstrapping


  1. get the ISO from the Arch Linux website.
  2. Once you have the ISO from your mirror of choice you should install Rufus (if you're on windows)
  3. check whether you have UFEI and BIOS(at least search how to find this, it ain't 1995), if you have BIOS, select GPT. Otherwise select MBR in the partition scheme section 3(UFEI only): if you're on UFEI, make sure to disable secure boot and fast startup
  4. then you need to open the BIOS menu when the system starts(the keys differ from motherboard manifacturer so read the manual or visit the OEM's website) and find boot disk priority and select your USB drive or put at the top and save.
  5. go and boot from your USB drive. you will be prompted to live ISO image. you will now see the commandline and this is where we're gonna put our camping here.

Step 2: Setting up Partitions


Disk Partitions

Use lsblk to check the disk drive name, in this example it is /dev/sda (You may need to check as you may not use your main hard drive, or the USB is recognised as /dev/sdb):

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 119.2G  0 disk
├─sda1   8:1    0   100M  0 part
├─sda2   8:2    0  63.4G  0 part 
├─sda3   8:3    0   512M  0 part 
└─sda4   8:4    0  55.3G  0 part 
sdb      8:16   1  14.3G  0 disk
├─sdb1   8:17   1   586M  0 part /run/archiso/bootmnt
└─sdb2   8:18   1    64M  0 part

Once you know what your drive is called, use cfdisk /dev/(drive), replacing (drive) with sda,sdb etc. I'll be using sda. Press the del buttons on any partitions you wanna get rid of.

cfdisk /dev/sda

it will prompt you to select label type, if you're on UFEI, select gpt otherwise select dos

For your SWAP partition, press new and set the partition size accordingly, I'll be using 4G. Then choose "primary".
For your boot partition, press new and set the partition size to 512M, choose primary and toggle bootable on it.
For your root partition, choose the size (i'll be using the rest of my SDD for this), and choose "primary" like how you have on both of your other partitions.
Once you have done all that, choose Write and type yes. Then choose quit.

the partition now should look like this

sda1 2GB swap partition
sda2 512MB boot partition
sda4 ---GB / partition

Activate the swap by doing:

mkswap /dev/sda1
swapon /dev/sda1

Then format the boot partition into vfat and ext4:

mkfs.vfat /dev/sda2
mkfs.ext4 /dev/sda3 

now mount the partitions

mount /dev/sda3 /mnt
mkdir /mnt/home
mkdir /mnt/boot 
mount /dev/sda2 /mnt/boot

separate /home directory (optional)

having a separate /home directory can help in if you're reinstalling your system in case of a broken system update, usually it is recommended to give 15-20GB to / partition and the rest to /home, you can still install and run arch if you don't want to create separate home directory

- sda1 2GB swap partition
- sda2 512MB boot partition
- sda3 15GB / partition
- sda4 ---GB /home partition

activating the swap and formatting into vfat and ext4 filesystem

mkswap /dev/sda1
swapon /dev/sda1
mkfs.vfat /dev/sda2
mkfs.ext4 /dev/sda3
mkfs.ext4 /dev/sda4

mounting the partitions, mount meaning connect or plugging

mount /dev/sda3 /mnt
mkdir /mnt/boot
mkdir /mnt/home
mount /dev/sda2 /mnt/boot
mount /dev/sda4 /mnt/home

Step 3: Packages, partitioning and Mirrors


connecting to the internet

you need to connect to the internet in order to install base system in the next sub-step if you're using ethernet, chances are it will be detected automatically in the live ISO. you can move onto next sub-step.
to see if you're connected, run ping -c 3 google.com
if you're on wireless network, this sub-step is for you Now start the INet Wireless Daemon(iwd).This wireless package comes pre-installed on intel based hp laptops.Not sure if it's in other laptop models. Enable and start the iwd.service

systemctl enable iwd.service
systemctl start iwd.service

Verify it has started

systemctl status iwd.service

After verifying the iwd service is running in the previous step, type iwctl to get an interactive prompt. The prompt will be displayed as [iwd]#. Here you are now interacting with the client program 'iwctl'.

list all wifi devices nearby

[iwd]# device list
                    Devices
-------------------------------------------------------------
Name           Address            Powered    Adapter  Mode
-------------------------------------------------------------
wlan0          xx:xx:xx:xx:xx:xx    on        phy0    station

Note: wireless devices usually start with letter 'w'. e.g wlan0 or wlp3s0

[iwd]# station wlan0 get-networks
                  Available networks
------------------------------------------------------------
Network name            Security          Signal
-------------------------------------------------------------
Hecker					  psk              ****
the_guy_next_door         psk              **** 

Your Network Name is also referred to as SSID technically. If you can see your network name, then type

[iwd]# station wlan0 connect <your_network_name>

substitute the above command with your network name, angle brackets excluded to connect to it. When you type the above command, for eg: station wlan0 connect guy_next_door you will be prompted for passphrase. This is nothing but you just have to type network password. Exit the iwctl client by typing exit

To use iwctl directly without entering into the prompt

iwctl --passphrase <your_network_password> station <your_interface>(usually wlan0) connect <your_network_name>

after you have the network configured, try slapping google three times to check whether your internet is working

ping -c 3 google.com

Installing the base system

optional set the mirror to the nearest ftp server to get the fastest network speed

nano /etc/pacman.d/mirrorlist

now it's time to install basic packages to get started, this might take time if you didn't select the nearest mirror

pacstrap -i /mnt base base-devel linux linux-firmware nano grub sudo bash dhcpcd networkmanager 

saving mounts permanently

now generate genfstab to permanently store mount points, otherwise they will get removed when restarting your system

genfstab -U -p /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab

make sure to check fstab file for any errors

logging into your arch

now, login into your sort-of arch

arch-chroot /mnt

Step 4: Configuration


now enable the network service

systemctl enable NetworkManager

Set the timezone

Set your own timezone, since I live in india so I would choose asia timezone here

ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
//ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
hwclock --systohc

set the time through network and check the time, if the above doesn't work

timedatectl set-ntp true
timedatectl status

Set your locale

open nano /etc/locale.gen with your favourite editor and uncomment en_US.UTF-8 UTF-8
generate a locale config file by typing:

locale-gen
echo LANG=[locale_name] > /etc/locale.conf

Where [locale_name] is the name of your preferred locale.

add multilib

open /etc/pacman.conf and uncomment the lines below

[multilib]
include = /etc/pacman.d/mirrorlist

run the command to update the repositories

pacman -Sy

Step 5: Adding a user


Adding user

open /etc/hosts in nano or vim
in place of "name", write your user account. this will be your username

127.0.0.1 name.localdomain name
127.0.0.1 cat.localdomain cat

add the user from (remember to write that username what you have written in /etc/hosts file)

useradd -m -g users -G wheel,storage,power,audio name

type your user password

passwd name

type your root password

passwd

add the computer name, it will be shown on your network

echo "computer name" > /etc/hostname

grant access to sudo

type EDITOR=nano visudo to open up the sudo editor, now you can either uncomment this line %wheel ALL=(ALL:ALL) ALL which requires you to type the password everytime you execute a command with sudo(which I recommended for beginners)

OR

uncomment this. %wheel ALL=(ALL) NOPASSWD: ALL same thing as above but without needing to type the password

Step 6: Building Kernel


Adding windows partition into the bootloader(optional)

using os-prober

download and run os-prober, this will automatically detect your windows installations

sudo pacman -S os-prober
os-prober

now uncomment this line from /etc/default/grub

GRUB_DISABLE_OS_PROBER="false"

adding the option manually

if os-prober doesn't detect your windows installation. then you can try adding it manually. then you need to add the following line to /etc/grub.d/40_custom

menuentry "Windows 10" {
insmod part_msdos
insmod ntfs
set root='(hd0,msdos1)'
chainloader +1
}

Building Kernels

now copy and paste these commands to install the bootloader:

For leagacy BIOS

mkinitcpio -p linux
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

For UFEI

mkinitcpio -p linux
pacman -S efibootmgr
grub-install --target=x86_64-efi --efi-directory=/boot/efi /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Type: exit then umount -R /mnt then reboot. Once you've done that, remove your USB and now you have a working install of Arch Linux!

installing AUR (optional)

Yet Another Yogurt - An AUR Helper Written in Go which can help you to build packages from source and install it via pacman

install git if you haven't done that

sudo pacman -S git

make a directory source and go inside the source directory

mkdir Sources
cd Sources

clone the aur repo

git clone https://aur.archlinux.org/yay.git

change directory and bulid it

cd yay
makepkg -si

Step 7: Installing a window manager


installing sway

install sway which is the window manager for wayland

sudo pacman -S sway swaybg swayidle swaylock

then type sway and it should launch sway

installing hyprland

install hyprland

sudo pacman -S hyprland

then type Hyprland it should show you the screen

installing video drivers

type: sudo pacman -Ss xf86-video for a full list of video drivers if you aren't using nvidia, amd or intel gpu

for nvidia drivers

Nvidia open-source drivers:

sudo pacman -S xf86-video-nouveau

Nvidia's properietary drivers:

sudo pacman -S nvidia nvidia-utils

for amd drivers

pacman -S xf86-video-amdgpu mesa

After installation enable the modules in configuration of Mkinitcpio. Open for this /etc/modprobe.d/modprobe.conf

Add the amdgpu driver in modules variable: MODULES=(amdgpu)

Build now your kernels

mkinitcpio -P

Set the kernel parameter for SI/CIK Graphicscard support.

radeon.cik_support=0 amdgpu.cik_support=1    
radeon.si_support=0 amdgpu.si_support=1 

In addition, you can enable overclocking features with:

amdgpu.ppfeaturemask=0xfffd7fff or amdgpu.ppfeaturemask=0xffffffff 

depending on the card. Save the changes and update grub.

reboot

for intel drivers

just install this driver and you're ready to go!

sudo pacman -S xf86-video-intel

configuring audio

install alsa

sudo pacman -S alsa-firmware alsa-lib alsa-utils

configure the audio

aplay -l && lspci | grep -i audio && ls -l /dev/snd/
alsamixer -c 1

test the audio

speaker-test -c 2

Now you can finally reboot and start your journey to join the unixporn community!!

Credits

  • hazel0177 for making the guide which helped me installing arch on my old-ass PC with an SSD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment