[SOLVED] File is larger when being copied, than what it actually is
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
probably the target filesystem does not support sparse files. As it was mentioned you might need to convert that qcow2 image to be really less that 20GB before copying (without sparse options).
(it looks like its virtual size is 3 TB, but can be stored in 17 GB).
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Original Poster
Rep:
Quote:
Originally Posted by pan64
probably the target filesystem does not support sparse files. As it was mentioned you might need to convert that qcow2 image to be really less that 20GB before copying (without sparse options).
(it looks like its virtual size is 3 TB, but can be stored in 17 GB).
Tried to convert but it seems to not be accepting anything I input for the size. I'm just copying it "in place".
Quote:
root@server04:100# qemu-img convert -f qcow2 -O raw vm-100-disk-0.qcow2 vm-100-disk-0.img -S 18432M
qemu-img: Invalid buffer size for sparse output specified. Valid sizes are multiples of 512 up to 16777216. Select 0 to disable sparse detection (fully allocates output).
But think at this point I'm just going to cut my losses and reformat and restart. Though I will need to figure out a way to stop it from doing this because this is removing my ability of backing up VM files.
you need to convert it without -S, that will create a sparse file. And probably you need to resize it because its virtual size is still 3TB (and you need to shrink it).
I think I had set the disk to be 3TB within the VM though. Is PVE doing something weird at the kernel level for the thin provisioning instead of handling it at the application level?
Last edited by Red Squirrel; 01-26-2022 at 02:58 PM.
You do need the "-S" option with "qemu-img convert", but with a reasonable size and not that ridiculous 18 gigabytes you used. That size is how large an all-zero block must be in order to be left unallocated at the destination. If the output were in qcow2 format, some (small) multiple of the qcow2 cluster size would be appropriate. For output in raw format, the size should be some multiple of the filesystem block size. If you are just doing this for backup, then a 4096 byte size (1 block) gives the maximum space savings. If you were actually going to mount this copy read/write and use it in operation, then you would want a somewhat larger "-S" size to avoid the filesystem becoming highly fragmented in actual use.
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336
Original Poster
Rep:
I decided to cut my losses and I will just rebuild the server without backing up this strange file, since I probably don't want a file acting that way anyway.
So I guess my next question is, how do I prevent this from happening again? I just want the VM disk file to act like a normal file. So whatever space it's actually using, I want the file to be that size and if I try to copy it, to stay that size. Ex: like a vmdk would. You can set thin provisioning in vmware to say 3TB, but the vmdk file is going to be smaller, and you can copy it or do what you want with it and it will not try to do anything weird. Can I do this by simply using raw format?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.