Introduction
This is my own guide for installing Arch Linux on bare metal machine with UEFI, encrypted LVM and separate /home partition.
Steps
First you need to create and boot the installation media on your PC, as the result you will boot into plain console.
Increase font size
As most modern laptops/PCs have large resolution displays I recommend increasing the font size:
setfont ter-132b
Setup the internet connection
In this example I have a laptop with Wi-Fi modem, so I’ll be using iwd
to setup the internet connection.
Run iwd:
iwctl
View a list of Wi-Fi adapters:
device list
Usually you should see one Wi-Fi device in output, in my case it is wlan0
Then if you know the station SSID and password, simply connect to the station, and don’t forget to replace {SSID} with your actual value:
station wlan0 connect {SSID}
Then exit the iwctl by typing exit
, then do the ping 8.8.8.8
to ensure you are connected to the internet.
Synchronize system clock
timedatectl set-ntp true
Partition your disk
In my case I want to have separate root
, /boot
and /home
partitions, moreover /
and /home
should be encrypted by LVM and be in the same volume group.
Detect your drive
First, we need to know what device to user, to view the disk devices use:
fdisk -l
In my case it is the NVMe SSD drive /dev/nvme0n1
.
Partitioning
Next, use gdisk /dev/nvme0n1
to create partitions with this layout:
/dev/nvme0n1p1
- at least 512M - typeEF00
- EFI System Partition/dev/nvme0n1p2
- rest of disk - type8309
- LUKS
Format the physical partitions
- EFI Partition
mkfs.vfat -F 32 /dev/nvme0n1p1
- LUKS Encrypted partition
cryptsetup luksFormat /dev/nvme0n1p2
Create volume group and logical volumes
First, open the encrypted container:
cryptsetup luksOpen /dev/nvme0n1p2 luks
As the result the encrypted partition is mounted at /dev/mapper/luks
.
Next, treat /dev/mapper/luks
as an LVM PV and create your volumes. In my case are like:
- Volume Group
vg0
- Logical Volume
lv_root
- Probably at least 20G, I use 75G - Logical Volume
lv_swap
- Optional, maybe not desirable if you have an SSD - Logical Volume
lv_home
- Rest of the space
- Logical Volume
The commands to achieve this:
|
|
Format the logical volumes
I will use ext4 filesystems for my setup, here you can use something different (like btrfs).
To format root and home partitions in ext4:
|
|
To format the swap partition and enable it:
|
|
Mount the partitions
This step is required to mount the created partitions and install the Arch Linux system there. All the filesystems should be mounted considering /mnt
as a root filesystem for the future installed system.
|
|
Install the base system
pacstrap -K /mnt base base-devel linux linux-firmware linux-headers
Generate the fstab file
genfstab -U /mnt >> /mnt/etc/fstab
Chroot into your system
arch-chroot /mnt
Generate locale
Uncomment en_US.UTF-8 UTF-8
and other needed locales in file /etc/locale.gen
.
Then generate locales:
locale-gen
To set the system locale:
echo "LANG=en_US.UTF-8" > /etc/locale.conf
Setup the hostname
This is actually the analog of computer name in Windows, in my case I will name it thinkpad
.
echo "thinkpad" > /etc/hostname
Also add the default values to the /etc/hosts
file:
|
|
Setup TimeZone
My timezone is Europe/Kiev
, so in my case this sumlink should be created:
ln -s /usr/share/zoneinfo/Europe/Kiev /etc/localtime
And also I recommend switch the BIOS hardware clock to UTC:
hwclock --systohc --utc
Setup initramfs
Install the lvm2 package:
pacman -S lvm2
Edit the /etc/mkinitcpio.conf
file and insert hooks encrypt
and lvm2
strictly in this order between the block
and filesystems
hooks like this:
HOOKS=(base udev ... block encrypt lvm2 filesystems)
Then re-generate the initramfs:
mkinitcpio -P
Create a user and credntials
First it is recommended to change the root user password:
passwd root
Then install sudo package to allow your user grant privileges:
pacman -S sudo
Then edit the sudoers file:
sudo EDITOR=nano visudo
And uncomment the line %wheel ALL=(ALL:ALL) ALL
and save the file.
Create a user, change the password and add it to the necessary groups:
|
|
Install the needed packages and desktop environment
This is optional step and you may do the same after install, but I’d like to be able to use the DE straigt after install.
In this example I will install Gnome DE (on Wayland and PipeWire) with NetworkManager.
pacman -S gnome networkmanager gnome pipewire \
pipewire-alsa pipewire-pulse pipewire-jack \
wireplumber bluez bluez-utils
Then start the needed services by default
|
|
Install the bootloader
I will use systemd-boot as my bootloader, to install it, run:
bootctl install
Then create the bootloader config at /boot/loader/loader.conf
containing this:
|
|
To load your CPU microcode early at bootloader install amd-ucode
or intel-ucode
package, in my case I have Intel CPU, so command is:
pacman -S intel-ucode
Then detect the UUID of your LVM encrypted partition (in my case /dev/nvme0n1p2):
blkid /dev/nvme0n1p2
Then create the boot entry for your Arch Linux system at /boot/loader/entries/arch.conf
, make sure to replace the UUID and correct root partition in the options
parameter:
|
|
Finally check the bootctl and validate that the config is correct in bootctl list
.
Reboot to your new system
To reboot you need:
- type
exit
to exit the chroot shell. - then do
umount -R /mnt
to unmount your partitions. - finally type
reboot