Install Alpine on a btrfs filesystem with refind as boot manager

From Alpine Linux
Note: This tutorial assumes that your other OS is already installed and working with rEFInd as boot manager and your harddisk filesystem is btrfs. Eventhough, refind is available in the testing repository of Alpine Linux, this tutorial does not need it to be installed.

Boot your PC from the Alpine Linux USB. Once booted, log in as root (no password required). Identify your partitions by using the command.

# blkid

/dev/nvme0n1p1: UUID="55C3-8AB4" TYPE="vfat"
/dev/nvme0n1p2: UUID="dab64e31-fb89-4364-b90f-b79400f73304" TYPE="swap"
/dev/nvme0n1p3: LABEL="BTRFSVOL" UUID="823a3283-30a7-4fef-b50b-8a2230c71b5b" TYPE="btrfs"

Mount the btrfs partition to /mnt.

# mount /dev/nvme0n1p3 /mnt -t btrfs


Complete the Installation until the base configuration step using the setup script:

# setup-alpine

Once base configuration is complete, prepare your disk for installation of Alpine as a subvolume in the btrfs filesystem:

Create a new Btrfs subvolume for Alpine and you need btrfs-progs package

# apk add btrfs-progs

Create a new Btrfs subvolume for Alpine:

# btrfs subvolume create /mnt/@alpine

Create a new mountpoint and mount the newly created subvolume:

# mkdir /mnt/os

# mount -o subvol=@alpine /dev/nvme0n1p3 /mnt/os

Install the base system using the below command:

# setup-disk -m sys /mnt/os

This will install the base system to the mounted subvolume. Once the base system is installed, chroot into the new system:

# chroot /mnt/os

Edit /etc/fstab to use the correct subvolume. Ensure that root entry looks like below. Mounting the efi partition is optional. If you want to share your @home subvolume between both the operating systems, you can also add an entry for it now.

Contents of /etc/fstab

UUID=823a3283-30a7-4fef-b50b-8a2230c71b5b / btrfs rw,relatime,compress=zlib:3,ssd,discard=async,space_cache=v2,subvol=/@alpine 0 1 UUID=55C3-8AB4 /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro 0 2

Verify linux kernel is installed successfully.

# apk list --installed

If your other OS is already installed and working with refind as boot manager, then there is no need to install refind here. You may want to remove the grub and grub-efi packages

# apk del grub grub-efi


Exit the chroot:

# exit


Mount the EFI partition to edit the refind.conf file

# mkdir /mnt/os/boot/efi

# mount dev/nvme0n1p1 /mnt/os/boot/efi


Edit /mnt/os/boot/efi/EFI/refind/refind.conf to boot alpine by adding an entry for Alpine Linux as shown below:

Contents of /boot/efi/EFI/refind/refind.conf

menuentry "Alpine Linux" { volume "BTRFSVOL" loader @alpine/boot/vmlinuz-lts initrd @alpine/boot/initramfs-lts options "root=UUID=823a3283-30a7-4fef-b50b-8a2230c71b5b rw rootflags=subvol=@alpine rootfstype=btrfs" }

Do not use PARTUUID in refind.conf as it does not work for booting alpine.

Unmount everything:

# umount -R /mnt


Reboot your system.

# reboot


Now, you should now see an option to boot into Alpine Linux in the rEFInd boot menu.