Alpine
Reference:
Create Alpine Linux PV DomU
In a nutshell, you will download a linux ISO file and mount it so it can be used as installation media.
Create a configuration file that specifies the location of the kernel files on the iso, the vm hardware configs, and location of the vm drives.
After booting up and configuring the vm you’ll configure it to use the installed kernel files, and reboot it so it doesn’t boot up to the installation media again.
Download ISO
Download and mount the iso file. My server had a cdrom. I didn’t want to get confused, so I created a iso directory as a mount point.
sudo mkdir /media/iso
sudo mount -t iso9660 -o loop /home/porky/iso/alpine-standard-3.23.2-x86_64.iso /media/isoCreate a partition for the vm
I have an unused drive on my server /dev/sdb. Then I created a logical volume (partition).
sudo vgcreate vg0 /dev/sdb
sudo lvcreate -n alpine -L 20G vg0Create network bridge
For the vm to connect to the internet you must create a bridge interface on the host.
On most linux versions that is configured by the /etc/network/interfaces file.
My original file was:
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
allow-hotplug eno1
iface eno1 inet dhcpMy updated interfaces file is below. Notice the eno1 interface was changed from dhcp to manual. The new bridge interface xenbr0 is set for dhcp.
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto eno1
iface eno1 inet manual
auto xenbr0
iface xenbr0 inet dhcp
bridge_ports eno1Create config file
Below is the configuration I used for m Alpine Linux vm. You need to verify the paths to the ramdisk and kernel are the same for your install. They may be named differently depending on the iso you use. Same for the disk targets.
I saved the config file to /etc/xen/alpine-1.cfg
# Kernel paths for install
kernel = "/media/iso/boot/vmlinuz-lts"
ramdisk = "/media/iso/boot/initramfs-lts"
extra="modules=loop,squashfs console=hvc0"
# Path to HDD and iso file
disk = [
'vdev=xvda, access=rw, target=/dev/vg0/alpine',
'format=raw, vdev=xvdb, access=r, devtype=cdrom, target=/home/porky/iso/alpine-standard-3.23.2-x86_64.iso'
]
# Network configuration
vif = ['bridge=xenbr0']
# DomU settings
memory = 2048
name = "alpine-a1"
vcpus = 1
maxvcpus = 1Create the vm
The -c flag starts a console to the vm.
sudo xl create -f /etc/xen/alpine-1.cfg -cLogin and configure the vm
Logging into an alpine vm for the first time you’ll use the root username with no password.
Then run setup-alpine command. If the bridge was set up correctly, the vm should have internet access.
From the config file you see set the drive to be xvda. You will use that for the installation drive with the sys option.
Configure GRUB menu
Once the installation is complete we will set up a grub menu to choose from when booting up.
Mount the drive the os was installed on and create hte grub.cfg file.
mount /dev/xvda1 /mnt
mkdir /mnt/grub
vi /mnt/grub/grub.cfgBelow is the config I used. Note you need kernel and ramdisk paths correct.
menuentry 'alpine-xen' {
set root=(xen/xvda,msdos1)
linux /boot/vmlinuz-lts root=/dev/xvda3 modules=ext4 console=hvc0
initrd /boot/initramfs-lts
}Now shutdown the alpine vm with the poweroff command.
Update the vm config file and boot up
The configuration file created earlier needs to be changed so it boots up using the xen pvgrub binary on the host instead of the one from the ISO. You’ll also remove the path to the ISO file.
Make sure you are your correct paths for your system.
sudo umount /media/iso# Kernel paths for install
kernel = "/usr/lib/grub-xen/grub-x86_64-xen.bin"
# Path to HDD and iso file
disk = [
'vdev=xvda, access=rw, target=/dev/vg0/alpine'
]
# Network configuration
vif = ['bridge=xenbr0']
# DomU settings
memory = 2048
name = "alpine-a1"
vcpus = 1
maxvcpus = 1Boot up your new vm
sudo xl create -f /etc/xen/alpine-1.cfg -cThis time you vm will boot to the grub menu.