Creating Virtual Machines For Xen, KVM, VMware Workstation 6, and VMware Server With vmbuilder On Ubuntu 8.10 - Page 2
4.1 Create A Virtual Machine For KVM
To create a virtual machine for KVM, we could run the following command:
cd ~/vm7/
vmbuilder kvm ubuntu --suite=intrepid --flavour=virtual --arch=i386 --mirror=http://192.168.0.100:9999/ubuntu -o --tmpfs=- --libvirt=qemu:///system --ip=192.168.0.107 --part=vmbuilder.partition --templates=mytemplates --user=administrator --name=Administrator --pass=howtoforge --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --firstboot=boot.sh --mem=256 --hostname=vm7
Most of the options are self-explanatory. --part specifies the file with the partitioning details, relative to our working directory (that's why we had to go to our VM directory before running vmbuilder), --templates specifies the directory that holds the template file (again relative to our working directory), and --firstboot specifies the firstboot script. --libvirt=qemu:///system tells KVM to add this VM to the list of available virtual machines. --addpkg allows you to specify Ubuntu packages that you want to have installed during the VM creation (see above why you shouldn't add openssh-server to that list and use the firstboot script instead).
In the --mirror line I have specified my local apt-proxy mirror (http://192.168.0.100:9999/ubuntu) - I have used my publically accessible IP address instead of localhost or 127.0.0.1 because this mirror will be used in the VM's /etc/apt/sources.list file as well, and of course, the VM won't be able to connect to 127.0.0.1 on the host. Of course, you can as well specify an official Ubuntu repository in --mirror, e.g. http://de.archive.ubuntu.com/ubuntu. If you leave out --mirror, then the default Ubuntu repository (http://archive.ubuntu.com/ubuntu) will be used. Don't specify an apt-proxy mirror if you intend to transfer the VM to a host that has no access to the apt-proxy mirror (e.g. because it's in a different network) - as I've already mentioned, the VM will use the mirror in its /etc/apt/sources.list that you specify for the vmbuilder command.
This will create an ubuntu-kvm/ subdirectory within the ~/vm7 directory that contains the disk image of the virtual machine:
ls -l ubuntu-kvm/
root@server1:~/vm7# ls -l ubuntu-kvm/
total 369184
-rw-r--r-- 1 root root 377663488 2008-12-11 14:18 disk0.qcow2
-rwx---r-x 1 root root 49 2008-12-11 14:18 run.sh
root@server1:~/vm7#
The configuration file of the VM is located in the /etc/libvirt/qemu directory (/etc/libvirt/qemu/vm7.xml):
ls -l /etc/libvirt/qemu
root@server1:~/vm7# ls -l /etc/libvirt/qemu
total 32
drwxr-xr-x 3 root root 4096 2008-12-10 15:26 networks
-rw------- 1 root root 963 2008-12-10 16:29 vm1.xml
-rw------- 1 root root 959 2008-12-10 19:10 vm2.xml
-rw------- 1 root root 799 2008-12-10 18:25 vm3.xml
-rw------- 1 root root 799 2008-12-10 18:39 vm4.xml
-rw------- 1 root root 799 2008-12-10 19:25 vm5.xml
-rw------- 1 root root 805 2008-12-11 14:06 vm6.xml
-rw------- 1 root root 818 2008-12-11 14:54 vm7.xml
root@server1:~/vm7#
If you want to transfer the VM to another host, copy the ubuntu-kvm directory and the VM's configuration file to the new host (e.g. using scp).
4.2 Create A Virtual Machine For Xen
The command to create a Xen VM is similar to the KVM command:
cd ~/vm7/
vmbuilder xen ubuntu --suite=intrepid --flavour=virtual --arch=i386 --mirror=http://192.168.0.100:9999/ubuntu -o --tmpfs=- --ip=192.168.0.107 --part=vmbuilder.partition --templates=mytemplates --user=administrator --name=Administrator --pass=howtoforge --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --firstboot=boot.sh --mem=256 --hostname=vm7
This will create an ubuntu-xen/ subdirectory within the ~/vm7 directory that contains the disk image of the virtual machine and its Xen configuration file:
ls -l ubuntu-xen/
root@server1:~/vm7# ls -l ubuntu-xen/
total 303748
-rw-r--r-- 1 root root 20971520000 2008-12-11 14:24 ____.img
-rw-r--r-- 1 root root 8388608000 2008-12-11 14:23 root.img
-rw-r--r-- 1 root root 4194304000 2008-12-11 14:23 swap.img
-rw-r--r-- 1 root root 526 2008-12-11 14:24 xen.conf
root@server1:~/vm7#
If you want to transfer the VM to another host, copy the ubuntu-xen directory to the new host (e.g. using scp). You should place the Xen configuration file in the /etc/xen directory.
4.3 Create A Virtual Machine For VMware Workstation 6
The command to create a VM for VMware Workstation 6 is similar to the KVM command:
cd ~/vm7/
vmbuilder vmw6 ubuntu --suite=intrepid --flavour=virtual --arch=i386 --mirror=http://192.168.0.100:9999/ubuntu -o --tmpfs=- --ip=192.168.0.107 --part=vmbuilder.partition --templates=mytemplates --user=administrator --name=Administrator --pass=howtoforge --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --firstboot=boot.sh --mem=256 --hostname=vm7
This will create an ubuntu-vmw6/ subdirectory within the ~/vm7 directory that contains the disk image of the virtual machine and its configuration file:
ls -l ubuntu-vmw6/
root@server1:~/vm7# ls -l ubuntu-vmw6/
total 368884
-rw-r--r-- 1 root root 402325504 2008-12-11 14:27 disk0.vmdk
-rwx---r-x 1 root root 527 2008-12-11 14:27 vm7.vmx
root@server1:~/vm7#
If you want to transfer the VM to another host, copy the ubuntu-vmw6 directory to the new host (e.g. using scp).
4.4 Create A Virtual Machine For VMware Server
The command to create a VM for VMware Server is similar to the KVM command:
cd ~/vm7/
vmbuilder vmserver ubuntu --suite=intrepid --flavour=virtual --arch=i386 --mirror=http://192.168.0.100:9999/ubuntu -o --tmpfs=- --ip=192.168.0.107 --part=vmbuilder.partition --templates=mytemplates --user=administrator --name=Administrator --pass=howtoforge --addpkg=vim-nox --addpkg=unattended-upgrades --addpkg=acpid --firstboot=boot.sh --mem=256 --hostname=vm7
This will create an ubuntu-vmserver/ subdirectory within the ~/vm7 directory that contains the disk image of the virtual machine and its configuration file:
ls -l ubuntu-vmserver/
root@server1:~/vm7# ls -l ubuntu-vmserver/
total 368828
-rw-r--r-- 1 root root 402128896 2008-12-11 14:31 disk0.vmdk
-rwx---r-x 1 root root 531 2008-12-11 14:31 vm7.vmx
root@server1:~/vm7#
If you want to transfer the VM to another host, copy the ubuntu-vmserver directory to the new host (e.g. using scp).
5 Links
- vmbuilder: https://help.ubuntu.com/community/JeOSVMBuilder
- JeOS and vmbuilder: http://doc.ubuntu.com/ubuntu/serverguide/C/jeos-and-vmbuilder.html
- Ubuntu: http://www.ubuntu.com/