Guide to install Arch Linux on an EFI System. Includes these features:
- Full Disk Encryption with LUKS
- BTRFS with
@and@homesubvolumes - Timeshift Backups
- Encrypted Swap Partition
- rEFInd bootloader
- SDDM display manager
- KDE Plasma desktop environment
Enable Time Sync
timedatectl set-ntp trueList your disks
lsblkFormat the disk you want to install arch on by using sgdisk. Typically most disks are labeled as /dev/sda , /dev/vda, or /dev/nvme0n1
sgdisk -Z /dev/sdaOnce formatted use gdisk to begin to partition the drive
gdisk /dev/sdaType n and hit enter to create a new partition.
Hit enter to leave the defaults for the partition start.
Type +512M and hit enter to create a 512MB size partition.
Type ef00 and hit enter to choose EFI partition type.
Type n and hit enter to create a new partition.
Hit enter to leave the defaults for the partition start.
Type +16G and hit enter to create a 16G size partition. (Swap sizes can be larger or smaller but it is recommended to match your swap to the amount of ram within the system)
Type 8200 and hit enter to choose Linux Swap partition type.
Type n and hit enter to create a new partition.
Hit enter to leave the defaults for the partition start.
Hit enter to use the remainder of the disk.
Hit enter to choose the default partition type.
Hit w to write the changes
List out all the partitions. They are laid out as /dev/sda1, /dev/sda2 , /dev/sda3 or /dev/nvme0n1p1, /dev/nvme0n1p2, /dev/nvme0n1p3.
lsblkFormat EFI Partition as FAT32
mkfs.fat -F32 /dev/sda1Temporary enable swap partition
mkswap /dev/sda2
swapon /dev/sda2Enable the Encryption Modules
modprobe dm-crypt
modprobe dm-modEncrypt the root partition
cryptsetup luksFormat -v -s 512 -h sha512 /dev/sda3Type out "YES" in call caps and create a secure passphrase for the partition (Recommended to use 25 - 30 characters). Verify the passphrase.
Unlock the newly encrypted drive
cryptsetup luksOpen /dev/sda3 archlinuxEnter the passphrase
Format the root partition
mkfs.btrfs /dev/mapper/archlinux
Mount the archlinux partition
mount /dev/mapper/archlinux /mnt Move into the /mnt directory
cd /mntCreate the @ and @home BTRFS Subvolumes
btrfs subvolume create @
btrfs subvolume create @homeUnmount archlinux partition
cd
umount /mnt Mount newly created subvolumes and EFI
mount -o noatime,compress=zstd:1,space_cache=v2,discard=async,subvol=@ /dev/mapper/archlinux /mnt
# create a mount point for the home directory
mkdir /mnt/home
mount -o noatime,compress=zstd:1,space_cache=v2,discard=async,subvol=@home /dev/mapper/archlinux /mnt/home
# create a mount point for the EFI partiton
mkdir /mnt/boot
mount /dev/sda1 /mnt/bootUse pacstrap to install the base packages.
If you have an INTEL CPU
pacstrap /mnt base linux linux-firmware sudo vim intel-ucode btrfs-progsIf you have an AMD CPU
pacstrap /mnt base linux linux-firmware sudo vim amd-ucode btrfs-progsGenerate fstab
genfstab -U /mnt >> /mnt/etc/fstabEnter Arch Linux on the /mnt directory
arch-chroot /mntEdit the file system table and remove the subvolid from the @ and @home entries
vim /etc/fstab-rw,noatime,compress=zstd:1,ssd,space_cache=v2,subvolid=261,subvol=/@
+rw,noatime,compress=zstd:1,ssd,space_cache=v2,subvol=/@
-rw,noatime,compress=zstd:1,ssd,space_cache=v2,subvolid=261subvol=/@home
+rw,noatime,compress=zstd:1,ssd,space_cache=v2,subvol=/@Enable Time Sync
timedatectl set-ntp trueSet your timezone. For this example the timezone is The United States East Coast
timedatectl set-timezone America/New_YorkSync the hardware clock
hwclock --systohcEdit the locale gen to enable United States English UTF-8
vim /etc/locale.gen-#en_US.UTF-8 UTF-8
+en_US.UTF-8 UTF-8Regenerate locale file
locale-genSet the locale language, time, and keyboard
localectl set-locale LANG="en_US.UTF-8"
localectl set-locale LC_TIME="en_US.UTF-8"
localectl set-keymap usSet the hostname
vim /etc/hostname+archSet the host. Change arch to whatever the hostname is
vim /etc/hosts+ 127.0.0.1 localhost
+ ::1 localhost
+ 127.0.1.1 arch.localdomain archEdit the pacman configuration to enable parallel downloads and color
vim /etc/pacman.conf- #ParallelDownloads = 5
- #Color
+ ParallelDownloads = 5
+ ColorSync to the Arch servers and update packages
pacman -SyuInstall Arch Packages
Intel
pacman -S refind base base-devel linux linux-headers bash-completion efibootmgr sddm plasma iwd man intel-ucode kde-applications firewalld
AMD
pacman -S refind base base-devel linux linux-headers bash-completion efibootmgr sddm plasma iwd man amd-ucode kde-applications firewalld
Install Video Drivers
Intel
pacman -S xf86-video-intel mesa vulkan-intelAMD
pacman -S xf86-video-amdgpu mesa vulkan-radeonNvidia
pacman -S nvidia nvidia-utilsEnable the services on system startup
systemctl enable NetworkManager
systemctl enable avahi-daemon
systemctl enable sddmEdit mkinitcpio.conf and enable BTRFS
vim /etc/mkinitcpio.conf- MODULES=()
+ MODULES=(btrfs)Add the encryption hook
- HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
+ HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard fsck) Regenerate the ramdisk init environment
mkinitcpio -p linuxEnter the command to install rEFInd
refind-installList out all devices on the device and note down the UUID of the encrypted partiton
blkid
# /dev/sda3: UUID="83da0c42-4b61-498d-bebc-68b65dc1704f" TYPE="crypto_LUKS" PARTLABEL="Linux filesystem" PARTUUID="923b9107-492d-447f-9e86-18e496a9a0f7"
#Note the UUID (UUID="83da0c42-4b61-498d-bebc-68b65dc1704f")Edit the rEFInd configuration file
vim /boot/refind_linux.confAdd the cryptdevice flag to “Boot with Standard Options”
- "Boot with standard options" "loglevel=3 quiet"
+ "Boot with standard options" "loglevel=3 quiet cryptdevice=UUID=83da0c42-4b61-498d-bebc-68b65dc1704f:archlinux root=/dev/mapper/archlinux rootflags=subvol=@ rw"Reinstall rEFInd
refind-install
Create and user account and password. Replace user with the username
useradd -mG wheel user
passwd userEdit the sudoers to enable sudo access for the user
EDITOR=vim visudo- #%wheel ALL=(ALL) ALL
+ %wheel ALL=(ALL) ALLSync the system and reboot
sync
exit
umount -a
reboot -n
Create a Swap Offset
su
swapoff /dev/sda2
mkfs.ext2 -L cryptswap /dev/sda2 1M
#Press y when promptedOpen Cryptab
vim /etc/crypttabUncomment the swap
- #swap /dev/sd_X#_ /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256
+ swap LABEL=cryptswap /dev/urandom swap,offset=2048,cipher=aes-xts-plain64,size=512Edit swap entry in fstab
- UUID=ad1cdf6d-010f-43ae-8b64-7b9d54367dda none swap defaults 0 0
+ /dev/mapper/swap none swap defaults 0 0Reboot the system and enjoy your completed system :)
exit
sudo reboot -n
I've not been able to get this to work, lots of errors such as btrfs not being the correct format
btrfs subvolume create @
btrfs subvolume create @home
This should be:
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
There was also issues with other parts of the code unless it is something I am doing wrong?