Set tmp directory for virt-sparsify

virt-sparsify uses about 10 GB temporary work space. The default (/tmp)
is often too small (especially if it is a RAM disk) and filled up by
virt-sparsify which hangs when it runs out of space.

With this changeset, we use the pool_dir as a tmp directory. On typical
systems, this means that instead of /tmp, the root partition needs to
have an extra 10 GB of space left, which should be much more likely to
work.

Change-Id: I4bf66474d6338c0e2e8eb76126ee496b13bc3c46
This commit is contained in:
Roger Luethi 2017-05-01 10:44:03 +02:00
parent 3539c4f950
commit 676a4f13cb
2 changed files with 11 additions and 3 deletions

View File

@ -381,8 +381,11 @@ function disk_compress {
sudo ls -lh "$disk_path"
sudo du -sh "$disk_path"
# Sparsify and compress basedisk image
sudo "$spexe" --compress "$disk_path" "$pool_dir/.$disk_name"
# virt-sparsify uses about 10 GB additional, temporary work space.
# The default (/tmp) is often too small (especially if it is a RAM
# disk). We use the pool_dir instead.
sudo "$spexe" --tmp "$pool_dir" --compress "$disk_path" \
"$pool_dir/.$disk_name"
# Copy owner and file modes from original file
sudo chown -v --reference="$disk_path" "$pool_dir/.$disk_name"

View File

@ -564,7 +564,12 @@ def disk_compress(disk_name):
logger.debug("size\t%s", size)
tmp_file = os.path.join(pool_dir, ".{}".format(disk_name))
subprocess.call(["sudo", spexe, "--compress", disk_path, tmp_file])
# virt-sparsify uses about 10 GB additional, temporary work space.
# The default (/tmp) is often too small (especially if it is a RAM
# disk). We use the pool_dir instead.
subprocess.call(["sudo", spexe, "--tmp", pool_dir, "--compress",
disk_path, tmp_file])
logger.info("Restoring owner.")
# No root wrapper, so use sudo with shell commands