Instructions and best practices for creating base images for StratusLab

OS installation

The base installation of the OS can be done with a virtualisation software like VirtualBox, QEMU/KVM or VMware Player.

  • Create a new VM and select an IDE bus for your HDD (very important for Windows).
  • When installing your OS it is recommended to choose a simple HDD layout (for example only 1 partition for / and no swap).
  • Choose DHCP method to get an IP address.

Configuration

When installation has finished and VM has rebooted:

  • Add programs and configurations you want.
  • For Windows, install updates (recommended) and activate Windows Remote Desktop service (RDP server).
  • For Linux, install openssh server.
  • Edit /etc/fstab (it is recommended to use UUID except for the extra swap disk) to remove the cdrom line and add a line for a swap disk in /dev/sdb (/dev/hdb on SL550). For example: /dev/sdb swap swap defaults 0 0
  • Remove /etc/udev/rules.d/70-persistent-net.rules and /etc/udev/rules.d/70-persistent-cd.rules.
  • For SL and RHEL edit /etc/sysconfig/network-scripts/ifcfg-eth0 and remove the line with the mac address.

Contextualisation (Linux only)

  • Install StratusLab contextualisation package (RPM availlable at http://quattorsrv.lal.in2p3.fr/packages/stratuslab/stratuslab-one-context-0.0.1-0.20111215.110102.noarch.rpm). If you don't use a RPM package manager just extract the package in / and run /usr/bin/stratuslab-one-context-postinstall
  • Edit /etc/stratuslab/stratuslab-one-context.cfg and set the cdrom block device to sr0 (hdd on SL550).
  • Edit /etc/stratuslab/conf.d/01-password.context to activate random password and force root user to log in with a ssh key.
  • Edit /etc/stratuslab/conf.d/99-quattor.context to activate configuration with Quattor.

Exportation

  • When configuration and contextualization are done, shutdown your VM.
  • Convert the virtual HDD to raw disk format with that command:
vboxmanage internalcommands converttoraw disk.vdi disk.img

Be careful to have enough free disk space when you do that because it will deflate the disk image.

  • Then compress it with:
cat disk.img | gzip > disq.img.gz
  • Or convert it to qcow2 format:
qemu-img convert -c -f raw -O qcow2 disk.img disk.qcow2

You need of course qemu-img installed to do that. The conversion takes more time than gzip it's really worth it.

Now your disk image is ready. Serve hot, test it and enjoy!

Best practices

  • DHCP for the main network interface.
  • Use a simple HDD layout, no need for swap partition.
  • Delete all occurrences of the mac address of the network interface(s) (udev, sysconfig).
  • Keep in mind that each instance is a clone. You can use contextualisation to specialize them.
  • Bookmark at
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at del.icio.us
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at Digg
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at Reddit
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at Google
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at StumbleUpon
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at Facebook
  • Bookmark "Instructions and best practices for creating base images for StratusLab" at Twitter