cloudstack-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Youri Bonnaffé <youri.bonna...@activeeon.com>
Subject DevCloud : how to customize VHD template
Date Fri, 04 Jan 2013 17:02:25 GMT
Hello,

As I've had issues to create and customize an instance template using
DevCloud, I would like to share how I finally did it. My goals were to
reuse the TTY Linux template, add some custom programs in the template and
create a boot script; basically to be able to quickly start an
autoconfigured instance.

Resizing the VHD template is achievable using vhd-util :
* Download the TTY template using the Cloudstack web client
* On the Xen host, aka the DevCloud virtualbox VM, you can use vhd-util
   vhd-util resize -n mytemplate.vhd -j output.log -s 200 (to extend its
size to 200M)
* On the Xen host create a block device mapped to the VHD file using tap-ctl
  here is a sample script to will do it ($1 MUST be an absolute path)

*device=$(tap-ctl allocate)
deviceid=${device#/dev/xen/blktap-2/tapdev}
echo $deviceid
spawn=$(tap-ctl spawn)
pid=${spawn#tapdisk spawned with pid }
echo $pid
tap-ctl attach -p $pid -m $deviceid
tap-ctl open -p $pid -m $deviceid -a vhd:$1

* * Use resize2fs */dev/xen/blktap-2/tapdev...IDOFDEVICE *to expand the
partition size (fsck might be needed, do it)
 * Now if you mount the device *mount /dev/xen/blktap-2/tapdevID some_folder
* you should see a partition of 200M instead of the 50M default TTY Linux
template

While you are at it you can edit files since the image is mounted.

 * Unmount it when you are done
 * Remove the block device
*      pid=$1
      deviceid=$2
      tap-ctl close -m $deviceid -p $pid
      tap-ctl detach -m $deviceid -p $pid
      tap-ctl free -m $deviceid*

Then can you can import back the VHD template file using the Cloudstack web
client.

I hope it will be helpful to someone, I've been struggling for days to do
it (I'm not familiar with Xen technologies thought).

  Youri,

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message