Skip to content
Henryk Paluch edited this page Jul 22, 2024 · 2 revisions

How to chainload Alpine Extlinux from GRUB

My situation:

  1. I already have installed Proxmox VE with GRUB loader in GPT+BIOS partition mode
  2. I want to install Alpine and boot it via its Extlinux loader from Proxmox's GRUB

Why I want to use Alpine's default Extlinux loader? Because its GRUB support has at least 2 bugs when using Xen (see Alpine wiki page).

Initial Proxmox partition layout

Here is initial partition layout:

  • GPT in BIOS mode
  • partitions seen from Proxmox's fdisk:
Device         Start       End   Sectors  Size Type
/dev/sda1         34      2047      2014 1007K BIOS boot
/dev/sda2       2048   2099199   2097152    1G EFI System
/dev/sda3    2099200 209715200 207616001   99G Linux LVM
  1. /dev/sda1 contains legacy GRUB with GPT+BIOS support. This GPT partition actually overlaps with 1st partition from PMBR (Protective MBR) - that allows to boot GRUB even from BIOS that never heard of GPT partitioning.
  2. /dev/sda2 - FAT, EFI partition - not used in my case (I have no UEFI support), but Proxmox creates it anyway (for example to be able to later move disk to new PC with UEFI support)
  3. /dev/sda3 - LVM that contains all Proxmox installation and data.

Preparing Alpine partitions

WARNING! We may not use FAT filesystem for /boot because xen package contains symlinks in /boot Fortunately Extlinux (fork of Syslinux) supports also extX filesystems.

I strongly recommend to use Proxmox's fdisk to setup new GPT partitions, because Alpine's fdisk (actually busybox) has "unfinished" GPT support - it claims to be in GPT mode but still works with primary/extended partitions which is nonsense.

It is recommended to create 2 partitions so we can avoid possible incompatibilites of Extlinux with some hot features of ext4 filesystem:

/dev/sdb4  209717248 210765823   1048576  512M Linux filesystem
/dev/sda5  210765824 344983551 134217728   64G Linux filesystem
  1. /dev/sda4 is ext4 partition that will be mount as /boot in Alpine Linux and its Extlinux loader will be installed into its boot sector
  2. /dev/sda5 is ext4 partition where main Alpine installation will live.

After creating partitions I still used Proxmox to format them with:

mkfs.ext4 -L alpine-boot /dev/sda4
mkfs.ext4 -L alpine-xen-king /dev/sda5

Installing Alpine Linux

Now boot Alpine Linux - I used alpine-extended-3.20.1-x86_64.iso.

Mount both partitions:

mount -t ext4 /dev/sda5 /mnt
mkdir /mnt/boot
mount -t ext4 /dev/sda4 /mnt/boot

Now install Alpine using:

DISKOPTS=/mnt setup-alpine

Variable DISKOPTS is very important - it tells Alpine that there is already ready partition and filesystem for installation. Without DISKOPTS alpine-setup would completely wipe your disk!

After installation verify that

  • there was no /boot related error
  • fstab properly mounts boot / and /boot partitions.

My /mnt/etc/fstab looks like:

UUID=da15790b-261e-4282-b428-bc4bd535f89b	/	ext4	rw,relatime 0 1
UUID=5059c967-5aa2-4a1f-b582-7bfa76f1eac6	/boot	ext4	rw,relatime 0 2
/dev/cdrom	/media/cdrom	iso9660	noauto,ro 0 0
/dev/usbdisk	/media/usb	vfat	noauto	0 0
tmpfs	/tmp	tmpfs	nosuid,nodev	0	0

If there was error you should chroot into Alpine Linux and try extlinux -i /boot if it will work

Adding Alpine to Proxmox's GRUB

Now reboot back to Proxmox and append below menuentry to /etc/grub.d/40_custom:

menuentry "Alpine Xen Kingston 200GB" {
        insmod part_gpt
        insmod ext2
        insmod chain
        search --no-floppy --fs-uuid --set=root 5059c967-5aa2-4a1f-b582-7bfa76f1eac6
        chainloader +1
        boot
}

You have to run update-grub to actually generate new GRUB boot menu.

Finally reboot Proxmox and try booting Alpine Linux via Alpine Xen Kingston 200GB.

Resources

Clone this wiki locally