UEC image resize script

Matt Zimmerman mdz at canonical.com
Thu Oct 1 20:09:56 BST 2009


On Thu, Oct 01, 2009 at 06:52:47PM +0100, Matt Zimmerman wrote:
> This script will take an official UEC image and resize it.  It should work
> on a compressed or uncompressed image, and outputs an uncompressed one.
> This is useful for speeding up testing the image, because the larger the
> image, the longer it takes to encrypt and copy around within Eucalyptus.
> 
> Where would be a good place to stash it?

Fixed version which actually remembers to truncate the file attached. ;-)

-- 
 - mdz
-------------- next part --------------
#!/bin/sh

set -e

if [ $# -lt 3 ]; then
	cat <<EOT >&2
Usage: resize-uec-image <existing image> <output file> <new size>

	Resizes a UEC image to a new size.

	New size is specified per resize2fs(8), e.g. "1G" for 1 gigabyte
EOT
	exit 1
fi

old_image="$1"
new_image="$2"
size="$3"

zcat -f $old_image | cp --sparse=always /dev/stdin $new_image
e2fsck -f $new_image
resize2fs $new_image $size
truncate --size=$size $new_image


More information about the ubuntu-devel mailing list