Paravirtualization With Xen On CentOS 5.3 (x86_64) - Page 2
3 Creating An Image-Based Virtual MachineI want to store the disk images of my image-based virtual machines in the directory /vm. Of course, you can use any other directory that has enough space left. If you use another directory, replace /vm with your own directory in this tutorial. If you want to save your virtual machines in /vm, too, but haven't created a partition for it or if the directory /vm doesn't exist on your system, you can create it like this: mkdir /vm CentOS comes with a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run virt-install The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 256MB RAM and a disk size of 4GB. I want to store it in the file /vm/vm01.img: Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems. <-- no You should answer the first question about the fully virtualized guest with no because otherwise you will not see the CentOS installer - the installation of the guest system will seem to hang. The question about the graphics support refers to the installer, not the virtual machine itself! It is possible to start a graphical installer, but you'd have to connect to it via VNC. It's easier to use the text installer - it offers the same options, so I choose the text installer. As install location, you should specify your CD/DVD drive (/dev/cdrom) or a mirror close to you where the installer can download all files needed for the installation of CentOS 5.3 in our virtual machine. You can find a list of CentOS mirrors here: http://www.centos.org/modules/tinycontent/index.php?id=13 After we have answered all questions, virt-install starts the normal CentOS 5.3 installer (in text mode) in our vm01 virtual machine. You already know the CentOS installer, so it should be no problem for you to finish the CentOS installation in vm01. After the installation, we stay at the vm01 console. To leave it, type CTRL+] if you are at the console, or CTRL+5 if you're using PuTTY. You will then be back at the dom0 console. virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0). It should look like this: cat /etc/xen/vm01
Run xm console vm01 to log in on that virtual machine again (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. To get a list of running virtual machines, type xm list The output should look like this: [root@server1 ~]# xm list To shut down vm01, do this: xm shutdown vm01 To start vm01 again, run xm create /etc/xen/vm01 If you want vm01 to start automatically at the next boot of the system, then do this: ln -s /etc/xen/vm01 /etc/xen/auto Here are the most important Xen commands: xm create -c /path/to/config - Start a virtual machine.
4 Creating An LVM-Based Virtual MachineThis chapter explains how you can set up LVM-based virtual machines instead of virtual machines that use disk images. Virtual machines that use disk images are very slow and heavy on disk IO. In this example I'm using a CentOS 5.3 host with the LVM volume group /dev/VolGroup00 that has about 150GB of space. /dev/VolGroup00 contains two logical volumes, /dev/VolGroup00/LogVol00 and /dev/VolGroup00/LogVol01 that consume about 60GB of space - the rest is not allocated and can be used to create logical volumes for our virtual machines: vgdisplay [root@server1 ~]# vgdisplay lvdisplay [root@server1 ~]# lvdisplay I want to create the virtual machine vm02 now which uses the logical volume /dev/VolGroup00/vm02. I want the virtual machine to have a disk space of 10GB, so I create the logical volume /dev/VolGroup00/vm02 as follows: lvcreate -L10G -n vm02 VolGroup00 Afterwards we can run virt-install again: Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems. <-- no As the disk file path, we specify our new volume group /dev/VolGroup00/vm02. Please note that virt-install doesn't ask for the disk space anymore because the disk space is determined by the size of the logical volume (10GB).
5 Links
|



Recent comments
21 hours 5 min ago
1 day 2 hours ago
1 day 6 hours ago
1 day 8 hours ago
1 day 22 hours ago
1 day 22 hours ago
2 days 3 hours ago
2 days 10 hours ago
2 days 11 hours ago
2 days 12 hours ago