GithubHelp home page GithubHelp logo

tomjgooding / arch-installation-guide Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 126 KB

Personal reference guide for installing Arch Linux. Disclaimer: YMMV!

License: GNU General Public License v3.0

arch-installation-guide's Introduction

Arch Installation Guide

Personal reference guide for installing Arch Linux. Disclaimer: YMMV!

Table of Contents

Features

  • Btrfs
  • zram
  • i3
  • Snapper

Pre-Installation

Download an Arch Linux image and create a bootable USB.

Connect an Ethernet cable.

Boot from the USB into the live environment.

Set the console keyboard layout (default is US).

loadkeys uk

Verify the boot mode

ls /sys/firmware/efi/efivars

Ensure a valid IP address

ip -c a

Verify internet connection

ping archlinux.org

Update the system clock

timedatectl set-ntp true

Partition the Disk

Identify the target disk

lsblk

Use gdisk to modify partition tables

gdisk /dev/the_disk_to_be_partitioned

Partition layout reference

No Size Type Code Name
1 +512M ef00 BOOT
2 remainder default ROOT

For each partition

  • Command: n
  • Partition number (default): <enter>
  • First sector (default): <enter>
  • Last sector: size
  • Code: type_code
  • Command: c
  • Partition number: no
  • Enter name: name

Print the partition table to ensure configured correctly with p

Write the changes to the disk with w

Show the partitions

lsblk

Format the Partitions

Format the BOOT (EFI) partition

mkfs.vfat -n BOOT /dev/boot_partition

Format the ROOT partition with the btrfs filesystem

mkfs.btrfs -L ROOT /dev/root_partition

Mount the Partitions

Show the partitions

lsblk

Mount the root volume

mount /dev/root_partition /mnt

Change into mnt directory

cd /mnt

Btrfs subvolumes layout reference

Name Subvolume
@.snapshots /.snapshots
@home /home
@log /var/log
@pkgs /var/cache/pacman/pkg

Create the btrfs subvolumes

btrfs su cr @
btrfs su cr @home
btrfs su cr @.snapshots
btrfs su cr @log
btrfs su cr @pkgs

Change back into main directory

cd

Unmount root and then remount

umount /mnt
mount -o compress=zstd:1,noatime,subvol=@ /dev/root_partition /mnt

Create the directories for the subvolumes

mkdir -p /mnt/{boot/efi,home,.snapshots,var/log,var/cache/pacman/pkg}

Mount the btrfs subvolumes

mount -o compress=zstd:1,noatime,subvol=@home /dev/root_partition /mnt/home
mount -o compress=zstd:1,noatime,[email protected] /dev/root_partition /mnt/.snaphots
mount -o compress=zstd:1,noatime,subvol=@log /dev/root_partition /mnt/var/log
mount -o compress=zstd:1,noatime,subvol=@pkgs /dev/root_partition /mnt/var/cache/pacman/pkg

Mount the EFI boot partition

mount /dev/boot_partition /mnt/boot/efi

Check the partitons are mounted correctly

lsblk

Installation

Select the mirrors

reflector --country "United Kingdom" --latest 5 --sort rate --save /etc/pacman.d/mirrorlist

Enable parallel downloads by uncommenting the ParallelDownloads line in the configuration file

vim /etc/pacman.conf

Sync the pacman repository

pacman -Syy

Install the essential packages listed in the Essential.paclist.txt file

pacstrap /mnt base linux linux-firmware other_essential_packages

Configure the system

Generate an fstab file

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

Change root into the new system

arch-chroot /mnt

Set the time zone

ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Synchronise the hardware clock to the system clock

hwclock --systohc

Edit /etc/locale.gen and uncomment the needed locales - en_GB.UTF-8 UTF-8

vim /etc/locale.gen

Generate the locales

locale-gen

Create the locale.conf file and set the LANG variable

echo "LANG=en_GB.UTF-8" >> /etc/locale.conf

