Xen Dom0 on USB or SD: Difference between revisions
Dubiousjim (talk | contribs) (Category:Installation) |
(link to udev/eudev article) |
||
(13 intermediate revisions by 11 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 device 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, | The first step is to set up a basic usb or SD install. To do that, boot from the Alpine install CD (minimal is fine) and follow one of the following guides:<BR>[[Create a Bootable USB]] or [[Create a Bootable Compact Flash]]. | ||
{{Note|you | Once you finish installing Alpine Linux on your device, boot from it and configure your newly installed system: | ||
Set up the network interfaces: | |||
<pre> | |||
# setup-interfaces | |||
# ifup eth0 | |||
</pre> | |||
{{Note| you may need to change <i>eth0</i> to the name of your interface}} | |||
Continue by setting up the apk repositories: | |||
<pre> | <pre> | ||
# setup- | # setup-apkrepos | ||
[...] | [...] | ||
# apk update | # apk update | ||
</pre> | </pre> | ||
Now | {{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, | Now that we have Xen installed, we 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 32: | Line 43: | ||
</pre> | </pre> | ||
Now we have | Now that we have the necessary files to boot Xen from the usb device, it's time to change the bootloader and add a Xen entry.<BR> | ||
To do so, open /media/usb/syslinux.cfg with your favorite editor and add one of the following entries: | |||
Normal boot: | Normal boot: | ||
Line 38: | Line 50: | ||
LABEL xen | LABEL xen | ||
KERNEL /boot/mboot.c32 | KERNEL /boot/mboot.c32 | ||
APPEND /boot/xen.gz --- /boot/ | 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. UUID can be read using blkid.</nowiki>}} | |||
{{Note|<nowiki>alternatively, to use /media/UUID=XXX-XXXX instead of /media/usb, see /proc/mounts to detect where your usb/cf card is mounted.</nowiki>}} | |||
Serial console boot: | Serial console boot: | ||
Line 45: | Line 60: | ||
LABEL xen | LABEL xen | ||
KERNEL /boot/mboot.c32 | KERNEL /boot/mboot.c32 | ||
APPEND /boot/xen.gz com1=115200,8n1 console=com1 --- /boot/ | 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> | ||
Change the UUID to the correct one, and add the necessary modules for your system. It's also a good idea to check [ | Change the UUID to the correct one, and add the necessary modules for your system.<BR>It's also a good idea to check [https://xenbits.xen.org/docs/unstable/misc/xen-command-line.html Xen Boot options] and set, dom0_mem, dom0_vcpus_pin and dom0_max_vcpus. | ||
The next step is to load the necessary kernel modules for Xen | 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 at boot time: | ||
<pre> | <pre> | ||
Line 58: | Line 73: | ||
</pre> | </pre> | ||
The last step is to configure startup services | The last step is to configure startup services. We will need [[udev]] and xencommons to start at boot time: | ||
<pre> | <pre> | ||
# rc-update add udev sysinit | # rc-update add udev sysinit | ||
# rc-update add udev-postmount | # rc-update add udev-postmount | ||
# rc-update add | # rc-update add xenstored | ||
# rc-update add xenconsoled | |||
# rc-update add | |||
</pre> | </pre> | ||
Now you have a fully functional Xen install. It's time to save your changes and boot into it. | |||
<pre> | <pre> | ||
Line 79: | Line 89: | ||
</pre> | </pre> | ||
Remember to configure at least one network bridge. Follow the [[Bridge]] guide. | |||
== See also == | == See also == | ||
* [[Xen Dom0]] | * [[Xen Dom0]] | ||
[[Category:Virtualization]] | [[Category:Virtualization]] |
Latest revision as of 11:07, 10 November 2023
This guide will show you how to perform a Xen Dom0 install on a USB device 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 that, 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 finish installing Alpine Linux on your device, boot from it and configure your newly installed system:
Set up the network interfaces:
# setup-interfaces # ifup eth0
Continue by setting up the apk repositories:
# setup-apkrepos [...] # apk update
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 that we have Xen installed, we 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 that we have the necessary files to boot Xen from the usb device, 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
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.
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 at boot time:
# 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 to start at boot time:
# rc-update add udev sysinit # rc-update add udev-postmount # rc-update add xenstored # rc-update add xenconsoled
Now you have a fully functional Xen install. It's time to save your changes and boot into it.
# lbu commit # reboot
Remember to configure at least one network bridge. Follow the Bridge guide.