Introduction
This HOWTO cover how to configure XEN in order to be able to install Alpine Linux as a virtual machine (DomU).
Preperation and installation
In this HOWTO we assume there already is a storage domain named nvmehost
and a network domain named netdriver
installed and ready to use.
Download Alpine ISO
In this HOWO we have created a directory called /images/alpine-3.20
where we download the installation image for Alpine Linux.
cd /images/alpine-3.20 && wget "https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-extended-3.20.2-x86_64.iso"
Create Virtual Disk
Create the ZFS Volume
zfs create -V 10G zpool/VM/the-machine-xvda
Adjust the disk size and name your needs.
Extract the kernel from the ISO
Mount the downloaded ISO and copy the boot directory to /images/alpine-3.20
mount -o ro /images/alpine-3.20/alpine-extended-3.20.2-x96_64.iso /mnt
cp -a /mnt/boot /images/alpine-3.20
umount /mnt
Create your Xen configuration file
/etc/xen/alpine.cfg
cat > /etc/xen/alpine.cfg << EOF
# basic config for alpine linux installation
vcpus = '2'
memory = '1024'
#kernel = '/usr/lib/grub-xen/grub-x86_64-xen.bin'
kernel = "/images/alpine-3.20/vmlinuz-lts"
ramdisk = "/images/alpine-3.20/initramfs-lts"
extra = "alpine_dev=hdc:iso9660 modules=loop,squashfs,sd-mod,usb-storage console=hvc0"
disk = [
'file:/images/alpine-extended-3.20.2-x86_64.iso,hdc:cdrom,r',
'phy:/dev/zvol/the-machine-xvda-disk,xvda,w,backend=nvmehost',
]
name = 'alpine'
vif = [ 'mac=00:16:3E:A0:00:01,bridge=br_202,backend=netdriver' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
EOF
Start the installation
xl create -c /etc/xen/alpine.cfg
At the login prompt login as root
Partition the disk to your needs with swap as the first partition and system as the second fdisk /dev/xvda
Run the command setup-alpine
Select your keyboard layout, network etc.
In the last steps when selecting where and what to install, select none.
Available disks are:
xvda1 (21.5 GB )
xvda2 (2.1 GB )
Which disk(s) would you like to use? (or '?' for help or 'none') [none]
Enter where to store configs ('floppy', 'usb' or 'none') [none]
Install e2fsprogs
apk add e2fsprogs
Format the disk
mkfs.ext4 /dev/xvda2
Create the swap
mkswap /dev/xvda1
Mount the disk
modprobe ext4
mount /dev/xvda2 /mnt
Install to the disk
setup-disk /mnt
Installing system on /dev/xvda2:
extlinux: Not a directory: /mnt/boot
100% ███████████████████==> initramfs: creating /boot/initramfs-lts
/boot is device /dev/xvda2
extlinux: no previous syslinux boot sector found
You might need fix the MBR to be able to boot
Create grub.cfg
mkdir /mnt/boot/grub
cat > /mnt/boot/grub/grub.cfg << EOF
set timeout=2
set default=0
menuentry "alpine" {
linux /boot/vmlinuz-lts modules=ext4 console=hvc0 root=/dev/xvda2
initrd /boot/initramfs-lts
}
EOF
Unmount and power off
cd
umount /mnt
poweroff
Update the Xen config file
Update the alpine.cfg file as follows
cat > /etc/xen/alpine.cfg << EOF
# basic config for alpine linux installation
vcpus = '2'
memory = '1024'
#type = 'pvh'
kernel = '/usr/lib/grub-xen/grub-x86_64-xen.bin'
#kernel = "/images/alpine-3.20/vmlinuz-lts"
#ramdisk = "/images/alpine-3.20/initramfs-lts"
#extra = "alpine_dev=hdc:iso9660 modules=loop,squashfs,sd-mod,usb-storage console=hvc0"
disk = [
# 'file:/images/alpine-extended-3.20.2-x86_64.iso,hdc:cdrom,r',
'phy:/dev/zvol/the-machine-xvda-disk,xvda,w,backend=nvmehost',
]
name = 'alpine'
vif = [ 'mac=00:16:3E:A0:00:01,bridge=br_202,backend=netdriver' ]
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
EOF
Start and test the new machine
xl create /etc/xen/alpine.cfg