Boot a VM from a qcow2 image

1,831 views
Skip to first unread message

Anastasis Andronidis

unread,
Jun 22, 2015, 3:37:37 AM6/22/15
to gan...@googlegroups.com
Hello, I have a quite simple scenario and I am not really sure which is the right approach to execute it with ganeti. I would really like your input and suggestions.

I have 2 hypervisors and both of them they share a common space through NFS on a third machine. I would like to have a .qcow2 image on this third NFS machine and boot it on one of those 2 aforementioned hypervisors. I would also like to be able to failover my VM in case that the main hypervisor fails.

So far, I understood that the correct way to boot VMs is through OS-definitions. So I tried to find how can I boot from a qcow2 image and I found ganeti-instance-image. If I understand correctly the context I have to modify ganeti-instance-image defaults and change the IMAGE_NAME and IMAGE_DIR to point on the qcow2 image I want to boot. That is a huge problem for me because that implies that I have a create a new definition for every qcow2 image I want to boot. Is there any other way I can make it work? I find it really strange that if I want to create a VM with KVM I can just give the path of the image to KVM and everything works just like that, and on the other hand Ganeti makes this scenario so hard. What am I doing wrong?

gnt-instance add has the -t option and I thought that maybe I can use the -t file or the -t sharedfile but I see no flag afterwords on where to define a path for my qcow2 image.

Randy Bush

unread,
Jun 22, 2015, 5:33:10 AM6/22/15
to Anastasis Andronidis, gan...@googlegroups.com
Find the disk size the qcow2 will require
qemu-img info <foo>.qcow2
Create the empty Ganeti instance with
gnt-instance create <foo>
Get the disk ID of the new instance
gnt-instance activate-disks <foo>
And slam the qcow2 image over the new instance
qemu-img convert <foo>.qcow2 /dev/ganeti/<lots of digits and some hyphens>.disk0

candlerb

unread,
Jun 22, 2015, 7:48:02 AM6/22/15
to gan...@googlegroups.com
As far as I know, the file/sharedfile templates do not support qcow2 images, only raw.

So you would have to expand the image using qemu-img convert. I believe qemu-img convert is able to create sparse files, so this won't necessarily use much more disk space.

(Aside: it *would* be a nice feature for ganeti to directly use vmdk or qcow2 files. But then I expect that would open up the floodgates to a whole bunch of other requests, such as supporting snapshots within the image)

Anastasis Andronidis

unread,
Jun 22, 2015, 10:07:09 AM6/22/15
to gan...@googlegroups.com
Thank you guys! So if I understand correctly there is no way to just define a path on the arguments when I run:
gnt-instance start

Like we do for the network boot:
gnt-instance start -H boot_order=network test.vm


candlerb

unread,
Jun 23, 2015, 7:18:52 AM6/23/15
to gan...@googlegroups.com
On Monday, 22 June 2015 15:07:09 UTC+1, Anastasis Andronidis wrote:
Thank you guys! So if I understand correctly there is no way to just define a path on the arguments when I run:

Right. I'm also not sure if you can adopt an existing file image, however you could always just create an instance with -t sharedfile and overwrite the image file.

Reply all
Reply to author
Forward
0 new messages