Skip to content

Instantly share code, notes, and snippets.

@p7cq
Last active June 4, 2023 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p7cq/93fbc7f7b0a79cf2c910e9aec5dae88b to your computer and use it in GitHub Desktop.
Save p7cq/93fbc7f7b0a79cf2c910e9aec5dae88b to your computer and use it in GitHub Desktop.
Install Arch Linux with Root on LVM

Arch Linux with Root on LVM

Arch Linux with root on LVM and systemd boot.

  • Set a bigger font (if using a 4K laptop display)
setfont latarcyrheb-sun32
  • To connect to the internet add the ESSID and passphrase
 wpa_passphrase ESSID PASSPHRASE > /etc/wpa_supplicant/wpa_supplicant.conf
  • Start wpa_supplicant and get an IP address
wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i <wifi interface>
dhclient <wifi interface>
  • Setup time zone:
timedatectl set-timezone Region/City
  • Partitioning
sgdisk --zap-all /dev/disk/by-id/nvme-disk1
sgdisk -n1:0:+550M -t1:ef00 /dev/disk/by-id/nvme-disk1
sgdisk -n2:0:+450G -t2:8e00 /dev/disk/by-id/nvme-disk1

sgdisk --zap-all /dev/disk/by-id/nvme-disk2
sgdisk -n1:0:+550M -t1:ef00 /dev/disk/by-id/nvme-disk2
sgdisk -n2:0:+450G -t2:8e00 /dev/disk/by-id/nvme-disk2
  • Create physical volumes
pvcreate /dev/disk/by-id/nvme-disk1-part2 /dev/disk/by-id/nvme-disk2-part2
  • Create volume group
vgcreate vg_root /dev/disk/by-id/nvme-disk1-part2 /dev/gidk/by-id/nvme-disk2-part2
  • Create logical volume
lvcreate -L 400G -n root vg_root
lvcreate -L 16G -n swap vg_root
  • Format the boot partition and logical volumes
mkfs.vfat -F 32 /dev/disk/by-id/nvme-disk1-part1
mkfs.ext4 /dev/vg_root/root
mvswap /dev/vg_root/swap
swapon /dev/vg_root/swap
  • Mount
mount /dev/vg_root/root /mnt
mkdir /mnt/boot
mount /dev/disk/by-id/nvme-disk1-part1 /mnt/boot
  • Bootstrap system
pacstrap /mnt base base-devel linux linux-firmware lvm2 dmraid
  • Generate fstab
genfstab -U /mnt >> /mnt/etc/fstab
  • Change root into the new system
arch-chroot /mnt
  • Configure time zone
ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
hwclock --systohc
  • Generate locale
sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
  • Set hostname
  • Set hosts
echo -e "127.0.0.1 localhost\n::1 localhost" >> /etc/hosts
  • Set root password
  • Install processor's microcode and some other software
pacman -Syu amd-ucode wpa_supplicant networkmanager vim sudo dhclient openssh lvm2 dmraid
  • Install bootloader
bootctl --path=/boot install
  • Add an EFI boot manager update hook in /etc/pacman.d/hooks/100-systemd-boot.hook
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd

[Action]
Description = update systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update
  • Replace content of /boot/loader/loader.conf with
default arch
timeout 3
# bigger boot menu on a 4K display
#console-mode 1
  • Create a /boot/loader/entries/arch.conf containing
title Arch Linux
linux /vmlinuz-linux
initrd /amd-ucode.img
initrd /initramfs-linux.img
options root=/dev/mapper/vg_root-root rw
  • Modify mkinitcpio.conf adding the appropriate RAID modules and hooks
MODULES=(dm-raid raid0 raid1 raid10)
#HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
HOOKS=(base systemd autodetect modconf block sd-lvm2 filesystems keyboard fsck)
  • Regenerate initramfs
mkinitcpio -p linux
  • Exit jail, unmount all and reboot
exit
umount -R /mnt
reboot

References:

https://wiki.archlinux.org/index.php/Install_Arch_Linux_on_LVM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment