Xen Dom0 on USB or SD: Difference between revisions

From Alpine Linux
No edit summary
(Updating syslinux configuration with new kernel, initrd and modloop filenames; some changes to setting up apk repos and some of the notes on edge cases.)
(22 intermediate revisions by 9 users not shown)
Line 1: Line 1:
This guide will show you how to perform a Xen Dom0 install on a USB or SD card, so you can have your Dom0 running from tmpfs. This has some benefits, but you will need a place to store your guests (virtual machines) and a syslog server to redirect the logs to.
This guide will show you how to perform a Xen Dom0 install on a USB or SD card, so you can have your Dom0 running from tmpfs. This has some benefits, but you will need a place to store your guests (virtual machines) and a syslog server to redirect the logs to.


The first step is to set up a basic usb or SD install, to do this boot from the Alpine install CD (minimal is fine) and follow one of the following guides: [[Installing_Alpine_on_USB]] or [[Installing_Alpine_on_Compact_Flash]]. Once you finished installing Alpine Linux on your device, boot from it and configure your newly installed system:
The first step is to set up a basic usb or SD install, to do this boot from the Alpine install CD (minimal is fine) and follow one of the following guides: [[Create a Bootable USB]] or [[Create a Bootable Compact Flash]].


Note: you might have to edit /etc/apk/repositories and change the first line so it points to /media/usb/apks
Once you finished installing Alpine Linux on your device, boot from it and configure your newly installed system:
 
Setup the network interfaces and apk repositories:


<pre>
<pre>
# setup-alpine
# setup-interfaces
# setup-apkrepos
[...]
[...]
# apk update
# apk update
</pre>
</pre>


Now you that you have your system properly configured, it's time to install Xen:
{{Note| you may need to edit /etc/apk/repositories and change the first line so it points to /media/usb/apks.}}
 
Now that you have your system properly configured, it's time to install Xen:


<pre>
<pre>
# Should this not be apk add xen xen-hypervisor ?
# apk add xen
# apk add xen
</pre>
</pre>


Now we have Xen installed, but we will need to modify the usb bootloader in order to load the Xen kernel. The first step is to remount /media/usb with write permissions:
Now we have Xen installed, but we will need to modify the usb [[Bootloaders|bootloader]] in order to load the Xen kernel. The first step is to remount /media/usb with write permissions:


<pre>
<pre>
Line 35: Line 41:
<pre>
<pre>
LABEL xen
LABEL xen
  MENU LABEL Xen
   KERNEL /boot/mboot.c32
   KERNEL /boot/mboot.c32
   APPEND /boot/xen-4.1.gz --- /boot/grsec alpine_dev=UUID=XXXX-XXXX:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/grsec.modloop.squashfs pax_nouderef --- /boot/grsec.gz
   APPEND /boot/xen.gz --- /boot/vmlinuz-hardened alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/modloop-hardened --- /boot/initramfs-hardened
</pre>
</pre>
{{Note|<nowiki>you might have to use alpine_dev=UUID=XXXX-XXXX:vfat might work as well. UUID can be read using blkid.</nowiki>}}
{{Note|<nowiki>alternatively, using /media/UUID=XXX-XXXX instead of /media/usb, see /proc/mounts to detected where is your usb/cf card mounted.</nowiki>}}


Serial console boot:
Serial console boot:
<pre>
<pre>
LABEL xen
LABEL xen
  MENU LABEL Xen
   KERNEL /boot/mboot.c32
   KERNEL /boot/mboot.c32
   APPEND /boot/xen-4.1.gz com1=115200,8n1 console=com1 --- /boot/grsec alpine_dev=UUID=XXXX-XXXX:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/grsec.modloop.squashfs pax_nouderef --- /boot/grsec.gz
   APPEND /boot/xen.gz com1=115200,8n1 console=com1 --- /boot/vmlinuz-hardened alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/modloop-hardened --- /boot/initramfs-hardened
</pre>
</pre>


