Notes to myself on how to install Arch Linux.
Instructions below are mostly from the Arch Linux Installation Guide.
Tested on:
- Dell XPS13 (9360)
- 2008 Macbook Black (search b43 drivers for wifi)
Preparation
Prepare a bootable USB stick with the Arch image on it:
- download the latest Arch Linux ISO image from the Arch Linux Downloads page
- format a USB stick (FAT format, MBR partition table)
- copy the ISO image to the stick:
sudo dd if=<path_to_iso> of=<path_to_usb_device> bs=1m
- alternatively, have a look at etcher which automates all this
- insert the bootable USB stick, boot the computer and enter the BIOS to disable 'safe boot'
- re-boot and select Arch Linux in the boot menu (Dell XPS13: press F12 to get the boot menu)
Pre-installation
Note: in case of SQUASHFS errors during installation, it probably means that the USB device is not good so try another one.
Set the console keyboard layout
The default is us
but for e.g. a uk
layout:
-
list the available layouts:
localectl list-keymaps
orls /usr/share/kbd/keymaps/**/*.map.gz
-
load the uk layout:
loadkeys uk
Load a more relevant font: setfont eurlatgr
Connect to the internet
Run wifi-menu
, or refer to Network configuration or Wireless network configuration if that doesn't work.
Update the system clock
timedatectl set-ntp true
Partition the disk
Check the disk with lsblk
or fdisk -l
and take a note of the device name (/dev/nvme0n1
on the Dell XPS13)
-
Use the GPT disklabel:
parted -a optimal /dev/nvme0n1 mklabel gpt
-
Create a small boot partition:
parted -a optimal -- /dev/nvme0n1 mkpart ESP fat32 1MiB 513MiB set 1 boot on
-
Create a system partition using the rest of the disk:
parted -a optimal -- /dev/nvme0n1 mkpart ext4 513MiB 100%
Persistent block device naming for fstab is achieved by using UUID of the disk.
Encrypt the Linux partition
Use LVM on LUKS.
-
Create the encrypted container on the system partition (choose a good passphrase):
cryptsetup luksFormat /dev/nvme0n1p2
-
Open the container (name it 'luks'):
cryptsetup open /dev/nvme0n1p2 luks
-
Create a Physical Volume on top of the opened LUKS container:
pvcreate /dev/mapper/luks
-
Create a Volume Group and add the Physical Volume to it (name it
main
):vgcreate main /dev/mapper/luks
-
Create Logical Volumes on that Volume Group (50GiB for
/
and 100GiB for/home
, no swap YOLO):lvcreate -L50g main -n root
lvcreate -L100g main --name home
Format the filesystem on each Logical Volume:
See https://wiki.archlinux.org/index.php/Ext4#Enabling_metadata_checksums and maybe http://www.askapache.com/optimize/super-speed-secrets/
modprobe crc32c_intel
mkfs.ext4 -O metadata_csum,64bit /dev/mapper/main-root
mkfs.ext4 -O metadata_csum,64bit /dev/mapper/main-home
Mount the file systems
-
mount
/
:mount -o defaults,journal_checksum /dev/mapper/main-root /mnt
-
create mountpoints for
/boot
and/home
:mkdir /mnt/{boot,home}
-
mount
/boot
:mount -o defaults,journal_checksum /dev/nvme0n1p1 /mnt/boot
-
mount
/home
:mount -o defaults,journal_checksum /dev/mapper/main-home /mnt/home
Installation
Install the base packages
Install the base and base-devel package groups as well as some packages for wireless network configuration, Intel micro-code updates and git:
pacstrap /mnt base base-devel dialog dhcpcd wpa_actiond wpa_supplicant intel-ucode git
Configure the system
Fstab
Create the fstab
file:
genfstab -U /mnt >> /mnt/etc/fstab
Change root into the target system to continue the installation:
arch-chroot /mnt
Time settings
Set the timezone:
ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
Set the hardware clock (from the system clock but keep it UTC):
hwclock --systohc --utc
Locale
Uncomment required localisations in /etc/locale.gen
and regenerate them with locale-gen
.
Set the LANG
variable in /etc/locale.conf
e.g. LANG=en_GB.UTF-8
Make console keyboard mappings and font changes permanent /etc/vconsole.conf
:
FONT=eurlatgr
KEYMAP=us
Hostname
-
Create the hostname file:
echo <hostname> > /etc/hostname
-
Add a matching entry to
/etc/hosts
:echo 127.0.1.1 <hostname>.localdomain <hostname> >> /etc/hosts
Network configuration
-
Configure wireless with
wifi-menu
. -
Configure wireless to start at boot and automatically connect to known networks:
systemctl enable netctl-auto@<interface_name>.service
(use tab completion to figure out the interface name).
Initramfs
Edit /etc/mkinitcpio.conf
with:
MODULES="EXT4"
HOOKS="autodetect systemd block sd-vconsole sd-encrypt sd-lvm2 fsck keyboard"
Run mkinitcpio -p linux
to generate the initramfs image as /boot/initramfs-linux.img
(see mkinitcpio#hooks)
Setup systemd-boot:
bootctl --path=/boot install
Bootloader
Create a bootloader entry:
UUID=$(cryptsetup luksUUID /dev/nvmen0n1p2)
cat <<EOF>/boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options luks.uuid=$UUID luks.name=$UUID=luks root=/dev/mapper/main-root rw
EOF
Point the bootloader to the default entry (see Basic Configuration):
cat <<EOF>/boot/loader/loader.conf
default arch
editor 0
EOF
Users
Set the root password with passwd
Add a regular user:
useradd -m -g users -G wheel -s /bin/bash franck
passwd franck
Run visudo
and add the following to have my user in the sudoers file :
# options
Defaults editor=/usr/bin/vim, !env_editor
Defaults insults
# full access
franck ALL=(ALL) ALL
# last rule as a safety guard
franck ALL=/usr/sbin/visudo
To add a red blinking prompt for root:
First, copy some skeleton files:
cp /etc/skel/.bash_profile /etc/skel/.bashrc /root
And then edit /root/.bashrc
and set PS1
to:
PS1="\e[1m\e[91m\e[5m[\u@\h]\$\e[m\e(b "
Reboot
exit
reboot
System configuration
Add the following repo to /etc/pacman.conf
for easy installation of vivaldi
:
[herecura]
Server = https://repo.herecura.be/herecura/x86_64
ensure that the following options are set:
HoldPkg = pacman glibc
Architecture = auto
Color
CheckSpace
VerbosePkgLists
SigLevel = Required DatabaseOptional
LocalFileSigLevel = Optional
and upgrade the system with sudo pacman -Syu
in order to be able to use it.
add tuning instructions e.g. build in tmpfs (https://wiki.archlinux.org/index.php/Makepkg#Improving_compile_times)
Packages
Install the following package groups:
i3 xorg xorg-apps xorg-drivers
Install the packages in packages.lst
with pacman and pacaur.
Enable some services
- systemctl enable --now systemd-timesyncd.service# simple SNTP daemon
- systemctl enable --now docker.service
- cp /etc/iptables/empty.rules /etc/iptables/iptables.rules &&
.. systemctl enable --now iptables.service # safety first (and see Simple Statefull Firewall for configuration)
User configuration
Clone all the config files from github/kifbv/dotfiles and install them with stow
TODO
Also see https://wiki.archlinux.org/index.php/Sysctl and https://wiki.archlinux.org/index.php/Improving_performance Fix the layout to be the same as Macbook UK (i.e. use us layout but remap the |\ key next to shift-left to ~`) Relocate files to tmpfs (+ other tips in https://wiki.archlinux.org/index.php/Improving_performance)
Arch Linux Docs:
Installation guide Improving performance Keyboard shortcuts Keyboard configuration in Xorg Map scancodes to keycodes Extra keyboard keys in Xorg Xbindkeys LVM Mkinitcpio Disk encryption Ext4 Wireless Network Configuration