Merge "Honor $DIB_IMAGE_SIZE."

This commit is contained in:
Jenkins 2013-05-13 17:56:17 +00:00 committed by Gerrit Code Review
commit ffdf0ba7ff
3 changed files with 18 additions and 10 deletions

View File

@ -108,19 +108,27 @@ prepare_first_boot
# Free up /mnt
unmount_image
mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built
MKFS_OPTS=""
if [ -n "$DIB_IMAGE_SIZE" ]; then
truncate -s${DIB_IMAGE_SIZE}G $TMP_IMAGE_PATH
else
# in kb*0.8 - underreport to get a slightly bigger device
_NEEDED_SIZE=$(sudo du --block-size=800 -x -s ${TMP_BUILD_DIR}/built | awk ' { print $1 } ')
truncate -s${_NEEDED_SIZE}K $TMP_IMAGE_PATH
if [ "$FS_TYPE" = "ext4" ] ; then
# Very conservative to handle images being resized a lot
MKFS_OPTS="-i 4096"
fi
fi
LOOPDEV=$(sudo losetup --show -f $TMP_IMAGE_PATH)
export EXTRA_UNMOUNT="detach_loopback $LOOPDEV"
export IMAGE_BLOCK_DEVICE=$LOOPDEV
eval_run_d block-device "IMAGE_BLOCK_DEVICE="
OPTS=""
if [ "$FS_TYPE" = "ext4" ] ; then
# Very conservative to handle images being resized a lot
OPTS="-i 4096"
fi
sudo mkfs $OPTS -t $FS_TYPE -L cloudimg-rootfs ${IMAGE_BLOCK_DEVICE}
sudo mkfs $MKFS_OPTS -t $FS_TYPE -L cloudimg-rootfs ${IMAGE_BLOCK_DEVICE}
mkdir $TMP_BUILD_DIR/mnt
sudo mount ${IMAGE_BLOCK_DEVICE} $TMP_BUILD_DIR/mnt
sudo mv -t $TMP_BUILD_DIR/mnt ${TMP_BUILD_DIR}/built/*

View File

@ -37,7 +37,6 @@ FS_TYPE=${FS_TYPE:-ext4}
# Used to set the file extension only at this stage.
IMAGE_TYPE=${IMAGE_TYPE:-qcow2}
IMAGE_NAME=${IMAGE_NAME:-image}
export DIB_IMAGE_SIZE=${DIB_IMAGE_SIZE:-2} # N.B. This size is in GB
export DIB_NO_TMPFS=${DIB_NO_TMPFS:-0}
# Set via the CLI normally.
# IMAGE_ELEMENT=

View File

@ -37,6 +37,7 @@ ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/dev
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/proc
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/sys
ALL ALL=(root) NOPASSWD: /bin/umount -f /tmp/*/mnt/tmp/in_target.d
ALL ALL=(root) NOPASSWD: /sbin/mkfs -t ext4 -L cloudimg-rootfs /dev/loop*
ALL ALL=(root) NOPASSWD: /sbin/mkfs -i 4096 -t ext4 -L cloudimg-rootfs /dev/loop*
ALL ALL=(root) NOPASSWD: /sbin/modprobe nbd max_part=16
ALL ALL=(root) NOPASSWD: /sbin/sfdisk /dev/nbd*