Create Alpine Linux PV DomU
Obtain a copy of Alpine Linux
To create an Alpine Linux paravirtualized (PV) DomU you will need an Alpine Linux iso.
Download the latest and greatest iso
| Download now!|
[ERROR in latestalp.php: failed to read ERROR in latestalp.php: failed to read ]
(ERROR in latestalp.php: failed to read MiB) Released ERROR in latestalp.php: failed to read
Extract the xen-aware linux kernel
Next, mount the iso and extract the kernel and initramfs:
# mkdir -p /mnt/alpine_iso # mount -t iso9660 -o loop /path/to/the/iso /mnt/alpine_iso # cp /mnt/alpine_iso/boot/grsec /path/to/save/kernel/ # cp /mnt/alpine_iso/boot/grsec.gz /path/to/save/kernel/ # umount /mnt/alpine_iso # rmdir /mnt/alpine_iso
Now we have the kernel in /path/to/save/kernel/grsec and initramfs in /path/to/save/kernel/grsec.gz.
Create the disk image
Now we should create an empty file, that will be the hard drive of the DomU (in this example we are using a 3GB disk):
# dd if=/dev/zero of=/path/to/disk.img bs=1M count=3000
Create a DomU config file that boots the ISO image
The next step is to create a basic DomU configuration file, so we can launch the pv guest iso (save it where you like, although the most common place is /etc/xen/).
# Alpine Linux PV DomU # Kernel paths for install kernel = "/path/to/save/kernel/grsec" ramdisk = "/path/to/save/kernel/grsec.gz" extra="alpine_dev=xvdc:iso9660 modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/grsec.modloop.squashfs console=hvc0" # Path to HDD and iso file disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img', 'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/path/to/the/iso' ] # Network configuration vif = ['bridge=br0'] # DomU settings memory = 512 name = "alpine" vcpus = 1 maxvcpus = 1
Install the guest
Now that we have all the necessary files, we can start the DomU to proceed with the install:
# xl create -f /path/to/conf -c
Login into the system with user "root" and no password, and proceed with the normal install:
After configuring the basic system, you will be asked where would you like to install Alpine, choose xvda and sys.
This will create three partitions on your disk, xvda1 for /boot, xvda2 for swap and xvda3 for /
Available disks are: xvda (3.1 GB ) Which disk(s) would you like to use? (or '?' for help or 'none') [none] xvda The following disk is selected: xvda (3.1 GB ) How would you like to use it? ('sys', 'data' or '?' for help) [?] sys WARNING: The following disk(s) will be erased: xvda (3.1 GB ) WARNING: Erase the above disk(s) and continue? [y/N]: y Initializing partitions on /dev/xvda... Creating file systems... Installing system on /dev/xvda3: Installation is complete. Please reboot. # halt
Adjust the domU config file to boot from fresh install
In your Dom0, edit your DomU config file to boot from the fresh install
# Alpine Linux PV DomU # Kernel paths for install kernel = "/path/to/save/kernel/grsec" ramdisk = "/path/to/save/kernel/grsec.gz" extra="modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3" # Path to HDD and iso file disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img' ] # Network configuration vif = ['bridge=br0'] # DomU settings memory = 512 name = "alpine" vcpus = 1 maxvcpus = 1
Adding a grub config file to boot with pvgrub
Now boot the VM once more to add a grub config file so that we may load the xen-aware kernel from within the VM.
This means that upgrading the kernel will not mean copying it to the dom0.
# xl create -f /path/to/conf -c
Log in as root and create the file /boot/grub/menu.lst with the following content
#/boot/grub/menu.lst default 0 timeout 5 title alpine-xen-pv root (hd0,0) kernel /boot/vmlinuz-grsec modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3 initrd /boot/initramfs-grsec
Halt your VM one last time
Adjust the DomU config file one last time to use pvgrub
Your final xen DomU config file should look something like this.
# Alpine Linux PV DomU disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/alpine.img' ] kernel = "/usr/lib/xen/boot/pv-grub-x86_64.gz" vif = [ 'bridge=br0' ] memory = 1024 name = "alpine" vcpus = 1 maxvcpus = 1
When you next boot, you will be presented with the grub boot menu, and your VM will boot.