Thursday, September 27, 2012

Cleaning up a virtual image before performing a Bundle

Below are instructions to remove ssh keys, logs, rightlink state, etc. before bundling a running VM into an image. This is typically a good idea, especially if you plan to share you image with others.  

DISCLAIMER: This code should work on CentOS, RHEL and Ubuntu.  See notes at bottom of post before running.  This post was written specifically for cleaning RightImages, but should apply to custom images as well.  This is alpha code provided with no warranty, YMMV.
That being said, feel free to post questions or issues and I will do what I can to help.

Cleaning a virtual image

Download clean_for_rebundle.tar

Step 1: configure VM the way you want it
Step 2: clean up the system before image "bundle" using attached script

vagrant@lucid32:/vagrant/data$ sudo cp clean_for_rebundle.tar /root/
vagrant@lucid32:/vagrant/data$ sudo -i
root@lucid32:~# tar xvf clean_for_rebundle.tar 
clean.sh
functions.sh
truncate.sh
root@lucid32:~# ./clean.sh

Step 3: rebundle image using cloud API or "bundle" button on rightscale dashboard.
Step 4: ??
Step 5: profit!



Notes

Just some extra info that may be pertainate to the image you are attempting to clean...

RightLink 5.7 

The tar file contains a clean.sh file for RightScale RightLink 5.8 images.  Replace this file with the contents of clean_rightlink5_7.sh if bundling a VM running on an older rightimage.  

CentOS/RHEL 

you must first have lsb_release utility installed.  To install run:

> sudo yum install -y redhat-lsb


Good luck!!

Source code project here https://github.com/caryp/clean_for_rebundle

No comments: