Make a virtual machine disk sparse with virt-sparsify (#1195)

After working with `virt-sysprep`, it is a good idea to make the disk image
sparse with `virt-sparsify`. This reduces the size of the resulting box.

See https://libguestfs.org/virt-sparsify.1.html

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
This commit is contained in:
Wong Hoi Sing Edison 2021-01-07 18:10:31 +08:00 committed by GitHub
parent 48c1a55153
commit 978e92eac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,7 @@ module VagrantPlugins
options = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS', '')
operations = ENV.fetch('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS', 'defaults,-ssh-userdir,-customize')
`virt-sysprep --no-logfile --operations #{operations} -a #{@tmp_img} #{options}`
`virt-sparsify --in-place #{@tmp_img}`
# add any user provided file
extra = ''
@tmp_include = @tmp_dir + '/_include'