Set the console keymap permanently

echo "KEYMAP=uk" >> /etc/vconsole.conf

Create the hostname

echo "arch" >> /etc/hostname

Edit the hosts file

vim /etc/hosts
127.0.0.1        localhost
::1              localhost
127.0.1.1        arch.localdomain        arch

Set the root password

passwd

Edit the configuration file for mkinitcpio

vim /etc/mkinitcpio.conf
BINARIES=(btrfs)

Regenerate

mkinitcpio -p linux

Install base packages

Select the mirrors

reflector --country "United Kingdom" --latest 5 --sort rate --save /etc/pacman.d/mirrorlist

Enable parallel downloads by uncommenting the ParallelDownloads line in the configuration file

vim /etc/pacman.conf

Sync the pacman repository

pacman -Syy

Download the list of base packages file

curl -O https://raw.githubusercontent.com/TomJGooding/arch-installation-guide/main/paclists/Base.paclist.txt

Install the packages

pacman -S --needed - < Base.paclist.txt

Install GRUB

Install GRUB

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ArchLinux

Create the GRUB configuration file

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

Add users and groups

Add a new user

useradd -m -G sys,network,lp,wheel tom

Set the password

passwd tom

Enable the wheel group for sudo, by uncommenting the %wheel ALL= (ALL) ALL line in sudoers

EDITOR=vim visudo 

Enable services

systemctl enable avahi-daemon
systemctl enable bluetooth
systemctl enable cups
systemctl enable fstrim.timer
systemctl enable NetworkManager

Reboot

Exit the chroot environment

exit

Unmount all the partitions

umount -R /mnt

Restart the machine. Remember to remove the USB!

reboot

Post-Installation

Ensure a valid IP address

ip -c a

Check you can synchronise packages

sudo pacman -Sy

Download the list of post-install packages file

curl -O https://raw.githubusercontent.com/TomJGooding/arch-installation-guide/main/paclists/PostInstall.paclist.txt

Install the packages

sudo pacman -S --needed - < PostInstall.paclist.txt

Enable the display manager

sudo systemctl enable lightdm

Edit lightdm config to use slick-greeter

sudo vim /etc/lightdm/lightdm.conf
greeter-session=lightdm-slick-greeter

Install AUR packages

Install the paru AUR helper

git clone https://aur.archlinux.org/paru
cd paru
makepkg -si

Verify paru is working

paru

Remove build directory

cd
rm -fr paru

Download the list of AUR packages file

curl -O https://raw.githubusercontent.com/TomJGooding/arch-installation-guide/main/paclists/AUR.paclist.txt

Install the packages

paru -S - < AUR.paclist.txt

Activate Zram

Enable zramd

sudo systemctl enable --now zramd

Check system now has swap with zram

lsblk

Reboot and Initial Configuration

Reboot the system

reboot

If everything went well, after rebooting we should be greeted with the lightdm display manager.

After logging in, we will be prompted by i3 to create a configuration file. Hit enter.

Select the windows key as the modifier and hit enter.

Hit mod+Enter to open the terminal. Change the keyboard layout

setxkbmap gb

The urxvt terminal is ugly out of the box, so we'll need to add an Xresources file

curl -O https://raw.githubusercontent.com/TomJGooding/arch-installation-guide/main/settings/.Xresources

Load the file

xrdb ~/.Xresources

Hit mod+Shift+q to close the current terminal, then open again with mod+Enter. We should now have a much nicer looking terminal!

Configure Snapper

Become root shell and change to the root directory

sudo -s
cd /

Snapper will re-create the snapshots subvolume when configured, so we need to remove this first

umount /.snapshots
rm -r /.snapshots

Create the snapper root configuration

snapper -c root create-config /

Listing the btrfs subvolumes will show that snapper has created an extra superflous snapshots subvolume

btrfs subvol lis /

Remove the extra superflous subvolume

btrfs subvol del /.snapshots

Listing again should show this has now been deleted

btrfs subvol lis /

Now we need to re-create this directory and re-mount

mkdir .snapshots
mount -a

Check that all subvolumes are properly mounted again

lsblk

We want bootable snapshots, but currently the default is the the top level file system tree

btrfs subvol get-def /

Change the default to the @ root subvolume ID

btrfs subvol lis /
btrfs subvol set-def ID_of_@_subvolume /

Verify the changes

btrfs subvol get-def /

Edit the config file

vim /etc/snapper/configs/root
ALLOW_GROUPS="wheel"
[...]
NUMBER_LIMIT="10"
[...]
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="5"
TIMELINE_LIMIT_DAILY="7"
TIMELINE_LIMIT_WEEKLY="0"
TIMELINE_LIMIT_MONTHLY="0"
TIMELINE_LIMIT_YEARLY="0"

Change the owner of the snapshots subvolume for the wheel group

chown -R :wheel /.snapshots

Exit the root shell and ensure we can use snapper as a wheel user

exit
snapper ls

Become root shell again and change to the root directory

sudo -s
cd /

Enable the grub-btrfs service

systemctl enable --now grub-btrfs.path

Verify that the service is monitoring for new snapshots

systemctl status grub-btrfs.path

Create a grub configuration file to ensure everything is synchronised

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

Enable the snapper services

systemctl enable --now snapper-timeline.timer
systemctl enable --now snapper-cleanup.timer

Create our first snapshot for the base system configuration

snapper -c root create -d "***Base System Configuration***"
snapper ls

Synchronise the grub menu

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

Exit the root shell and verify that as a wheel user the new snapshot is listed

exit
snapper ls

Managing dotfiles

We will use chezmoi to help manage our configuration files (dotfiles)

First configure your GitHub username and email address

git config --global user.name "Your Name"
git config --global user.email [email protected]

Install the Github CLI and authenticate your account

sudo pacman -S github-cli

gh auth login

Install and initialise chezmoi

sudo pacman -S chezmoi

chezmoi init

Create a new repository on GitHub called dotfiles. Choose 'No' for all options to add files and the option to clone locally.

gh repo create

Manage our first file with chezmoi

chezmoi add ~/.Xresources

Make some changes and save the file. See what changes chezmoi would make.

export EDITOR=vim
chezmoi edit ~/.Xresources
chezmoi diff

Apply the changes. Then open a shell in the source directory, to commit your changes

chezmoi -v apply
chezmoi cd
git add .
git commit -m "Initial commit"

Push your repo, then finally exit the shell in the source directory

git remote add origin https://github.com/username/dotfiles.git
git branch -M main
git push -u origin main
exit

Install Neovim

Install neovim

sudo pacman -S neovim

Create and change into a new nvim config directory

mkdir .config/nvim
cd .config/nvim

Download the kickstart configuration file

curl -O https://raw.githubusercontent.com/nvim-lua/kickstart.nvim/master/init.lua

Start neovim and install the plugins

nvim
:PackerInstall

If we run :checkhealth neovim will show some errors for missing packages required by the configuration

Quit neovim and install these packages

sudo pacman -S node npm wget unzip

Running :checkhealth again should no longer show these errors. We can also check installed language servers by running :Mason

Add relative numbers to the nvim configuration and manage with chezmoi

chezmoi add ~/.config/nvim/init.lua
export EDITOR=nvim
chezmoi edit ~/.config/nvim/init.lua

Add line for relative numbers

-- Make line numbers default
vim.wo.number = true
vim.wo.relativenumber = true

Apply the changes. Then open a shell in the source directory, to commit your changes

chezmoi -v apply
chezmoi cd
git add .
git commit -m "Added nvim dotfile"

Push your repo, then finally exit the shell in the source directory

git push -u origin main
exit

Create a new~/.profile file which will allow us to set neovim as the default editor

cd
touch .profile

