Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize script results in large (non-sparse) image file for QEMU builder #369

Closed
dmlb2000 opened this issue Jun 5, 2015 · 2 comments
Closed

Comments

@dmlb2000
Copy link
Contributor

dmlb2000 commented Jun 5, 2015

Noticed this as I was building the qemu variants of the box images for all the linuxes.

The image file is 40Gb in size, that space is also used on the host file system. This doesn't make sense (I thought) with the way disk image formats like QCOW2 and VMDK are used. These disk image formats are sparse by design and only use the space necessary on the host machine when the blocks are actually allocated within the VM. I figured out that the minimize.sh script was allocating all the space on the drive with zeros then removing it, which causes the disk image file to actually take up 40Gb on the host.

It maybe that VMDK and whatever parallels uses are also compressed by design which would allow minimize.sh to still produce a small image. However, QCOW2 is not compressed by design.

As the post scripts are global to a box and minimize.sh seems to be in all the boxes, I figured I'd put in an issue before I added a pull request to remove it, as there's not much documentation in the script as to why its there nor git history. What the script is doing is obvious through inspection its only a 15 line script but why its there is escaping me.

So to test this and put it into perspective I remove the minimize.sh script from the CentOS 7.1 box and built both it and CentOS 6.6 boxes.

The boxes themselves are small
[dmlb2000@uber-gamer bento]$ ls -lh builds/chef__centos-6.6-2.0.20150605152146.git.ca13d1658ab459b6f54829bf216e0698f700f382_dirty.libvirt.box builds/chef__centos-7.1-2.0.20150605135802.git.ca13d1658ab459b6f54829bf216e0698f700f382_dirty.libvirt.box
-rw-r--r--. 1 dmlb2000 users 251M Jun 5 08:49 builds/chef__centos-6.6-2.0.20150605152146.git.ca13d1658ab459b6f54829bf216e0698f700f382_dirty.libvirt.box
-rw-r--r--. 1 dmlb2000 users 459M Jun 5 07:11 builds/chef__centos-7.1-2.0.20150605135802.git.ca13d1658ab459b6f54829bf216e0698f700f382_dirty.libvirt.box

But when the boxes get added to vagrant... they get big.
[dmlb2000@uber-gamer boxes]$ pwd
/home/dmlb2000/.vagrant.d/boxes
[dmlb2000@uber-gamer boxes]$ du -sh *
40G opscode-centos-6.6
1.2G opscode-centos-7.1

So it would be nice to know if this can be fixed by removing this script or by simply putting an, 'exit if I'm doing the qemu build' logic into the script.

@cheeseplus cheeseplus changed the title Minimize script blows up image file Minimize script results in large (non-sparse) image file for QEMU builder Sep 22, 2015
@cheeseplus
Copy link
Contributor

Pretty sure Packer fixes this themselves - see release notes for 0.9.0

https://github.com/mitchellh/packer/blob/master/CHANGELOG.md#090-february-19-2016

@cheeseplus
Copy link
Contributor

Closing as fixed upstream but if it's still present I'm happy to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants