Install Arch Linux on EFI system with full filesystem (including /boot) encrypted and on btrfs partition
Official guide for basic install: https://wiki.archlinux.org/index.php/Installation_Guide
it is always good to consult with official guide, cause arch config might change in time
For setting up different locale, or better explanations check out Arch Wiki
Download the ISO file from https://www.archlinux.org
dd if=archlinux.img of=/dev/sdX bs=16M && syncExtend writable space so you can install basic desktop in live environment and for example use gparted for partitioning or open this tutorial in web browser or whatever you want.
Remember this area is saved in your RAM, so make sure you have enough of it
mount -o remount,size=5G /run/archiso/cowspace
pacman -Syy plasma-desktop glibc konsole xorg
pacman -Scc
startplasma-wayland
loadkeys pl timedatectl set-ntp true reflector --country 'Poland' --age 24 --verbose --sort rate --save /etc/pacman.d/mirrorlist pacman -Syy btrfs-progslsblkfdisk /dev/sdX - 100MB EFI partition
- 100% size partiton # ( encrypted optionally) for BTRFS partition, this partition will require formatting AFTER encryption if you do encryption
mkfs.vfat -F32 /dev/sdX1Don't use regional letters (not in en-us keyboard) like ąęć etc. for password. This requires additional steps, which are not covered by this tutorial.
cryptsetup -c=aes-xts-plain64 --key-size=512 --hash=sha512 --iter-time=3000 --pbkdf=pbkdf2 --use-random luksFormat --type=luks1 /dev/sdX2
cryptsetup luksOpen /dev/sdX2 MainPart mkfs.btrfs -L "Arch Linux" /dev/mapper/MainPart pacman -Syy btrfs-progs
mkfs.btrfs -L "Arch Linux" /dev/sdX2 mount /dev/sdX2 /mnt This scheme can be adjusted to your needs, I'd suggest at least one subvolume for root (@) and one for snapshots (@snapshots). varlog and tmp are created to easily disable Copy on Write on /var/log and /tmp.
btrfs su cr /mnt/@
btrfs su cr /mnt/@home
btrfs su cr /mnt/@varlog
btrfs su cr /mnt/@tmp
btrfs su cr /mnt/@snapshots
chattr +C /mnt/@varlog
chattr +C /mnt/@tmp
umount /mnt
mount -o defaults,noatime,discard,ssd,subvol=@ /dev/sdX2 /mnt
mkdir /mnt/home
mkdir -p /mnt/var/log
mkdir /mnt/tmp
mkdir /mnt/snapshots
mkdir /mnt/efi # for EFI partition /dev/sdX1 mount -o defaults,noatime,discard,ssd,subvol=@home /dev/sdX2 /mnt/home
mount -o defaults,noatime,discard,ssd,subvol=@varlog /dev/sdX2 /mnt/var/log
mount -o defaults,noatime,discard,ssd,subvol=@tmp /dev/sdX2 /mnt/tmp
mount -o defaults,noatime,discard,ssd,subvol=@snapshots /dev/sdX2 /mnt/snapshots
mount /dev/sdX1 /mnt/efivim /etc/pacman.d/mirrorlist This command can be customized with additional packages (btrfs-progs is necessary to let the system boot up from btrfs partition !)
pacstrap /mnt/ base base-devel git btrfs-progs efibootmgr linux linux-headers linux-firmware mkinitcpio dhcpcd bash-completion sudogenfstab /mnt >> /mnt/etc/fstabarch-chroot /mnt /bin/bashln -s /usr/share/zoneinfo/Europe/Warsaw /etc/localtime
hwclock --systohc --utc myhostname
KEYMAP=pl
FONT=Lat2-Terminus16.psfu.gz
FONT_MAP=8859-2
locale-genLANG=en_US.UTF-8
LC_COLLATE=pl_PL.UTF-8
LC_MEASUREMENT=pl_PL.UTF-8
LC_MONETARY=pl_PL.UTF-8
LC_NUMERIC=pl_PL.UTF-8
LC_TIME=pl_PL.UTF-8
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname
Create separate subvolume for swapfile. This subvolume is needed to let you make snapshot of /, which would not be possible with any file in it with CoW disabled!
btrfs su create /swap
chattr +C /swap
touch /swap/swapfile Check if C attribute is enabled (should be already if created in folder with disabled CoW attribute)
lsattr /swap/swapfile'chattr +C /swap/swapfile dd if=/dev/zero of=/swap/swapfile bs=1024K count=4096
chmod 600 /swap/swapfile
mkswap /swap/swapfile swapon /swap/swapfile /swap/swapfile none swap sw 0 0
passwd useradd -m MYUSERNAME
passwd MYUSERNAME vim /etc/mkinitcpio.conf HOOKS=(base udev autodetect keyboard keymap modconf block btrfs filesystems keyboard fsck)
BINARIES=(btrfsck)
HOOKS=(... keyboard keymap block encrypt btrfs ... filesystems ...)
mkinitcpio -P pacman -S grub efibootmgr os-prober dosfstools mtools GRUB_ENABLE_CRYPTODISK=y
blkid (temporarly you can use /dev/sdX2 in place of "UUID=<device-UUID>" and change it later easy in gui mode)
GRUB_CMDLINE_LINUX="cryptdevice=UUID=<device-UUID>:MainPart:allow-discards"
dd bs=512 count=4 if=/dev/random of=/crypto_keyfile.bin iflag=fullblock
chmod 600 /crypto_keyfile.bin
chmod 600 /boot/initramfs-linux*
cryptsetup luksAddKey /dev/sdX2 /crypto_keyfile.bin FILES=(/crypto_keyfile.bin)
then run:
mkinitcpio -P grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg exit swapoff -a
umount -R /mntreboot shutdown now git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
localectl status