Skip to content

Instantly share code, notes, and snippets.

@admkng
Forked from heppu/ARCH_INSTALL.MD
Last active November 11, 2019 14:20
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 admkng/1702fa56e60df1c1e210d1be7286561f to your computer and use it in GitHub Desktop.
Save admkng/1702fa56e60df1c1e210d1be7286561f to your computer and use it in GitHub Desktop.
Installing Arch with cgdisk, dm-crypt, LUKS, LVM and systemd-boot

Create bootable USB

dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync

Boot from USB and set prepare system

timedatectl set-ntp true

Connect to wifi

wifi-menu

Partition the disk with cgdisk

We will create 2 partitions, one for boot partition and one for LUKS encrypted partition

cgdisk /dev/sdX
1 512MB EFI partition # Hex code ef00
2 100% size partiton # (to be encrypted) Hex code 8300

Format, encrypt and mount partitions

I will create only swap and root partitions, but here you can create home, var and other partitions if you wish.

modprobe dm-crypt
cryptsetup luksFormat /dev/sda2
cryptsetup open --type luks /dev/sda2 lvm

pvcreate /dev/mapper/lvm
vgcreate volume /dev/mapper/lvm
lvcreate -L20G volume -n swap
lvcreate -l 100%FREE volume -n root

mkfs.vfat -F32 /dev/sda1
mkfs.ext4 /dev/mapper/volume-root
mkswap /dev/mapper/volume-swap

mount /dev/mapper/volume-root /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/mapper/volume-swap

Install base system

pacstrap /mnt base base-devel linux linux-firmware lvm2 netctl dialog wpa_supplicant git vim tmux zsh 

Generate fstab

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

(If you have SSD change relatime on all non-boot partitions to noatime.)

chroot into new system and prepare it

arch-chroot /mnt

ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime
hwclock --systohc

echo <your-hostname> > /etc/hostname

passwd
useradd -m -G wheel -s /usr/bin/fish <username>
passwd <username>

Set locales

Uncomment en_US.UTF-8 UTF-8 and other needed localizations in /etc/locale.gen

echo LANG=en_US.UTF-8 > /etc/locale.conf
echo KEYMAP=<your-keymap> > /etc/vconsole.conf
locale-gen

mkinitcpio

bootctl --path=/boot install

Edit /etc/mkinitcpio.conf

HOOKS=(base udev autodetect keyboard keymap modconf block encrypt lvm2 filesystems keyboard fsck)

Configure bootloader

Create /boot/loader/entries/arch.conf

title	Arch Linux
linux	/vmlinuz-linux
initrd	/initramfs-linux.img
options cryptdevice=UUID=<DEVICE-UUID>:volume root=/dev/mapper/volume-root rw

(use :r ! blkid /dev/sda2 -sUUID -ovalue in vim to get the device UUID)

Edit /boot/loader/loader.conf

default arch
timeout 3
editor yes

Finish installation and boot to new system

mkinitcpio -p linux
exit
umount -R /mnt
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment