virt-sparsify in Proxmox?

Discussion in 'Proxmox VE: Installation and configuration' started by mlanner, Jun 2, 2015.

  1. mlanner

    mlanner Member

    Joined:
    Apr 1, 2009
    Messages:
    184
    Likes Received:
    1
    I have a need to maintain a VM in Proxmox as a template that gets shipped as a .qcow2 or .vmdk disk. However, before shipping it, I'd like to make it as small as possible. During installation of software inside the VM I download fairly large files, which then add a lot of "used" space in the image. I've read about 'virt-sparsify' being a good tool to "trim" down the image size. Does anyone a) have any experience with virt-sparsify, and b) it's not in the Debian repos -- so is there a plan to include it with Proxmox?
     
  2. mlanner

    mlanner Member

    Joined:
    Apr 1, 2009
    Messages:
    184
    Likes Received:
    1
    I think I found the answer to my own question. It looks like the 'virt-sparsify' is part of the 'libguestfs-tools' package. My only concern now is if it will conflict with any Proxmox package. Hopefully it won't. I'll try to install it on a PVE test host and report back here once I've got that going have done some testing.
     
    mjw likes this.
  3. manu

    manu Proxmox Staff Member

    Joined:
    Mar 3, 2015
    Messages:
    806
    Likes Received:
    63
    You could use zerofree available in the debian archive to fill the unused block of the partitions with 0. I have not tested yet on Qcow2 disk images, but with vmdk it makes a huge win to reduce the disk size.

    Zerodisk requires you to be in single user mode.
    You can also try the following scripted approach, whihc works in multi user setups:
    https://anonscm.debian.org/cgit/clo...packer-virtualbox-vagrant/scripts/minimize.sh
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. manu

    manu Proxmox Staff Member

    Joined:
    Mar 3, 2015
    Messages:
    806
    Likes Received:
    63
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. spirit

    spirit Well-Known Member

    Joined:
    Apr 2, 2010
    Messages:
    3,371
    Likes Received:
    140
    - If you use "move disk" option offline to convert the disk, it'll be sparse (move disk online don't create sparse image)
    - you can do a backup/restore
    - you can use fstrim inside a vm, if you use virtio-scsi + discard option.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    mjw likes this.
  6. mlanner

    mlanner Member

    Joined:
    Apr 1, 2009
    Messages:
    184
    Likes Received:
    1
    I found that the libfsguest-tools had too many missing dependencies.

    Thanks for all the ideas. I'm going to automate the build by running a backup of the image and then restoring it to another VMID. Seems to be the simplest option at this point.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice