Virtualization With Xen 3.3.1 On Debian Etch - Page 2
4 Creating Image-Based Virtual Machines
Now we edit /etc/xen-tools/xen-tools.conf. This file contains the default values that are used by the xen-create-image script unless you specify other values on the command line. I changed the following values and left the rest untouched:
The dir line specifies where the virtual machine images will be stored. dist specifies the distribution to be installed in the virtual machines (Debian Etch) (there's a comment in the file that explains what distributions are currently supported).
The passwd = 1 line makes that you can specify a root password when you create a new guest domain. In the mirror line specify a Debian mirror close to you.
Make sure you specify a gateway, netmask, and broadcast address. If you don't, and you don't specify a gateway and netmask on the command line when using xen-create-image, your guest domains won't have networking even if you specified an IP address!
It is very important that you add the line serial_device = hvc0 (or serial_device = xvc0) because otherwise your virtual machines might not boot properly!
Before we go on, we must create the directory where the virtual machine images should be stored:
Now let's create our first guest domain, xen1.example.com, with the IP address 192.168.0.101:
xen-create-image --hostname=xen1.example.com --size=4Gb --swap=256Mb --ip=192.168.0.101 --memory=128Mb --arch=i386 --role=udev
Options that you specify on the command line override the settings in /etc/xen-tools/xen-tools.conf. Options that are not specified on the command line are taken from /etc/xen-tools/xen-tools.conf. Please make sure that you add --role=udev, or your virtual machine might not boot properly!
(To learn more about the available options, take a look at the xen-create-image man page:
The xen-create-image command will now create the xen1.example.com virtual machine for us. This can take a few minutes. The output should be similar to this one:
server1:~# xen-create-image --hostname=xen1.example.com --size=4Gb --swap=256Mb --ip=192.168.0.101 --memory=128Mb --arch=i386 --role=udev
There should now be a xen1.example.com configuration file - /etc/xen/xen1.example.com.cfg. Open it and add the line extra = 'xencons=hvc0 console=hvc0' (or extra = 'xencons=xvc0 console=xvc0' if you use serial_device = xvc0 in /etc/xen-tools/xen-tools.conf) at the end so that the file looks as follows:
If you don't add that line and you go to the console of the vm using the xm console command, the boot process seems to hang forever (while in fact, the vm is running perfectly fine - you can connect to it using SSH).
(Please note: if you have a dual-core or quad-core CPU and want the virtual machine to use all CPU cores, please add the line vcpus = '2' or vcpus = '4' to the configuration file.)
To start the virtual machine, run
xm create /etc/xen/xen1.example.com.cfg
xm console xen1.example.com
to log in on that virtual machine (type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY to go back to dom0), or use an SSH client to connect to it (192.168.0.101).
(If you see something like this during the boot process of the vm...
EXT3-fs: mounted filesystem with ordered data mode.
... run the following command in the vm:
mv /lib/tls /lib/tls.disabled
To get a list of running virtual machines, type
The output should look like this:
server1:~# xm list
To shut down xen1.example.com, do this:
xm shutdown xen1.example.com
If you want xen1.example.com to start automatically at the next boot of the system, then do this:
ln -s /etc/xen/xen1.example.com.cfg /etc/xen/auto
Here are the most important Xen commands:
xm create -c /path/to/config - Start a virtual machine.
A list of all virtual machines that were created with the xen-create-image command is available under
To learn more about what you can do with xen-tools, take a look at this tutorial: http://www.howtoforge.com/xen_tools_xen_shell_argo