Arch Linux: mount LVM partitions and run mkinitcpio

By | 04/15/2025

It’s not often, but sometimes I need to boot the system from a USB and rebuild initramfs-linux.img.

This post is more of a quick note to myself on how, what, and where to mount on my laptop to run mkinitcpio, as I have LVM partitions, separate disk partitions for /boot, and swap.

iwctl and WiFi

So, we boot from the USB drive with Arch Linux live image, and set up WiFi so that we can do all the commands from another computer where we can copy from the RTFM blog:

[root@archiso ~]# iwctl # station wlan0 connect setevoy-linksys-5-0

Set the root password :

[root@archiso ~]# passwd root

Get the IP:

[root@archiso ~]# ip a s wlan0 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 inet 192.168.3.114/24 brd 192.168.3.255 scope global dynamic noprefixroute wlan0

And connect to this laptop from another laptop or PC:

[setevoy@setevoy-home-laptop ~] $ ssh [email protected]

Mounting LVM partitions

Finde the volume group:

[root@archiso ~]# vgscan Found volume group "vg_arch" using metadata type lvm2

Activate it:

[root@archiso ~]# vgchange -ay 2 logical volume(s) in volume group "vg_arch" now active

Let’s remember which logical volumes are in the system.

I have two of them – one root for the system, the other one for the $HOME:

[root@archiso ~]# lvdisplay --- Logical volume --- LV Path /dev/vg_arch/root ... --- Logical volume --- LV Path /dev/vg_arch/home ...

Mount /dev/vg_arch/root to /mnt:

[root@archiso ~]# mount /dev/vg_arch/root /mnt/

Mounting /boot

Let’s see the rest of the disks and partitions:

[root@archiso ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 820.6M 1 loop /run/archiso/airootfs sda 8:0 1 28.9G 0 disk └─sda1 8:1 1 28.9G 0 part nvme0n1 259:0 0 465.8G 0 disk ├─nvme0n1p1 259:1 0 512M 0 part ├─nvme0n1p2 259:2 0 1G 0 part ├─nvme0n1p3 259:3 0 32G 0 part └─nvme0n1p4 259:4 0 432.3G 0 part ├─vg_arch-root 254:0 0 100G 0 lvm /mnt └─vg_arch-home 254:1 0 332.3G 0 lvm

This is the tricky part, where I keep forgetting that I have mounted and how I have it. But we have the fstab where everything is described.

For example, I once spent a lot of time rebuilding the initramfs image, but the system still wouldn’t boot.

It was only after a while that I remembered that I had /boot on a separate partition:

[root@archiso ~]# cat /mnt/etc/fstab # /dev/mapper/vg_arch-root UUID=8569a65c-d848-427d-bcd0-5046d0e07f2b / ext4 rw,relatime 0 1 # /dev/mapper/vg_arch-home UUID=0ae5ba43-3bb3-4826-8570-8918a82bf27f /home ext4 rw,relatime 0 2 # /dev/nvme0n1p1 UUID=54C4-1990 /boot/EFI vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2 # /dev/nvme0n1p2 UUID=6a42ffb4-6811-4176-b26e-873f49aea3b0 /boot ext2 rw,relatime 0 2 # /dev/nvme0n1p3 UUID=08d2ae9d-28fa-4d20-9d06-72d1b7fdc21d none swap defaults 0 0

So, mount /dev/nvme0n1p2 to /mnt/boot/:

[root@archiso ~]# mount /dev/nvme0n1p2 /mnt/boot/

Let’s see what’s there now – and now there’s nothing, because during my latest system’s upgrade, there was not enough space in /tmp, and the new initramfs-linux.img was not built:

[root@archiso ~]# ls -l /mnt/boot/ total 24 drwxr-xr-x 2 root root 4096 Dec 7 2020 EFI drwxr-xr-x 6 root root 4096 Dec 7 2020 grub drwx------ 2 root root 16384 Dec 7 2020 lost+found

And now you can actually build the system.

Starting mkinitcpio

Everything is simple here – install packages in /mnt using the pactrap:

[root@archiso ~]# pacstrap /mnt base linux linux-firmware

Perform chroot, and run mkinitcpio:

[root@archiso ~]# arch-chroot /mnt/ 11:27:22 [root@archiso /] # mkinitcpio -p linux ==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default' ==> Using configuration file: '/etc/mkinitcpio.conf' -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img ...

Check /boot again – now everything is in place:

11:28:48 [root@archiso /] # ls -l /boot/ total 68000 drwxr-xr-x 2 root root 4096 Dec 7 2020 EFI drwxr-xr-x 6 root root 4096 Dec 7 2020 grub -rw------- 1 root root 41323222 Mar 3 11:28 initramfs-linux-fallback.img -rw------- 1 root root 14137751 Mar 3 11:28 initramfs-linux.img drwx------ 2 root root 16384 Dec 7 2020 lost+found -rw-r--r-- 1 root root 14053888 Mar 3 11:26 vmlinuz-linux

Done – reboot to the main system.