[SOLVED] qcow2 image file causing guest install to fail due to insufficient space
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
qcow2 image file causing guest install to fail due to insufficient space
I'm trying to deploy a Linux guest in KVM on RHEL 6.2 using a pre-created image for the backing store.
I create the image with qemu-img and then the guest using virt-install. The guest boots off my DVD ISO, but when I get to the point in the installer to setup the disk partition if fails claiming there is not enough space - either showing it as 0kb or 256kb.
The image file is of type qcow2 and I expected the space to be allocated (i.e. it to grow from 256kb up to max of 20GB as required) as the install progressed and during actual usage.
I must be getting confused somewhere along the way so any pointers would be greatly appreciated.
This created a sparse file that is shown by ls to be ~21GB in size, but its actually only using a few MB. The installer recognises this as the correct size and I can install ok. After which the file is now consuming ~2GB.
When I create the qcow2 file without this preallocation option the file size is shown by ls to be only 256KB. Does anyone else have any examples on what sizes they see?
I guess you could boot to some live cd image and then format it and copy random stuff to it until it grows some maybe 8G or whatever size plus of expected image. Installers sometimes use more space then delete it at end of operation so grow the disk maybe 25% larger. Then use the installer again to partition the image file and format it. It still should be same size.
Guess your location of the file might hold some size limits.
If you created the file full then it should be 21G in disk size.
Make it a raw disk then and re-test. I have almost never had a raw disk not work. Just change the name to the correct vm image. Otherwise it's use is exactly the same and as far as I can tell a bit faster.
If it fails on the raw disk then... dunno.
Guess it could be that you have some huge fragmentation issue. A copy binary to similar file might fix it then use the new name.
wait, it's in /home? might be a permission or selinux issue. the permissions and context for libvirt are by default properly set for /var/lib/libvirt/...
I did set the context of the file correctly, but I also disabled SELinux just to make sure
Maybe I wasn't clear, it does work now, but only if I create the qcow2 image with the preallocation=metadata option. This file is only ~3MB and grows without issue during the installation to end up being ~2GB in size. The guest system does think it has a 20GB disk available, so I'm sure the file will be able to grow fine to the full 20GB size limit as and when it is used by the guest.
I just don't understand why I need to use this preallocation=metadata option - as far as I know it should work fine with just the defaults. Does anybody else see the same issue as me or does it just work fine?
It was actually all down to the location of image file. Libvirt treats it differently if it is not in the standard /var/lib/libvirt/images location.
The logfile for the guest shows it being used as a raw format.
If you move the same image file to the default location, creating a guest with the same parameters using that same image file then results in it being used correctly and the format being shown as qcow2.
You can also use an option with virt-install (disk=myimg.qcow2,format=qcow2) to force it to use the correct format.
No, you were referring to the SELinux file context considerations for using a non-default location for your images, which was clearly NOT the issue in this case as I have outlined in the solution above.
Actual permissions on an image file are 600 when created using virt-manager or 644 using qemu-img (with default umask).
libvirt behaves the same whatever the permissions on the file or its directory. To reiterate what I already stated above, if when you create the guest with virt-install you use ",format=qcow2" then irrespective of the location of your image file it is used as a qcow2 format file, as opposed to being used as a raw format file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.