I have been using Arch Linux for over a year now, and while I mostly enjoy it, installing it is rather cumbersome. Following Installation Guide on ArchWiki seems simple (kind of) but you will always forget to do something. More so if you want to diverge from their steps. Things like using a bootloader, encryption, or dualbooting are not exactly easy to follow for first time users.
To avoid problems in future installations I have put together a thorough guide. It is tailored to my needs. I am using Lenovo Thinkpad T480s with NVME SSD, integrated GPU and UEFI. I want to have Linux partition encrypted with LVM on LUKS method without the swap partition. I will be dualbooting with Windows 10.
You might need to adjust the following commands to your hardware (different network interface or disk names). Good luck.
Windows 10 Installation
It is recommended to first install the Windows system first and then Linux.
-
Plug in Windows installation media (USB stick or CD).
-
Delete all partitions. From the empty space create new partition for Windows. Size does not matter right now. Windows will create few required system partitions for you.
-
Keep the first partition named Recovery (around 500 MB large) and delete all other partitions. Reason for this is that Windows creates too small EFI partition (~ 100 MB). It might be enough for Windows but you would get out of space pretty quickly when you add more systems. For dualbooting, more space is needed.
-
Press
Shift+F10
and type the following commands:diskpart
select disk 0
create partition efi size=500
exit
-
Now close the command line and click Refresh in partitions list. You should see two partitions: Recovery and System (EFI).
-
From the remaining empty space on the disk create a new partition for Windows again. Don't use full disk capacity for Windows partition and leave empty disk space for Arch installation (e.g. 150 GB for Windows and rest empty). Installation media should add only the remaining partitions that we have deleted previously and have not created them manually in CMD.
-
Continue with installation. Unplug the ethernet cable to use local account instead of online login (tell me something about dark patterns).
-
After installation finishes, disable Fast Boot in system power management settings.
-
Set time to use NTP so your time in Windows is correct. Open CMD with Administrator privileges and run following command.
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_QWORD /f
And you are done. You can set whatever else you require (like encryption or installing apps). This is outside the scope of this tutorial.
Arch Linux ISO
After you have installed Windows, unplug Windows installation media and plug your Arch installation media. Boot into Arch ISO.
-
List available network interfaces with
ip link
. Enable ethernet withsystemctl start dhcpcd@interface_name
or wifi bywifi-menu
. -
Test connection by
ping 8.8.8.8
(Google DNS servers). If ping returns an error, wait a few seconds. Starting the network interface might take some time. -
Update the repository index using
pacman -Syyy
. -
Update system clock with
timedatectl set-ntp true
. -
List all partitions by
fdisk -l
. -
Use
fdisk /dev/nvme...
to open correct disk.- Press
n
to create new partition. Accept everything to create partition from all remaining space. - Now type
t
, choose partition number (5
in my case) and then type31
. - Save changes with
w
. - Exit.
- Press
-
Encrypt partition using dm-crypt with LVM on LUKS. You will have one large encrypted partition which will contain virtual partitions for root and home.
cryptsetup luksFormat /dev/partition_name
cryptsetup open /dev/partition_name cryptlvm
pvcreate /dev/mapper/cryptlvm
vgcreate vg /dev/mapper/cryptlvm
(namevg
can be changed)lvcreate -L 32G vg -n root
will create smaller partition for root (/
) directory.lvcreate -l 100%FREE vg -n home
will use the rest empty space to create another partition for/home
.mkfs.ext4 /dev/vg/root
mkfs.ext4 /dev/vg/home
-
Mount partitions.
mount /dev/vg/root /mnt
mkdir /mnt/home
mount /dev/vg/home /mnt/home
mkdir /mnt/boot
mount /dev/efi_partition /mnt/boot
mounts EFI partition created by Windows. It is usually second partition.
-
Next, install required packages.
pacstrap /mnt base linux linux-lts linux-firmware base-devel lvm2 intel-ucode man-db man-pages vim
-
genfstab -U /mnt >> /mnt/etc/fstab
Chroot into Arch
-
arch-chroot /mnt
-
ln -sf /usr/share/zoneinfo/Europe/Prague /etc/localtime
-
hwclock --systohc
-
Uncomment
en_US.UTF-8 UTF-8
in/etc/locale.gen
. -
locale-gen
-
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
-
echo "arch" >> /etc/hostname
-
Open
/etc/hosts
.127.0.0.1 localhost ::1 localhost 127.0.1.1 arch.localdomain arch
-
Edit
/etc/mkinitcpio.conf
HOOKS=(base udev autodetect keyboard keymap modconf block encrypt lvm2 filesystems fsck)
-
Recreate initramfs by
mkinitcpio -P
. -
passwd
-
useradd -m -g users -G wheel your_user_name
passwd your_user_name
-
Install DE (Plasma for me) and other useful things like ZSH, terminal emulator and GPU drivers.
- Install packages first.
pacman -S plasma-meta kde-applications-meta xorg xf86-video-intel mesa sddm kitty git htop zsh zsh-autosuggestions zsh-completions zsh-syntax-highlighting
systemctl enable sddm.service
to enable desktop manager.
-
Install bootloader (systemd-boot). I will include both Linux Stable and LTS version. It might be very useful in the future.
-
bootctl --path=/boot install
-
Create file
/boot/loader/entries/arch.conf
. You can find partition UUID in VIM by command:r !blkid
. Copy UUID for main partition (not virtual group or volume).title Arch Linux Stable linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options cryptdevice=UUID=YOUR-DEVICE-UUID:cryptlvm root=/dev/mapper/vg-root rw quiet
-
For backup Linux LTS kernel, add second boot entry to
/boot/loader/entries/arch-lts.conf
. This comes handy when stable kernel goes wild.title Arch Linux LTS linux /vmlinuz-linux-lts initrd /intel-ucode.img initrd /initramfs-linux-lts.img options cryptdevice=UUID=YOUR-DEVICE-UUID:cryptlvm root=/dev/mapper/vg-root rw quiet
-
Edit
/boot/loader/loader.conf
. You can choose eitherarch
orarch-lts
as default boot option.default arch timeout 4
-
-
Create swap file using systemd-swap. I use this instead of dedicated swap partition.
-
pacman -S systemd-swap
-
Set swappiness in file
/etc/sysctl.d/99-sysctl.conf
.vm.swappiness=5
-
Customize value inside file
/etc/sysctl.d/99-sysctl.conf
.vm.vfs_cache_pressure=50
-
Type
sysctl -p /etc/sysctl.d/99-sysctl.conf
. -
Inside file
/etc/systemd/swap.conf
edit following lines. They will not be together and you have to find them.zram_enabled=0 zswap_enabled=1 swapfc_enabled=1
-
I had to set
swapfc_force_preallocated=1
in file/etc/systemd/swap.conf
. Otherwise I had errors. This might not apply to you. See Swap on ArchWiki. -
Start service.
systemctl enable systemd-swap.service
-
-
exit
-
umount -R /mnt
-
reboot
-
Pray.
After rebooting you should be greeted with black screen asking for your encryption key. This will be shown on every cold-boot. Use password that you used for encryption, not your user account (they might not be the same depending on your setup).
If you do not see prompt for unlocking your partition, something went wrong. Welcome to the Arch world. In my case, most problems were usually with bootloader or fstab. Make sure you pass the correct partition UUID.
Final touch
This part is entirely optional. You will probably want to enable sudo
though.
-
Change default shell
chsh -s /bin/zsh
. -
Add user to sudoers. Install
vi
package. Then runvisudo
and uncommentwheel
. You can disable timeout.Defaults passwd_timeout=0
-
Enable multicore to makepkg in
/etc/makepkg.conf
.COMPRESSXZ=(xz -c -z - --threads=0)
(0 for all cores or pick number)
-
To enable proper tray icons, install
libappindicator-gtk3
(this will make tray icon sharp and pretty). -
If there is no WiFi icon:
sudo systemctl enable NetworkManager.service
-
In case you suffer from long DNS resolution (approx. 5 seconds), add this line to your
/etc/resolv.conf
file.options single-request
-
To enable emojis, install
ttf-joypixels
. -
You will probably want to use AUR packages. Install yay for easier usage.
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd .. && rm -rf yay
to delete now useless folder.
-
Enable SSD TRIM:
sudo systemctl enable --now fstrim.timer
-
Important. Create alias for
sudo
command to make your Linux usage more civilized. Open file~/.zshrc
or~/.bashrc
depending on your shell. Then add this line.alias please="sudo"
After this you can use commands like
please reboot
instead of rudesudo reboot
.