Creating a XEN guest and tidbids in CLI Rumi, April 7, 2023 INSTALLING A GUEST DOMAIN (“DOMU”) Now that the Xen hypervisor/Dom0 virtual machine is configured and up and running, it’s time to configure and create a DomU. Just like we did in the Debian 9 tutorial, we will now install and use the xen-tools package to automate the steps involved in creating a paravirtualized (“PV”) DomU. INSTALL DEBIAN PACKAGE XEN-TOOLS Use apt-get to update the Xen hypervisor/Dom0 package index files, and upgrade all currently installed packages. As root run the following command: # apt-get update && apt-get upgrade Next, use apt-get to install the xen-tools package from the Debian stretch repository, which is currently shipping xen-tools version 4.8-1. Run the following command as root: # apt-get install xen-tools SET UP NEW PARTITION AND VOLUME GROUP Before we use xen-tools to create a new DomU, we need to create a LVM volume group which will be used to provision disk space for new virtual machines. In this step, we assume Dom0 was installed on the /dev/sda1 partition of your primary disk drive, and that all other /dev/sda drive space is empty. If you already have a partition on the empty drive space from where you’ll provision DomU disks, you can simply follow the step to add it as a volume group (vgcreate). If you already have a volume group on the space from where you’ll provision DomU disks, take note of the volume group name, and then you are ready for Step 3.3. Assuming there is no partition or volume group: In the first step, we use cfdisk to create a partition on the empty space. The drive with the empty space on the test computer is /dev/sda. So we use cfdisk to modify that drive, select the empty drive space, and create an Id/Type partition of “83 Linux”. The partition should not be bootable. Don’t touch the /dev/sda1 partition as it is contains the Dom0 operating system! # cfdisk /dev/sda Make sure to “write” your changes, then quit. If you follow the above step, you should end up with a new /dev/sda2 partition. Next, we add the /dev/sda2 partition to a new LVM volume group called “vg0”: # vgcreate vg0 /dev/sda2 For more information on configuring LVM volume groups, refer to the article A Quick Guide for Configuring LVM. USE XEN-TOOLS TO CREATE A NEW DOMU Now that the volume group is set up, everything is in place to create a new PV DomU virtual machine. We can now pass xen-tools some configuration options, which will automate the creation of the new DomU. Then all we need to do is start it! # xen-create-image --hostname=apache --lvm=vg0 --dhcp --pygrub --memory=4G --maxmem=4G --noswap --size=4G --passwd Here is an explanation of the xen-create-image options as detailed above: “hostname” sets the root@hostname of the new DomU “lvm” tells xen-tools which volume group to provision disk space from “dhcp” tells xen-tools that the new DomU will be using DHCP for networking “pygrub” tells xen-tools to boot the new DomU using pygrub “memory” tells xen-tools how much ram to allocate to the new DomU “maxmem” tells xen-tools the maximum amount of ram to allocate to the new DomU “noswap” tells xen-tools not to create swap space for the new DomU “size” tells xen-tools how much disk space to allocate to the new DomU “passwd” tells xen-tools to prompt the user to set the root password for the new DomU After running the xen-create-image command, the Dom0 console will be taken over momentarily by the process. When the process is complete, a new DomU configuration file will be created in the “/etc/xen/” folder. In the example above, the configuration file will be named “apache.cfg”. Refer to the hyperlinks provided at the end of this tutorial for more information on creating, configuring, and deleting DomU. START THE NEW DOMU Now that xen-tools has helped create a new DomU, it’s time to boot the new virtual machine. Now we can use the xl create command and pass it the name of the newly created DomU configuration file. # xl create /etc/xen/apache.cfg -c The “-c” option passes the Dom0 terminal to the booting DomU. To get back to Dom0 from the DomU’s terminal, use the key combination “Ctrl + ]”. To get back to the DomU from Dom0’s terminal, use the command: # xl console {name-of-domu} Note that, once you go back to the DomU, press the “Enter” key otherwise the terminal may appear inactive! A FEW MORE TIPS Before we wrap up, here are a few navigational tips. While in DomU’s console: To shutdown the DomU, as root run the command “shutdown -h now” To reboot the DomU, as root run the command “reboot” To exit DomU’s console and go back to Dom0 use the “CTRL + ]” key combination While in Dom0’s console: To shutdown a DomU, as root run the command “xl shutdown {domain-id}” To reboot a DomU, as root run the command “xl reboot {domain-id}” To exit Dom0’s console and go back to DomU, as root run the command “xl console {domain-id}” To start a DomU for the first time, or to restart after shutdown, as root run the command “xl create {full-location-to-DomU .cfg file}” If it appears you are in a frozen terminal in any one of the transitions above, try pressing “Enter” again, and you will likely find out that you are not! It is important to note that the DomU operating system, like any real operating system, will retain all configuration history and file creation/destruction changes even after it is shutdown and restarted. Simply configure and use the DomU virtual machine as you would any computer. Administrations Configurations (Linux) Virtualization Xen-Project