From 3fada2566a366c8bc1b668e91c8412b8fb63fd7a Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Thu, 1 May 2014 10:22:15 +0100 Subject: [PATCH] Build raw image in separate tmpfs If the tmpfs being used to hold the image filesystem is close to being full then housing the raw disk image in the same place can be problematic as it tends to grow faster then the filesystem shrinks when data is being moved into it. Putting them both into separate tmpfs's will allow there to be an overlap where they jointly use more then the size limit for a singe tmpfs. Change-Id: Ia17ca357d3b865d70a2d3e13e0479d008ca5f924 Closes-Bug: #1289582 --- lib/common-functions | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/common-functions b/lib/common-functions index 0e1b67bdd..9f40e568f 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -28,15 +28,17 @@ function tmpfs_check() { function mk_build_dir () { TMP_BUILD_DIR=$(mktemp -t -d --tmpdir=${TMP_DIR:-/tmp} image.XXXXXXXX) + TMP_IMAGE_DIR=$(mktemp -t -d --tmpdir=${TMP_DIR:-/tmp} image.XXXXXXXX) [ $? -eq 0 ] || die "Failed to create tmp directory" export TMP_BUILD_DIR if tmpfs_check ; then sudo mount -t tmpfs tmpfs $TMP_BUILD_DIR + sudo mount -t tmpfs tmpfs $TMP_IMAGE_DIR fi - sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR + sudo chown $(id -u):$(id -g) $TMP_BUILD_DIR $TMP_IMAGE_DIR trap cleanup EXIT echo Building in $TMP_BUILD_DIR - export TMP_IMAGE_PATH=$TMP_BUILD_DIR/image.raw + export TMP_IMAGE_PATH=$TMP_IMAGE_DIR/image.raw export TMP_HOOKS_PATH=$TMP_BUILD_DIR/hooks } @@ -190,8 +192,8 @@ function mount_qcow_image() { function cleanup_dirs () { sudo rm -rf $TMP_BUILD_DIR/built sudo rm -rf $TMP_BUILD_DIR/mnt - sudo umount -f $TMP_BUILD_DIR || true - rm -rf $TMP_BUILD_DIR + sudo umount -f $TMP_BUILD_DIR $TMP_IMAGE_DIR || true + rm -rf $TMP_BUILD_DIR $TMP_IMAGE_DIR } # Run a directory of hooks outside the target.