Growing an image file

sjones4 edited this page Apr 22, 2013 · 5 revisions
Clone this wiki locally

Filesystems generated by image creation tools such as ami-creator are often made quite small by default, to ensure that they can be used on Eucalyptus systems with vm types allocating as little as 2 GB for the root disk. If you have one of these image files (such as the one created by the FastStart install, which is left in /tmp/img on the frontend system) and you simply want a larger version, here's how you do that:

Let's say your image is ks-centos6-201302151307.img and you want to grow it to ~9.5G (the largest that will work on a 10GB vm type in eucalyptus, since 512 MB will be swap).

  1. Resize the file: dd if=/dev/zero bs=1M seek=9500 count=1 of=ks-centos6-201302151307.img
  2. Resize the filesystem contained in the file: resize2fs ks-centos6-201302151307.img
  3. Bundle the image (using the same eki and eri that the original image used; use euca-describe-images to determine this):
euca-bundle-image --kernel eki-74C34082 --ramdisk eri-DAB1400A -i ks-centos6-201302151307.img
  1. Upload: euca-upload-bundle -b centos6bigger -m /tmp/ks-centos6-201302151307.img.manifest.xml
  2. Register: euca-register centos6bigger/ks-centos6-201302151307.img.manifest.xml

That's it. Your new, larger image is ready to run.

What if you no longer have the image file?

This problem is a bit trickier if you no longer have the image file on your system. If you are the owner of the image in your cloud, though, there's hope. I mangled the euca-unbundle utility into a new euca-download-and-unbundle script. So you can grab that and use it to fetch an existing image from walrus. Just determine the manifest path by running euca-describe-images. Example output:

IMAGE	emi-CD1C39B7	centos6/ks-centos6-201302151307.manifest.xml	495684638284	available	
public x86_64	machine	eki-74C34082	eri-DAB1400A		instance-store

in this case, centos6/ks-centos6-201302151307.manifest.xml is the manifest path.

NOTE: When you modify an image, you should either change the file name or upload it to a different bucket. If you upload to the same bucket and file name, your previous image will be overwritten, but it may take time for the cloud's various caches to invalid, which could lead to errors. category.images