Corporate Home Open Source Home
Syndicate content
Eucalyptus

Creating images from ISO (xen)

This page explains how to create a root filesystem to be used with Eucalyptus using xen and an iso image of the guest OS you want to install.

Prerequisite: You must have hardware virtualization support (hvm must be functioning on your system) and xen must be installed and properly functioning (i.e., you must be able to start domU).

These are the steps:

  • Download the iso image of the distro (guest OS) you want to install.
  • Create a virtual 'disk' of the desired size (example 4GB):
    dd if=/dev/zero of=new.img bs=1M count=4096
  • Create a xen configuration file to (say xen.cfg) boot off the ISO image: it should be similar to the following:
    name = "bootFromISO"
    kernel = "/usr/lib/xen/boot/hvmloader"
    memory = 1024
    builder = "hvm"
    device_model = "/usr/lib64/xen/bin/qemu-dm"
    boot = "d"
    disk = ['file:PATH_TO_ISO,hdc:cdrom,r',
    'file:PATH_TO/new.img,sda,w']
    vif = ['mac=00:01:01:00:00:03, bridge=xenbr0']
    dhcp="on"
    vnc = 1
    vncdisplay = 7
    pae = 1

    NOTE: You must modify device_model and kernel since they depend on where the distribution puts such files. Look into the xen package file list. Also be sure that all the options are correct for your needs.
  • Start the domU:
    xen create xen.cfg
  • Connect with a vnc viewer, for example:
    xvncviewer localhost:7
  • Install the distro as you would normally to: do not use lvm or md and install everything in one partition. Remember the partition in which the distro is installed.

    NOTE: Most distributions will remember the network interfaces by the MAC address so that interfaces will always be the same (that is eth0 and eth1 will not be inverted accidentally). In Eucalyptus you have to get the distribution to forget the NIC, so that every instance will see the interface as the first interface. To do so you may want to see to the specific distribution: for example debian/ubuntu uses udev so check /etc/udev/rules.d/*net* while centos may have something in /etc/network-scripts/ifcfg-eth0. Failure to do so may leave your instance without network.

  • Stop the domU.
  • Find out the starting block and the block size of the root file systems. To do so you can use parted:
    parted new.img
    get parted to use blocks as unit: type 'U' then 'b' (this will change the units to blocks)
    (parted) U
    Unit? [compact]? b

    then print the current partition table using 'p':
  • Note the start for the partition you are interested in and the size (for this example let's say start is 32256 and the size is 10000000).
  • Extract the file system:
    dd if=new.img of=rootfs.img bs=1 skip=32256 count=10000000
  • Now you have the file 'rootfs.img' which contains the root file system.
    make sure that is compatible with the kernel/initrd you are using in your
    cloud environment (in particular you may want to be sure you have the
    modules of the kernel you are going to use).