Line 55: Line 62:
# echo "xen_netback" >> /etc/modules
# echo "xen_netback" >> /etc/modules
# echo "xen_blkback" >> /etc/modules
# echo "xen_blkback" >> /etc/modules
# echo "xen_gntdev" >> /etc/modules
# echo "tun" >> /etc/modules
# echo "xen_evtchn" >> /etc/modules
# echo "evtchn" >> /etc/modules
# echo "gntdev" >> /etc/modules
</pre>
</pre>


Line 66: Line 70:
# rc-update add udev sysinit
# rc-update add udev sysinit
# rc-update add udev-postmount
# rc-update add udev-postmount
# rc-update add xencommons
# rc-update add xenstored
</pre>
# rc-update add xenconsoled
 
If you need the xm toolstack, also add xend to startup services:
 
<pre>
# rc-update add xend
</pre>
</pre>


Line 82: Line 81:
</pre>
</pre>


Also remember to configure at least one network bridge following the [[Howto_Configure_a_Network_Bridge]] guide.
Also remember to configure at least one network bridge following the [[Bridge]] guide.
 
== See also ==
* [[Xen Dom0]]
 
[[Category:Virtualization]]

Revision as of 15:49, 23 October 2017

This guide will show you how to perform a Xen Dom0 install on a USB or SD card, so you can have your Dom0 running from tmpfs. This has some benefits, but you will need a place to store your guests (virtual machines) and a syslog server to redirect the logs to.

The first step is to set up a basic usb or SD install, to do this boot from the Alpine install CD (minimal is fine) and follow one of the following guides: Create a Bootable USB or Create a Bootable Compact Flash.

Once you finished installing Alpine Linux on your device, boot from it and configure your newly installed system:

Setup the network interfaces and apk repositories:

# setup-interfaces
# setup-apkrepos
[...]
# apk update
Note: you may need to edit /etc/apk/repositories and change the first line so it points to /media/usb/apks.

Now that you have your system properly configured, it's time to install Xen:

# Should this not be apk add xen xen-hypervisor ?
# apk add xen

Now we have Xen installed, but we will need to modify the usb bootloader in order to load the Xen kernel. The first step is to remount /media/usb with write permissions:

# mount -o remount,rw /media/usb

Then, copy the Xen kernel and mboot.c32 to the usb boot partition:

# cp /boot/xen.gz /media/usb/boot/
# cp /boot/mboot.c32 /media/usb/boot/

Now we have all the necessary files to boot Xen from the usb, it's time to change the bootloader and add a Xen entry, to do so open /media/usb/syslinux.cfg with your favorite editor and add one of the following entries:

Normal boot:

LABEL xen
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz --- /boot/vmlinuz-hardened alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/modloop-hardened --- /boot/initramfs-hardened
Note: you might have to use alpine_dev=UUID=XXXX-XXXX:vfat might work as well. UUID can be read using blkid.
Note: alternatively, using /media/UUID=XXX-XXXX instead of /media/usb, see /proc/mounts to detected where is your usb/cf card mounted.

Serial console boot:

LABEL xen
  KERNEL /boot/mboot.c32
  APPEND /boot/xen.gz com1=115200,8n1 console=com1 --- /boot/vmlinuz-hardened alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/modloop-hardened --- /boot/initramfs-hardened

Change the UUID to the correct one, and add the necessary modules for your system. It's also a good idea to check Xen Boot options and set dom0_mem, dom0_vcpus_pin and dom0_max_vcpus at least.

The next step is to load the necessary kernel modules for Xen, we will add them to /etc/modules, so they will be loaded automatically on boot:

# echo "xen_netback" >> /etc/modules
# echo "xen_blkback" >> /etc/modules
# echo "tun" >> /etc/modules

The last step is to configure startup services, we will need udev and xencommons at least to be started on boot:

# rc-update add udev sysinit
# rc-update add udev-postmount
# rc-update add xenstored
# rc-update add xenconsoled

Ok, now you have a fully functional Xen install, it's time to save your changes and boot into it.

# lbu commit
# reboot

Also remember to configure at least one network bridge following the Bridge guide.

See also