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
This commit is contained in:
parent
b46ece4de9
commit
3fada2566a
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user