Skip to content

Instantly share code, notes, and snippets.

@jomifepe
Last active April 14, 2021 18:57
Show Gist options
  • Save jomifepe/561b62082156fdceb817dd878b5ab01f to your computer and use it in GitHub Desktop.
Save jomifepe/561b62082156fdceb817dd878b5ab01f to your computer and use it in GitHub Desktop.

Updated installation guide: https://wiki.archlinux.org/index.php/installation_guide

1. Pre-installation

1.1. Change keyboard layout

# Listing all available layouts:
ls /usr/share/kbd/keymaps/**/*.map.gz

# Loading portuguese layout:
loadkeys pt-latin1

1.2. Verify if booted in UEFI

# If the directory does not exist, the system may be booted in BIOS or CSM mode.
ls /sys/firmware/efi/efivars

1.3. Check internet connection

ip link
ping google.com

1.4. Update the system clock

timedatectl set-ntp true
# To check if the time is correct:
timedatectl status

1.5. Partition the disks

# List available disks
fdisk -l
# Partition the disks using cfdisk:
cfdisk /dev/sdX

UEFI installation example:

Partition Size Type
Boot 512M 1 - EFI System
Swap Double your RAM 19 - Linux swap
/ (Root) Rest of the free space 20 - Linux filesystem

1.6. Format partitions

# Format root partition
mkfs.ext4 /dev/sdX1
# Format the boot partition (if created):
mkfs.fat -F32 /dev/sdX2
# Initialize swap
mkswap /dev/sdX3
swapon /dev/sdX3

1.7. Mount the file systems

# Mount root partition
mount /dev/sdX1 /mnt

# Create a boot directory
mkdir /mnt/boot
# Mount boot (UEFI) partition
mount /dev/sdX2 /mnt/boot

1.8. Select pacman mirrors

# Delete mirrors outside of Europe
vim /etc/pacman.d/mirrorlist

2. Installation

2.1. Install essential packages

pacstrap /mnt base linux linux-firmware vim nano

3. Configure the system

3.1. Configure Fstab

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

3.2. Chroot

arch-chroot /mnt

3.3. Time zone

ln -sf /usr/share/zoneinfo/Portugal /etc/localtime
hwclock --systohc

3.4. Localization

# Edit /etc/locale.gen and uncomment what you want:
vim /etc/locale.gen
# Generate locale
locale-gen
# Configure /etc/locale.conf:
vim /etc/locale.conf
# and set the LANG variable accordingly:
LANG=en_US.UTF-8
# If you set the keyboard layout, make the changes persistent with:
vim /etc/vconsole.conf
# and set the KEYMAP variable accordingly:
KEYMAP=pt-latin1

4. Network configuration

4.1. Hostname

# Create /etc/hostname with your hostname:
vim /etc/hostname
# Add your hostname like:
myhostname

4.2. Add the following lines to /etc/hosts:

127.0.0.1       localhost
::1             localhost
127.0.1.1	myhostname.localdomain	myhostname

4.3. Installing network management software

IMPORTANT: This is needed in order to have internet connection after the reboot

# If you only have a wired connection, dhcpcd is sufficient and less complicated
pacman -S dhcpcd
systemctl enable dhcpcd

# If you also need to handle Wi-Fi, NetworkManager is better
pacman -S networkmanager
systemctl enable networkmanager

4.4. User configuration:

# Set root password
passwd

# Adding a new user
useradd -m yourusername
passwd jmfp

# Adding user to groups
usermod -aG wheel,power,audio,video,optical,storage yourusername

# Allow wheel group members to execute any command
visudo
# Uncomment the line "%wheel ALL=(ALL) NOPASSWD: ALL"

4.5. Installing bootloader

# Use pacman to install grub, efibootmgr and os-prober
pacman -S grub efibootmgr os-prober
# Install grub on the system
grub-install --target=x86_64-efi --efi-directory=/boot
# If you have or plan on dual booting with Windows, mount it's partition in order to os-prober detect it when generating the grub config
mkdir /mnt/windows
# Find the windows partition with (fdisk -l, lsblk, blkid, etc) and mount it
mount /dev/sdXX /mnt/windows
# Generate a grub config file
grub-mkconfig -o /boot/grub/grub.cfg

5. Reboot

# Exit chroot
exit

# Optionally manually unmount all the partitions
umount -R /mnt

# Finally reboot
reboot

6. Post-installation

6.1. Install a display server

# Install Xorg
sudo pacman -S xorg xorg-xinit

6.2. Install a window manager

# Install bspwm
sudo pacman -S bspwm sxhkd

# Install the default config
mkdir -p .config/bspwm
mkdir .config/sxhkd
cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm/
cp /usr/share/doc/bspwm/examples/sxhkdrc ~/.config/sxhkd/

6.3. Install a display/login manager

# Install lightdm
sudo pacman -S lightdm
# Install a greeter
sudo pacman -S lightdm-gtk-greeter

# Change the config to the installed greeter
sudo vim /etc/lightdm/lightdm.conf

# [Seat:*]
# ...
# greeter-session=lightdm-gtk-greeter

# Enable the service
systemctl enable lightdm

6.4. Installing an authentication control system (polkit)

Polkit is necessary to control system-wide privileges and ask the user to enter the administrator password when necessary

# Install the polkit package
sudo pacman -S polkit
# If you are using a graphical environment, make sure that a graphical authentication agent is installed and autostarted on login (lxsession is a lightweight alternative)
# There are a few options: https://wiki.archlinux.org/index.php/Polkit
sudo pacman -S lxsession

6.5. Persisting keyboard layout on Xorg

sudo setxkbmap -layout pt

6.6. Creating the home directory file structure

# Install xdg-user-dirs
sudo pacman -S xdg-user-dirs
# Create the default directories
xdg-user-dirs-update

Aditional important packages:

  • base-devel (building and compiling packages)

  • git

  • linux-headers

  • dialog (boxes for shell scripts)

  • pkgfile (to search files from packages)

  • yay (installing packages from aur)

    git clone https://aur.archlinux.org/yay.git
    cd yay
    makepkg -si
  • gvfs-smb (support for SMB networking protocol)

  • ntfs-3g (reading ntfs)

  • tlp (power management for laptops)

  • bluez, bluez-utils and blueman (bluetooth support)

  • Fonts:

    • ttf-ms-fonts - AUR (Most of Microsoft fonts)

    • ttf-windows - AUR (Other Microsoft fonts, like Segoe UI)

    • noto-fonts (general unicode support, important for browsers)

    • noto-fonts-emoji (emojis)

    • noto-fonts-cjk (chinese, japanese and korean character support, fairly large package)

    • powerline-fonts (improved powerline fonts to support symbols)

      git clone https://github.com/powerline/fonts.git --depth=1
      cd fonts
      ./install.sh
    • nerd-fonts-complete (optional, has a lot of fonts)

Extra - Windows Dual-boot

If you plan on dual booting with windows, it's installation will probably break grub, to recover it follow these steps:

  1. Boot an Arch Linux live cd
  2. Chroot into your installation:
# Check the correct partitions
fdisk -l
# Mount the root partition
mount /dev/sdX1 /mnt
# Mount the boot partition
mount /dev/sdX3 /mnt/boot
# Chroot into the installation
arch-chroot /mnt
  1. Reinstall grub by following the steps on 4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment