Skip to content

Instantly share code, notes, and snippets.

@KarthikNayak
Last active August 11, 2024 05:04
Show Gist options
  • Save KarthikNayak/912c268aa62c3ede3c0f707164f2d4ab to your computer and use it in GitHub Desktop.
Save KarthikNayak/912c268aa62c3ede3c0f707164f2d4ab to your computer and use it in GitHub Desktop.
Installing Arch with LVM

https://wiki.archlinux.org/index.php/beginners'_guide

What I wanted:

  1. LVM
  2. UEFI/GPT

###Connect to Wifi

wifi-menu -o <dev_name>

The device name can be obtained from ip link.

###Update the system clock

timedatectl set-ntp true

###Partitioning the hard disk

Since this was an unused harddisk I created two partitions, one for boot and the other for LVM. We can use parted for making partitions.

parted /dev/sdX

Create a GPT partition as so:

(parted) mklabel gpt

The boot partition should be around <1Gb so we can create that by:

(parted) mkpart ESP fat32 1MiB 513MiB
(parted) set 1 boot on

Create another partition for the LVM:

(parted) mkpart primary ext4 513MiB 100%

To create partitions under LVM we need to first create a physical volume under which we'll have volume group under which we'll finally have logical volumes. Lets first create a physical volume:

pvcreate /dev/sda2

sda2 because sda1 was our boot partition. Modify accordingly.
Next create the volume group:

vgcreate lvm /dev/sda2

Create logical volumes, for a basic setup we'd need one for root, swap and home.

lvcreate -L 30G lvm -n root
lvcreate -L 8G lvm -n swap
lvcreate -l 100% lvm -n home

###Format the file systems and enable swap

List existing partition using lsblk.

Format the boot partition first:

mkfs.fat -F32 /dev/sda1

Format the other partitions:

mkfs.ext4 /dev/lvm/root
mkfs.ext4 /dev/lvm/home

Enable Swap:

mkswap /dev/lvm/swap
swapon /dev/lvm/swap

Mount the partitions:

mount /dev/lvm/root /mnt
mkdir -p /mnt/home
mount /dev/lvm/home /mnt/home
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot

###Install the base packages

Install the base packages using pacstrap:

pacstrap -i /mnt base base-devel

###Configuration

####Generate the fstab file:

genfstab -U /mnt >> /mnt/etc/fstab

####Change root:

arch-chroot /mnt /bin/bash

####Locale:

Possible values are listed in /etc/locale.gen. Uncomment en_US.UTF-8 UTF-8, as well as other needed localisations. Save the file, and generate the new locales:

locale-gen

Create /etc/locale.conf, where LANG refers to the first column of an uncommented entry in /etc/locale.gen:

LANG=en_US.UTF-8

####Time

Create the symbolic link /etc/localtime, where Zone/Subzone is the TZ value from $ tzselect:

ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime

Set the time standard to UTC:

hwclock --systohc --utc

####Initramfs

First we need to edit /etc/mkinitcpio.conf to provide support for lvm2.
Edit the file and insert lvm2 between block and filesystems like so:

HOOKS="base udev ... block lvm2 filesystems"

Generate the initramfs image:

mkinitcpio -p linux

###Install a boot loader

Install systemd-boot to the EFI system partition:

bootctl install

Now we need to create a boot entry. Edit /boot/loader/loader.conf:

default  arch
timeout  4
editor   0

Create the arch entry by editing /boot/loader/entries/arch-lvm.conf:

title          Arch Linux (LVM)
linux          /vmlinuz-linux
initrd         /initramfs-linux.img
options        root=/dev/mapper/lvm-root rw

###Configure the network

####Wireless

Install iw, wpa_supplicant, and (for wifi-menu) dialog:

pacman -S iw wpa_supplicant dialog

###Root password

Set the root password with:

passwd

###Unmount the partitions and reboot

Ctrl + D
umount -R /mnt
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment