Skip to content

Instantly share code, notes, and snippets.

@L04DB4L4NC3R
Created May 16, 2020 13:10
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save L04DB4L4NC3R/90c63f222620758cc069f36ae7354375 to your computer and use it in GitHub Desktop.
Save L04DB4L4NC3R/90c63f222620758cc069f36ae7354375 to your computer and use it in GitHub Desktop.
ArchLinux Standard Installation

Installing Arch the Standard Way


Create a bootable pendrive

Run lsblk to see what is your pendrive

dd if=<path to arch iso> of=/dev/sd<letter> status="progress"

Boot from USB

Press F12 (or F8 on some machines) and choose USB hardrive. You may or may not have to disable secure boot. Choose Arch live install.


Check internet connection

Check if ping 8.8.8.8 pings the server. You can also check ip addr to see if an IP address shows up.

# to get wifi
wifi_menu

You may need to systemctl restart dhcpd the dhcp daemon for the internet to work (may not also)


Choose a Mirror nearest to you

Go to /etc/pacman.d/mirrorlist and choose the mirror closest to you and move that to the beggining of the file. Note that vim editor works.


Test the Mirrors

Run:

pacman -Syyy

Take a look at the disk structure

You can run any of the following commands to list the volumes:

fdisk -l | more

lsblk

The aim is to get an idea of which disk you want to partition


Check if your system supports efi

If the following command gives viable output then it does:

efivar -l

If this is the case then your grub_install step will be different and you ideally should create an additional 2M partition of BIOS type.


Create Disk Partitions

For the purpose of this tutorial let us assume that /dev/sda is the drive you want to install Arch on:

Note that unless you press w in the PS2 given by fdisk, nothing is really written on disk. You can always press p to see the current status. If you did something wrong then you can always press g again to define a GPT partition (the older data will be overwritten).

Note that we need to create 3 partitions (one 2M extra if efivar not there):

  • First for EFI: 500M (can be less)
  • Second for the root filesystem: 30G
  • Third for the user filesystem: Remainder of the disk
fdisk /dev/sda

# Print current partition layout
> p

# Create a new gpt partition
> g

# New partition #1 (for its last sector use `+500M`, enter through all else. Dont forget to use a + sign)
> n 

# Choose new type. Press L to see the types. Press 1 to choose EFI type
> t 

# For root filesystem (enter through all, but the last sector add `+30G`)
> n 

# For the home filesystem. Enter through all and it will take the remainder of the space on disk
> n

# See your current settings
> p

# Finalize everything
> w

And done


Format Partitions

The EFI parition should be FAT32 and the root and user should be ext4. If no efivar then the BIOS one should be FAT32 as well

# EFI as FAT32
mkfs.fat -F32 /dev/sda1

# ext4 for second and third partitions
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sda3

Mount the partitions

Mount the root filesystem at the mount point and the home partition inside the home folder

mount /dev/sda2 /mnt

mkdir /mnt/home

mount /dev/sda3 /mnt/home

# These command show the details
mount
df -h

Export filesystem mount points into fstab

mkdir /mnt/etc

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

# Create a backup of the fstab file
cp /mnt/etc/fstab /mnt/etc/fstab.bak

Pacstrap

Bootstrap the needed binaries on the mounted filesystem using pacstrap. Base is necessary. Base-devel is for the additional binaries (needed if we are building AURs locally).

pactrap -i /mnt base base-devel

Connect to the mounted FS

Whatever we do in the chroot environment will take effect in the new Arch installation.

arch-chroot /mnt

Choose a Kernel

For rolling kernel:

pacman -S linux linux-headers

For LTS Kernel

pacman -S linux-lts linux-lts-headers

Note that you can add both. If you do that then you will be prompted which kernel to use during startup.


Install an editor

pacman -S vim

Install SSH

This step is optional

pacman -S openssh

systemctl enable sshd

Systemctl basically creates symlinks on a .service file on enabling. All of the symlinked services will run as systemd services on boot.


Installing Network Packages

Only the first one is required, the rest are optional

pacman -S networkmanager wpa_supplicant wireless_tools netctl

systemctl enable NetworkManager

Install the dialog package

pacman -S dialog

Generate initial ramdisk

# For Rolling
mkinitcpio -p linux

# For LTS
mkinitcpio -p linux-lts

Configure Locale

# find your locale in the file. In my case -> (en_US.UTF-8 UTF-8) 
# Uncomment your locale
vim /etc/locale.gen

# Generate locale
locale-gen

Setting a Password

# Setting root password
passwd

# Creating a user and giving sudo access
useradd -m -g users -G wheel angad

# Creating password for the user
passwd angad

# Go to this file and uncomment the wheels line
visudo

Configure GRUB Bootloader

Install the required packages

pacman -S grub efibootmgr dosfstoolsos-prober mtools

Create a dir for EFI and mount the EFI filesystem here in the chroot environment

mkdir /boot/EFI
mount /dev/sda1 /boot/EFI

Install GRUB

# for system which supports efi (efivar -l)
grub-install --target=x86_64-efi --bootloader-id=grub_uefi --recheck

# for system which does not support efivar -l
# /dev/sda4 is the 2M partition of BIOS type
grub-install --target=i386-pc /dev/sda4

Copy locale to GRUB

mkdir /boot/grub/locale

# Depends on your locale
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

Generate GRUB config

grub-mkconfig -o /boot/grub/grub.cfg

Create a swapfile

When a program consumes more RAM than there is, some programs get pre-empted to the swap space. It is ideal to have it on the filesystem rather than as another partition so that the size can be flexible.

# 2 GB swapfile
fallocalte -l 2G /swapfile

# Change permisisons of the swapfile
chmod 600 /swapfile

# Make the swapfile
mkswap /swapfile

# Make it to activate at boot by adding it to the fstab
echo '/swapfile none swap sw 0 0' >> /etc/fstab

Install additional packages

# for amd CPU microcode
pacman -S amd-ucode

# for intel CPU microcode
pacman -S intel-ucode

# for amd/intel graphics
# mesa is pre-requisite for xorg-server too
pacman -S mesa

# for nvidia graphics
pacman -S nvidia nvidia-utils

# for a desktop environment
pacman -S xorg-server xorg-xinit

# for linux firmware
pacman -S linux-firmware

# for sound
pacman -S alsa-utils
alsamixer

# for ifconfig
pacman -S net-tools

If installing Arch on virtualbox

pacman -S virtualbox-guest-utils xf86-video-vmware

Synchronise clock

We will activate the service, to activate synchronization between the computer and the servers on the internet:

systemctl enable systemd-timesyncd.service

timedatectl set-ntp true

Poweroff or reboot

# exit from chroot
exit

# check mounts
umount -a

# poweroff
poweroff

You are now good to go! The next steps are only necessary if you want a desktop environment.

Setting up a display manager

You can download any display manager. This is basically your login screen to your desktop environment. You will also want a greeter to go along with it.

pacman -S lightdm lightdm-gtk-greeter

systemctl enable lightdm

Setting up a window manager

You can download a WM for a desktop environment (DE). Let us see how we can get the awesome window manager up and running:

pacman -S awesome

echo 'exec awesome' > ~/.xinitrc

startx

Setting up a desktop environment

Optionally, you can set up a desktop environment:

pacman -S cinnamon

echo 'exec cinnamon-session' > ~/.xinitrc

startx

Some other useful tools

# feh image viewer
# mpv video player
# alacritty terminal emulator
# qutebrowser browser
# cava sound visual effects
# transmisison torrent client
pacman -S feh mpv newsboat alacritty qutebrowser cava transmission 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment