Install Alpine on a btrfs filesystem with refind as boot manager
This Tutorial is about installing Alpine Linux as a btrfs subvolume Dualbooting with another Linux distribution and uses refind as boot manager.
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.The below instructions are based on below partition layout as shown by blkid command.
/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"
- Complete the Installation until the base configuration step.
- Once base configuration is complete, Identify your partition name and note the LABEL for the btrfs filesystem by using the command.
# blkid
- Mount the btrfs partition to /mnt.
# mount /dev/nvme0n1p3 /mnt -t btrfs
- To create a Btrfs subvolume for Alpine Linux install the btrfs-progs package .
# apk add btrfs-progs
- Create a new Btrfs subvolume for Alpine.
# btrfs subvolume create /mnt/@alpine
- Unmount the btrfs partition.
# umount /mnt
- Mount the newly created subvolume to /mnt.
# mount -o subvol=@alpine /dev/nvme0n1p3 /mnt
- Install the base system using the below command:
# setup-disk -m sys /mnt
- This will install the base system to the mounted subvolume. Once the base system is installed, chroot into the new system:
# chroot /mnt
- Check and ensure that /etc/fstab uses the correct subvolume for the root entry 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 |grep lts
- If your other OS is already installed and working with refind as boot manager, then there is no need to install refind again. 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/boot/efi && mount dev/nvme0n1p1 /mnt/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" } - 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.