Corporate Home Open Source Home
Syndicate content
Eucalyptus

Creating an image from an existing VM (CentOS)

These instructions are largely taken from the forum post Creating image from existing VM but geared towards CentOS.

  1. Run an instance of the image.
  2. You need to make sure you have enough space on your instance to create your new image. You'll have to attach some more storage according to the instructions at Interacting with Block Storage. My image was 2 GB in size (but not all of it was used) so I created a 2GB volume.
  3. Once the volume is attached you need to make a file system on it and mount it to /mnt. We're using KVM so it got attached to /dev/vdb.
    mkfs -t ext3 /dev/vdb
    mount /dev/vdb /mnt
  4. SCP your Eucalyptus credential bundle (i.e., euca2-xxxxx-x509.zip) to the /mnt dir of the instance: scp -i yourkey.private euca2-xxxxxxx-x509.zip root@xxx.xxx.xxx.xxx:/mnt
  5. SSH into the instance:ssh -i yourkey.private root@xxx.xxx.xxx.xxx
  6. Install some necessary tools for later:
    yum install rsync unzip
  7. Change to the /mnt device (it should have enough space to create new image bundle): cd /mnt
  8. Unzip your Eucalyptus credentials zip to /mnt/euca:unzip euca2-admin-x509.zip -d euca/
  9. Follow the instructions for Installing Euca2ools on CentOS 5
  10. Install any other software you want on instance so it will be part of your new image.
  11. Source your Eucalyptus script: . /mnt/euca/eucarc
  12. Bundle the image:
    euca-bundle-vol -c ${EC2_CERT} -k ${EC2_PRIVATE_KEY} -u ${EC2_USER_ID} --ec2cert ${EUCALYPTUS_CERT} --no-inherit --kernel eki-KKKKKKKK --ramdisk eri-RRRRRRRR -d /mnt -r ARCH -p NEW_IMAGE_NAME -s SIZE_IN_MBs -e /mnt,/root/.ssh,OTHER_DIRS_TO_EXCLUDE

    eki-KKKKKKKK -> same as with running instance
    eri-RRRRRRRR -> same as with running instance

    For example:
    euca-bundle-vol -c ${EC2_CERT} -k ${EC2_PRIVATE_KEY} -u ${EC2_USER_ID} --ec2cert ${EUCALYPTUS_CERT} --no-inherit --kernel eki-47C7126D --ramdisk eri-80991354 -d /mnt -r x86_64 -p new.centos.5-3.x86-64.2GB.img -s 2048 -e /mnt,/root/.ssh

  13. Upload the bundle:euca-upload-bundle -b BUCKET_NAME -m /mnt/NEW_IMAGE_NAME.manifest.xml
    1. I got a "You do not have permission to access bucket: BUCKET_NAME" error at this point. After hunting around the forums to fix it I just did:
      yum install -y ntp
      ntpdate pool.ntp.org
  14. Register the bundle:
    euca-register BUCKET_NAME/NEW_IMAGE_NAME.manifest.xml