In order to maintain my sanity, I install and configure software on VPS instances in a semi-automated way.

Recently I figured out how to install Alpine Linux on an x86_64 VPS instance hosted by a company that didn’t manage to implement a trivial boot from arbitrary ISO images.

Here’s how to deal with all this dementia:

1. Boot preinstalled Ubuntu, sudo -s

2. Reboot into the Alpine Linux ISO image:

#!/usr/bin/env bash

set -eu

ARCH="x86_64"
VERSION="3.20.3"
MIRROR="https://dl-cdn.alpinelinux.org/alpine"

short_version=$(echo ${VERSION} | sed 's!\.[0-9]*$!!')
iso="alpine-virt-${VERSION}-${ARCH}.iso"
url="${MIRROR}/v${short_version}/releases/${ARCH}/${iso}"

apt -y install wget
wget "${url}" "${url}.sha256" "${url}.asc" "https://alpinelinux.org/keys/ncopa.asc"
sha256sum -c "${iso}.sha256"
gpg --import < ncopa.asc
gpg --verify "${iso}.asc" "${iso}"

mount -t iso9660 "${iso}" /mnt
cp -a /mnt/* /
cp -a /mnt/* /boot/ # in case if you have a separate /boot partition and the rest of stuff on LVM
umount /mnt

echo '#!/bin/sh
cat << EOF
menuentry "Alpine Linux" --unrestricted {
  linux /boot/vmlinuz-virt
  initrd /boot/initramfs-virt
}
EOF' > /etc/grub.d/99_custom

chmod +x /etc/grub.d/99_custom
update-grub2
grub-reboot "Alpine Linux"
reboot

3. Unmount VPS disk, fix file layout, wipe VPS disk, install the OS:

#!/usr/bin/env sh

set -eu

DISK="sda"

cp -r /.modloop /root/
cp -a /media/${DISK}*/apks /root/
umount /.modloop /media/${DISK}*
ln -sf /root/.modloop/modules /lib/modules
for i in /media/${DISK}*/ ; do
  cp -a /root/apks "$i"
done

setup-interfaces
setup-dns 9.9.9.9
/etc/init.d/networking restart
setup-apkrepos -1
apk add sgdisk
/etc/init.d/networking stop

sgdisk --zap-all "/dev/${DISK}"
setup-alpine

I wish the third step was less esoteric and more reliable. Most likely this installation method will stop working after few ISO image releases.

netboot.xyz

Another approach, which is actually pretty user-friendly, is grub-imageboot + netboot.xyz. It works. However, I’m personally very uneasy about the security of this approach and have less time to verify it.

Booting ISO using ramdisk

This has never worked for me, I’d gladly appreciate if anyone share a grub2 config that successfully does that trick with Alpine Linux.

If you are a VPS hosting provider

Please consider adding a custom ISO image boot option to your control panel. It’s so damn simple to implement and yet it will open your business to more clients and greater profits, for almost no effort!

And no, preinstalled system disk images are never enough. Even for this specific OS you will likely make some weird disk layout or whatever else that makes provisioning/deployment scripts incompatible with your image, right?


What's your favorite VPS hosting
that supports custom ISO boot?


I’m pretty exhausted by this research. Please let me know in the comments below if you are aware of any VPS hosting providers that actually fall under these criteria:

  • control panel with
    • VNC client
    • custom ISO image boot support
  • hosted in a DMCA-ignored zone
  • honest ≈1 Gbps outgoing speed
  • ≥15 GiB SSD/NVMe disk space with a possibility to extend it later
  • ≥1 GiB RAM
  • monthly renewal with a possibility to switch to an annual renewal
  • competitive price
    • with no hidden additional charges (like for traffic overuse, etc.)

Yes, it’s still relevant, in whatever century you’re reading this article. Thank you a lot! ❤️