Skip to content

Instantly share code, notes, and snippets.

@tsoporan
Last active April 12, 2020 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsoporan/c4327aacdedc0bae84c607d5c5add7f9 to your computer and use it in GitHub Desktop.
Save tsoporan/c4327aacdedc0bae84c607d5c5add7f9 to your computer and use it in GitHub Desktop.
Install Arch Linux w/ Btrfs subvolumes and dm-crypt

Dell XPS 9360 only

  • Enter BIOS with F2 and configure:
  • "System Configuration" > "SATA Operation": "AHCI"
  • "Secure Boot" > "Secure Boot Enable": "Disabled"

Install Guide

Enter boot menu with F12, and boot the Arch USB medium

Set desired keymap

loadkeys us

Set large font

setfont latarcyrheb-sun32

Connect to Internet (or eth already should be up check ip link)

wifi-menu

Sync clock

timedatectl set-ntp true

Securely wipe disk

https://wiki.archlinux.org/index.php/Securely_wipe_disk#Random_data

Create three partitions:

cgdisk /dev/nvme0n1

  1. 1GB EFI System
  2. 16GB Swap
  3. Rest Linux Filesystem

Make filesystems and encryption

mkfs.fat -F32 /dev/nvme0n1p1 cryptsetup luksFormat /dev/nvme0n1p3 cryptsetup open /dev/nvme0n1p3 luks mkfs.btrfs -L luks /dev/mapper/luks mkswap /dev/nvme0n1p2

Create btrfs subvolumes

mount -t btrfs /dev/mapper/luks /mnt btrfs subvolume create /mnt/@root btrfs subvolume create /mnt/@var btrfs subvolume create /mnt/@home btrfs subvolume create /mnt/@snapshots

Mount btrfs subvolumes

umount /mnt mount -o subvol=@root /dev/mapper/luks /mnt mkdir /mnt/{var,home,.snapshots} mount -o subvol=@var /dev/mapper/luks /mnt/var mount -o subvol=@home /dev/mapper/luks /mnt/home mount -o subvol=@snapshots /dev/mapper/luks /mnt/.snapshots

Mount EFI partition

mkdir /mnt/boot mount /dev/nvme0n1p1 /mnt/boot

Change pacman mirror priority, move closer mirror to the top

vi /etc/pacman.d/mirrorlist

Install the base system plus a few packages

pacstrap /mnt base sudo

Generate fstab

genfstab -L /mnt >> /mnt/etc/fstab

Verify and adjust /mnt/etc/fstab

For all btrfs filesystems consider:

  • Change "relatime" to "noatime" to reduce wear on SSD
  • Adding "discard" to enable continuous TRIM for SSD
  • Adding "autodefrag" to enable online defragmentation

Enter the new system

arch-chroot /mnt

Setup time

rm /ect/localtime ln -s /usr/share/zoneinfo/America/Toronto /etc/localtime hwclock --systohc

Generate required locales

vi /etc/locale.gen # Uncomment desired locales, e.g. "en_US.UTF-8", "de_CH.UTF-8" locale-gen

Set desired locale

echo 'LANG=en_US.UTF-8' > /etc/locale.conf

Set desired keymap and font

echo 'KEYMAP=us' > /etc/vconsole.conf echo 'FONT=latarcyrheb-sun32' >> /etc/vconsole.conf

Set the hostname

echo '' > /etc/hostname

Add to hosts

echo '127.0.0.1 localhost' >> /etc/hosts echo '::1 localhost' >> /etc/hosts echo '127.0.1.1 .localdomain ' >> /etc/hosts

Set password for root

passwd

Add daily user

useradd -m -g users -G wheel -s /bin/bash passwd echo ' ALL=(ALL) ALL' > /etc/sudoers.d/

Configure mkinitcpio with modules needed for the initrd image

vi /etc/mkinitcpio.conf

Change: HOOKS="base systemd autodetect modconf block keyboard sd-vconsole sd-encrypt filesystems

Regenerate initrd image

mkinitcpio -p linux

Setup systemd-boot

bootctl --path=/boot install

Enable CPU microcode updates

pacman -S intel-ucode or pacamn -S amd-ucode

Create bootloader entry

Get luks-uuid with: cryptsetup luksUUID /dev/nvme0n1p2

/boot/loader/entries/arch.conf

---
title		Arch Linux
linux		/vmlinuz-linux
initrd		/intel-ucode.img
initrd		/initramfs-linux.img
options		rw luks.uuid=<uuid> luks.name=<uuid>=luks root=/dev/mapper/luks rootflags=subvol=@root
---

Set default bootloader entry

---
/boot/loader/loader.conf
---
default		arch
---

Exit and reboot

exit reboot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment