Using Libvirt to boot a VM.

Posted: December 30, 2014 in Uncategorized

My previous post was about how to boot a VM using KVM.

Let’s focus now on booting a VM using Libvirt.

The following example shows how to use the qemu-img command to create an empty image file. virt-install command to start up a virtual machine using that image file.

1. First create a .qcow2 image file

————————————————————————————————————————————————-

root@xyz:~# qemu-img create -f qcow2 /home/nazarite/ubuntu-14.04-server.qcow2 250G

———————————————————————————————————————————————–

2. Use net-start in virsh to start the default network

——————————

virsh # net-start default
Network default started

——————————-

3. I am going to use virt-install tool to boot the virtual machine through libvirt and connect to the graphical console from a VNC client installed on your local machine.

—————————————————————————————————————————————————-

root@xyz:~# virt-install –virt-type kvm –name ubuntu-14.04-server –ram 10240 –cdrom=/home/nazarite/ubuntu-14.04.1-server-amd64.iso –disk path=/home/ppmuser/ubuntu-14.04-server.qcow2,size=250,format=qcow2 –network network=default –graphics vnc,listen=0.0.0.0 –noautoconsole –os-type=linux –os-variant=ubuntutrusty

Starting install…
Creating domain…                                                                                                          |    0 B     00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.

——————————————————————————————————————————————————

4. Use the ‘virsh vncdisplay vm-name’ command to get the VNC port number.

# virsh vncdisplay ubuntu-14.04-server
:1

5. Connect to a vnc client like tightvnc with the I.P Addresss_of_host:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s