Configuring temp directory for virt-builder
I was playing around with virt-builder to speed up configuration for some VMs. I was building images on my laptop, which has a /var
partition that's only about 9 GiB, with only a couple gigabytes free. By default on my machine, virt-builder uses a directory under /var/tmp
to extract VM images. Maybe you can see where this is going--the extracted image wouldn't fit in my /var
partition and virt-builder failed.
I couldn't tell that a full partition was the problem at first. I enabled an environment variable to see debug messages: export LIBGUESTFS_DEBUG=1
. This told me a command called "supermin" was failing. It was writing its output in /var/tmp
, and I saw that it was running out of disk space.
I wanted to change the cache directory, but I couldn't find a command-line flag or environment variable in the manpage for configuring it. I took a look at the code instead, and I found my way to the build_supermin_appliance
function by searching for a log statement "run supermin".
From there I found a variable int_cachedir
. Thankfully a docstring in the code says I can change it by setting the environment variable LIBGUESTFS_CACHEDIR
. I set it to $HOME/.cache/virt-builder
and I was able to build the image successfully!