LLI Wiki — My Digital Knowledge Base

Installing Arch Linux on UEFI with LVM

GPT partitioning, LVM volumes, file systems and mount points for an Arch Linux installation on UEFI.

This guide describes how to partition a disk for UEFI with LVM before installing Arch Linux (or an Arch-based distribution). Device and volume names (/dev/sda, arch-lvm) are examples to adapt. The commands below erase the data on the target disk.

Partition table

Create a GPT table with three partitions: an EFI System Partition (ESP), a /boot partition and a partition for LVM.

Partition Range Role
/dev/sda1 1 MiB to 513 MiB EFI System Partition (FAT32, boot flag)
/dev/sda2 513 MiB to 800 MiB /boot
/dev/sda3 800 MiB to 100% LVM physical volume
parted /dev/sda
(parted) mklabel gpt
(parted) mkpart ESP fat32 1MiB 513MiB
(parted) set 1 boot on
(parted) name 1 efi
(parted) mkpart primary 513MiB 800MiB
(parted) name 2 boot
(parted) mkpart primary 800MiB 100%
(parted) name 3 lvm-partition
(parted) print
(parted) quit

LVM volumes

parted /dev/sda set 3 lvm on
parted /dev/sda print

pvcreate /dev/sda3
vgcreate arch-lvm /dev/sda3

lvcreate -n arch-root -L 20G arch-lvm
lvcreate -n arch-swap -L 2G arch-lvm
lvcreate -n arch-home -l 100%FREE arch-lvm
lvs

File systems and mount points

mkfs.fat -F32 /dev/sda1
mkfs.ext2 /dev/sda2
mkfs.btrfs -L root /dev/arch-lvm/arch-root
mkfs.btrfs -L home /dev/arch-lvm/arch-home
mkswap /dev/arch-lvm/arch-swap
swapon /dev/arch-lvm/arch-swap

mount /dev/arch-lvm/arch-root /mnt
mkdir /mnt/{home,boot}
mount /dev/sda2 /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
mount /dev/arch-lvm/arch-home /mnt/home

Then install the base system with the distribution installer (or pacstrap), and generate the fstab file:

genfstab /mnt >> /mnt/etc/fstab

GRUB on a UEFI virtual machine

Replace /path/to/esp/mountpoint with the mount point of the EFI partition (here /boot/efi in the installed system).

grub-install --target=x86_64-efi --efi-directory=/path/to/esp/mountpoint --removable

References

Mastodon LLIMastodon SocialFosstodon