Resizing a Machine Image (EMI)

Eucalyptus Affected Versions: All

Resizing Root Filesystem for Machine Image

This guide illustrates how to create a larger root file system as needed for images.  There are a couple of techniques to resize the root filesystem of an image.  This guide will cover both.

Using tar to Copy Data from Old Image to New  Image

Create a new image of the desired size (for example 4GB):

    $ dd if=/dev/zero of=new.img bs=1M count=4096

    # mkfs.ext3 -F new.img

Create temporary mount points for the images and to facilitate a copy between them: 

    $ mkdir old && mkdir new

Mount them respectively:

    # mount -o loop old.img old # mount -o loop new.img new

Copy the data out of the old img and into the new:

    # (cd old; tar czf - .) | (cd new; tar xzf -)

Then unmount the images:

    # umount old
    # umount new

The new image now contains the same contents as the older, smaller image.  Register and upload to the Eucalyptus cloud to begin using it.   

Using resize2fs

Another method is using resize2fs.  Before resizing the image, use e2fsck to check the filesystem of the image:

$ sudo e2fsck -f centos-6.3-x86_64.img
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
_/: 24952/292032 files (1.6% non-contiguous), 258564/1167360 blocks

After the check has been executed, use resize2fs to resize the image to the desired size.  In the example below, the image is resized to 10 Gigabytes:

$ sudo resize2fs centos-6.3-x86_64.img 10G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on centos-6.3-x86_64.img to 2621440 (4k) blocks.
The filesystem on centos-6.3-x86_64.img is now 2621440 blocks long.

The image is now ready to be bundled, uploaded and registered to Eucalyptus

 

Have more questions? Submit a request

Comments

Please sign in to leave a comment.