Follow the same steps above for managing this dotfile with chezmoi. Add these lines:

export EDITOR=/usr/bin/nvim
export BROWSER=/usr/bin/firefox

i3 Configuration

Add new options in the i3 configuration file, again ensuring to manage all dotfiles with chezmoi (i.e. chezmoi add ~/.config/i3/config, etc...)

# Configure border style
default_border pixel 1
default_floating_border normal

# Hide borders
hide_edge_borders none

# Open specific applications in floating mode
for_window [title="alsamixer"] floating enable border pixel 1
for_window [class="Lightdm-settings"] floating enable
for_window [class="Lxappearance"] floating enable sticky enable border normal
for_window [class="Nitrogen"] floating enable sticky enable border normal

# Switch to workspace with urgent window automatically
for_window [urgent=latest] focus

# Autostart applications
exec --no-startup-id nitrogen --restore; sleep 1; picom -b

#############################
### Settings for i3-gaps: ###
#############################

# Set inner/outer gaps
gaps inner 14
gaps outer -2

# Smart gaps (gaps used if only more than one container on the workspace)
smart_gaps on

# Smart borders (draw borders around container only if it is not the only container on this workspace) 
smart_borders on

Close the window and restart i3. Verify windows now have gaps by opening a couple new terminals

mod+Shift+q
mod+Shift+r
mod+Enter
mod+Enter

Add Wallpaper with Nitrogen

Open dmenu with mod+d. Type 'nitrogen' and press Enter to open.

Click 'Preferences' and add the directory /usr/share/backgrounds. Ensure the Recurse option is ticked, then click OK.

Choose a background and change the sizing option to 'Zoomed Fill'. This repo's settings directory also includes a retro Linux background if you prefer, just save to the backgrounds directory. Click 'Apply' and close Nitogen with mod+Shift+q

We can also add transparency to the terminal by editing the .Xresources file (remember to manage with chezmoi)

URxvt.background: [95]#282c34

Merge the changes

xrdb -merge ~/.Xresources

picom Configuration

First we need to copy the default picom configuration file to our ~/.config directory

cp /etc/xdg/picom.conf .config/

Remember to manage all dotfiles with chezmoi and edit this file to disable fading

fading = false
# fading = true

Exit i3 with mod+Shift+e. After logging back in, the termimal should now have transparency but no fading effect when opening/closing a window.

Theme configuration with Lxappearance

Install the theme packages

sudo pacman -S arc-gtk-theme papirus-icon-theme

Open dmenu with mod+d. Type 'lxappearance' and press Enter to open.

Change the 'Widget' theme to Arc-Dark and the 'Icon Theme' to Papirus-Dark

Display manager configuration

Open the lightdm configuration tool

sudo lightdm-settings

Choose a background. Change the GTK theme to Arc-Dark and the Icon theme to Papirus-Dark.

Quit with mod+Shift+q, then exit i3 with mod+Shift+e. The display manager should now have a wallpaper.

Status bar configuration

First we need to copy the default i3status configuration file to our ~/.config/i3 directory

cp /etc/i3status.conf .config/i3

Remember to manage all dotfiles with chezmoi and edit this file

# order += "ipv6"
order += "cpu_usage"
order += "disk /"
order += "wireless _first_"
# order += "ethernet _first_"
order += "battery all"
# order += "load"
order += "memory"
order += "tztime local"

cpu_usage {
        format = "CPU: %usage"
}

By default i3 will look for the i3status config in the etc directory, so we need to edit the i3 config file

bar {
        status_command i3status -c ~/.config/i3/i3status.conf
}

We can also change the bar font and colours

# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font xft:NotoSansMono Nerd Font 10
[...]
bar {
        status_command i3status -c ~/.config/i3/i3status.conf

        colors {
                background #282c34
        }
}

Reload i3 to verify the changes

mod+Shift+r

arch-installation-guide's People

Contributors

tomjgooding avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.