Scenario: a remote Linux server with many CPUs and lots of RAM is your virtual host. You want to create a new guest virtual machine and you want access via VNC to the installation process. In my case, I was using KVM as the hypervisor, but libvirt should work seamlessly with Xen and LXC too.
First thing, I created the disk image for my VM, then I started the installation with virt-install:
# qemu-img create -f qcow2 /var/lib/libvirt/images/my-virt-machine.img 100G # virt-install --name "MyVirtMachine" --vcpus 1 --ram 512 \ --disk /var/lib/libvirt/images/my-virt-image.img \ --cdrom /var/lib/libvirt/images/ubuntu-12.04.1-server-amd64.iso --os-type linux --network network=default \ --graphics=vnc,password=trustworthypass,listen=0.0.0.0,port=5903
Let’s see what’s happening:
- –name “MyVirtMachine”: your virtual machine’s name
- –vcpus 1: number of CPUs available to the VM
- –ram 512: megabytes of memory available to the VM
- –disk /var/[…].img: the path to the disk image
- –cdrom /var/[…].iso: the path to the ISO image of the installation disk
- –os-type linux: the OS we will install on the VM
- –network network=default: configure the VM to use the default network provided by libvirt
- –graphics=vnc,password=trustworthypass,listen=0.0.0.0,port=5903: connect the VM to a VNC server listening on every interface (0.0.0.0) on port 5903 with password trustworthypass
Now you can connect to the IP address of your hypervisor on port 5903 with a VNC client to complete the installation.