Skip to content

Instantly share code, notes, and snippets.

@thomasheller
Last active June 22, 2021 08:49
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 thomasheller/725d8f324451e063938e38fde159bf09 to your computer and use it in GitHub Desktop.
Save thomasheller/725d8f324451e063938e38fde159bf09 to your computer and use it in GitHub Desktop.
Arch Linux "LVM on LUKS" setup

Arch Linux "LVM on LUKS" setup

  • Download ISO and verify signatures.

  • Boot and select "Boot Arch Linux (x86_64)".

  • If you're on a WiFi-only network, connect via iwctl:

iwctl
device list
station <device> scan
station <device> get-networks
station <device> connect "<SSID>"
quit
  • Make sure network is available:
ping archlinux.org
  • Enable NTP:
timedatectl set-ntp true
  • Check available disks:
lsblk
  • Create partitions for boot and encryption (replace /dev/sda with the desired disk!):
fdisk /dev/sda
p
[If needed, use d to delete any old partitions.]
n
p
1
<Enter>
+200M
[If needed, confirm signature deletion with y.]
n
p
2
<Enter>
<Enter>
w
  • Create encrypted LUKS container (replace /dev/sda with the desired disk!):
cryptsetup luksFormat /dev/sda2
cryptsetup open /dev/sda2 cryptlvm
  • Create LVM volumes (adjust volume sizes to available space!):
pvcreate /dev/mapper/cryptlvm
vgcreate Linux /dev/mapper/cryptlvm
lvcreate -L 24G Linux -n swap
lvcreate -L 100G Linux -n root
lvcreate -l 100%FREE Linux -n home
  • Format and mount volumes:
mkswap /dev/Linux/swap
mkfs.ext4 /dev/Linux/root
mkfs.ext4 /dev/Linux/home

swapon /dev/Linux/swap
mount /dev/Linux/root /mnt
mkdir /mnt/home
mount /dev/Linux/home /mnt/home
  • Prepare boot partition (replace /dev/sda with the desired disk!):
mkfs.ext4 /dev/sda1
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
  • Install essential packages:
pacstrap /mnt base linux linux-firmware
  • Generate file system table:
genfstab -U /mnt >>/mnt/etc/fstab
  • Switch to newly installed system:
arch-chroot /mnt
  • Install manpages:
pacman -S man-db man-pages texinfo
  • Install text editor:
pacman -S vim
  • Set up timezone if needed:
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
  • Edit /etc/locale.gen and uncomment desired locales:
vim /etc/locale.gen
  • Generate locale(s):
locale-gen
  • Set desired default locale, e.g.:
echo LANG=en_US.UTF-8 >/etc/locale.conf
  • Set desired hostname, e.g.:
echo arch >/etc/hostname
  • Add hosts entries:
echo 127.0.0.1 localhost >>/etc/hosts
echo ::1 localhost >>/etc/hosts
echo 127.0.1.1 arch >>/etc/hosts
  • Set up DHCP if desired:
pacman -S dhcpcd
systemctl enable dhcpcd
  • For WiFi, consider installing wifi-menu, too:
pacman -S netctl dialog wpa_supplicant
  • Install and load modules required for cryptsetup in initial ramdisk:
pacman -S lvm2
vim /etc/mkinitcpio.conf

...
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck encrypt lvm2)
...
  • Apply initramfs configuration:
mkinitcpio -P
  • Install GRUB (replace /dev/sda with the desired disk!):
pacman -S grub
grub-install --target=i386-pc /dev/sda
  • Set GRUB defaults and create configuration (replace <device-uuid> with the UUID of the second partition of the desired disk according to lsblk -f!):
vim /etc/default/grub
...
GRUB_CMDLINE_LINUX="cryptdevice=UUID=<device-uuid>:cryptlvm root=/dev/Linux/root"
...

grub-mkconfig -o /boot/grub/grub.cfg
  • Set the root password:
passwd
  • Boot into the new system (remove install medium):
exit
reboot

(Log in as root.)

  • If you're on a WiFi-only network, connect via wifi-menu.

  • Make sure network is available:

ping archlinux.org
  • Add sudo user:
useradd -m -g wheel arch
passwd arch
  • Install sudo:
pacman -S sudo
EDITOR=vim visudo

...
%wheel ALL=(ALL) ALL
...
  • Install alternative shell if desired:
pacman -S zsh
chsh -s /usr/bin/zsh root
chsh -s /usr/bin/zsh arch
  • Install X, fonts and terminal emulator if desired:
pacman -S xorg-server xorg-xinit
# pacman -S ttf-linux-libertine ttf-inconsolata
pacman -S noto-fonts noto-fonts-emoji
pacman -S alacritty
  • Install window manager, e.g. bspwm:
pacman -S bspwm sxhkd
mkdir -p ~/.config/bspwm
mkdir -p ~/.config/sxhkd
cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm
cp /usr/share/doc/bspwm/examples/sxhkdrc ~/.config/sxhkd
sed -i s/urxvt/alacritty/ ~/.config/sxhkd/sxhkdrc
echo exec bspwm >~/.xinitrc
  • Run X:
exec startx -- -nolisten tcp
  • Useful basic packages:
pacman -S git openssh base-devel
  • yay for installing AUR packages:

https://github.com/Jguer/yay#installation

  • Browser, e.g.:
yay -S brave-bin
  • For building dwm:
pacman -S libxinerama
yay -S libxft-bgra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment