openshift / vagrant-openshift

Other
83 stars 117 forks source link

libvirt provider requires 50 GB of disk space #548

Open tiran opened 7 years ago

tiran commented 7 years ago

The libvirt box for vagrant-openshift require a lot of disk space:

Why is the libvirt image so large? Is there any way to make the image smaller? My laptop has a 250 GB SSD with 40 GB disk space for the root partition.

I prefer to use libvirt because I'm usually running multiple VMs at the same time. The other VMs are all managed by libvirt. Due to hardware and software restrictions it is not possible to run Virtualbox and libvirt at the same time. tl;dr only one Kernel driver can utilize a CPU's hardware virtualization feature.

stevekuznetsov commented 7 years ago

I'm struggling to find the work, but I remember looking into some workflow with qemu-img and/or virt-sysprep to reduce the size of the images. I'm amazed that the image you're seeing is 22GB -- IIRC the ones I was building were ~3GB. Could you post the link to the image and disk usage information for it on your system?

tiran commented 7 years ago
$ vagrant plugin install vagrant-openshift
...
$ vagrant origin-local-checkout -u tiran
...
$ cd $GOPATH/src/github.com/openshift/origin
$ vagrant origin-init --stage inst --os fedora
$ vagrant up --provider=libvirt
Bringing machine 'openshiftdev' up with 'libvirt' provider...
==> openshiftdev: Box 'fedora_inst' could not be found. Attempting to find and install...
    openshiftdev: Box Provider: libvirt
    openshiftdev: Box Version: >= 0
==> openshiftdev: Box file was not detected as metadata. Adding it directly...
==> openshiftdev: Adding box 'fedora_inst' (v0) for provider: libvirt
    openshiftdev: Downloading: https://mirror.openshift.com/pub/vagrant/boxes/openshift3/fedora_libvirt_inst.box
    openshiftdev: Progress: 3% (Rate: 6086k/s, Estimated time remaining: 0:15:10)

The vagrant up command downloads a large compressed file (5.4 G) and extracts a 21.7 GB qcow2 image from it:

$ ls -lah ~/.vagrant.d/tmp/box022b83e2b8674afa1d877a7cdf9d2d109e3ff882 
-rw-rw-r--. 1 heimes heimes 5,4G Jun 20 16:49 /home/heimes/.vagrant.d/tmp/box022b83e2b8674afa1d877a7cdf9d2d109e3ff882
$ tar -tzvf /home/heimes/.vagrant.d/tmp/box022b83e2b8674afa1d877a7cdf9d2d109e3ff882
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.selinux'
-rw-rw-r-- dmcphers/dmcphers 57 2016-11-11 00:37 ./metadata.json
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.selinux'
-rw-rw-r-- dmcphers/dmcphers 136 2016-11-11 00:37 ./Vagrantfile
tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.security.selinux'
-rw-r--r-- dmcphers/dmcphers 21666988032 2016-11-11 00:40 ./box.img

Do you need more information?

raghavendra-talur commented 7 years ago

one possible fix(for the maintainer) to create images again:

  1. use qemu img to rewrite the disk file. This removes the sparseness of file from file system view but retails the virtual size in the view of qemu. qemu-img convert -O qcow2 box.img box2.img
  2. mv box.img box_old.img
  3. mv box2.img box.img

This worked for me.