Differences between revisions 12 and 13
Revision 12 as of 2013-08-19 13:52:40
Size: 4657
Editor: ?FernandoLagrange
Comment: Added Debian Wheezy 7.1 guidelines.
Revision 13 as of 2013-10-15 11:20:10
Size: 5939
Comment: Updated for wheezy, and moving squeeze to a later section
Deletions are marked like this. Additions are marked like this.
Line 15: Line 15:
=== Preparing a Debian stable/squeeze amd64 image === === Preparing a Debian stable/wheezy amd64 image ===

 * Download an installer CD iso image, for instance :<<BR>>{{{
$ wget http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-7.2.0-amd64-netinst.iso
}}}
 * Prepare a VM disk image file (for instance of size 5 Gb)<<BR>>{{{
$ qemu-img create debian-7.2.0-amd64-one.img -f raw 5G
}}}
 * Boot the installer to install it on the prepared disk image file. ATTENTION :
  * do this on machine running an amd64 kernel if generating amd64 image :<<BR>>{{{
$ kvm -m 512 -cdrom debian-7.2.0-amd64-netinst.iso -boot d debian-7.2.0-amd64-one.img
}}}
  * or do that if you run a different architecture kernel (i386 for instance) on the machine on which you prepare the AMD64 image (you'll notice it's then slow, but that works) :<<BR>>{{{
$ qemu-system-x86_64 -m 512 -cdrom debian-7.2.0-amd64-netinst.iso -boot d debian-7.2.0-amd64-one.img
}}}
 * If you know exactly what your future VM instances will be used for, then choose appropriate packages. You probably need the default selection otherwise, with maybe the OpenSSH server if you intend to later access it from the network once deployed. Choosing an english qwerty keyboard may be a safe bet too, as there are some problems with VNC connection to VMs with other keymaps, AFAICT.
 * Reboot your VM, without the CD to check that it works, and proceed with the contextualization of the system, with either :
  * if same arch : <<BR>>{{{
$ kvm -no-acpi -m 512 debian-7.2.0-amd64-one.img
}}}
  * or : <<BR>>{{{
$ qemu-system-x86_64 -no-acpi -m 512 debian-7.2.0-amd64-one.img
}}}


=== Preparing an old Debian squeeze amd64 image ===
Line 37: Line 62:
}}}

=== Preparing a Debian stable/wheezy amd64 image ===

Follow the same steps as a squeeze amd64 image above. In short, for a 5G disk image and with first Debian installation CD:
{{{
$ qemu-img create debian-7.1-amd64-one.img -f raw 5G
$ kvm -m 512 -cdrom debian-7.1.0-amd64-CD-1.iso -boot d debian-7.1-amd64-one.img

This page is meant to describe ways to prepare a Debian VM image ready to be used to deploy VM instances in OpenNebula.

Principles

The first step needed is to install a Debian system onto a system image which will be later run with the virtualizer of OpenNebula, typically kvm.

The easiest way to do this is to perform a Debian install inside qemu/kvm on a machine which may not be the OpenNebula execution host.

Attention : if the target is supposed to run a i686 VM, be careful to install from an i386 installer, and likewise for amd64.

After installation, the system will need to be personalized to include some scripts needed by OpenNebula. These scripts are executed upon boot, and to the contextualization of the VM : when OpenNebula deploys a VM, it will boot its image providing it with an iso9660 CD image which it will have prepared so that it contains a context definition file. The personalization you'll add to the VM image is the means to load that context file upon boot.

Howtos

Preparing a Debian stable/wheezy amd64 image

  • Download an installer CD iso image, for instance :

    $ wget http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-7.2.0-amd64-netinst.iso
  • Prepare a VM disk image file (for instance of size 5 Gb)

    $ qemu-img create debian-7.2.0-amd64-one.img -f raw 5G 
  • Boot the installer to install it on the prepared disk image file. ATTENTION :
    • do this on machine running an amd64 kernel if generating amd64 image :

      $ kvm -m 512 -cdrom debian-7.2.0-amd64-netinst.iso -boot d debian-7.2.0-amd64-one.img 
    • or do that if you run a different architecture kernel (i386 for instance) on the machine on which you prepare the AMD64 image (you'll notice it's then slow, but that works) :

      $ qemu-system-x86_64 -m 512 -cdrom debian-7.2.0-amd64-netinst.iso -boot d debian-7.2.0-amd64-one.img 
  • If you know exactly what your future VM instances will be used for, then choose appropriate packages. You probably need the default selection otherwise, with maybe the OpenSSH server if you intend to later access it from the network once deployed. Choosing an english qwerty keyboard may be a safe bet too, as there are some problems with VNC connection to VMs with other keymaps, AFAICT.
  • Reboot your VM, without the CD to check that it works, and proceed with the contextualization of the system, with either :
    • if same arch :

      $ kvm -no-acpi -m 512 debian-7.2.0-amd64-one.img 
    • or :

      $ qemu-system-x86_64 -no-acpi -m 512 debian-7.2.0-amd64-one.img 

Preparing an old Debian squeeze amd64 image

  • Download an installer CD iso image, for instance :

    $ wget http://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-6.0.7-amd64-netinst.iso
  • Prepare a VM disk image file (for instance of size 1 Gb)

    $ qemu-img create debian-6.0.7-amd64-one.img -f raw 1G 
  • Boot the installer to install it on the prepared disk image file. ATTENTION :
    • do this on machine running an amd64 kernel if generating amd64 image :

      $ kvm -m 512 -cdrom debian-6.0.7-amd64-netinst.iso -boot d debian-6.0.7-amd64-one.img 
    • or do that if you run a different architecture kernel (i386 for instance) on the machine on which you prepare the AMD64 image (you'll notice it's then slow, but that works) :

      $ qemu-system-x86_64 -m 512 -cdrom debian-6.0.7-amd64-netinst.iso -boot d debian-6.0.7-amd64-one.img 
  • If you know exactly what your future VM instances will be used for, then choose appropriate packages. You probably need the default selection otherwise, with maybe the OpenSSH server if you intend to later access it from the network once deployed. Choosing an english qwerty keyboard may be a safe bet too, as there are some problems with VNC connection to VMs with other keymaps, AFAICT.
  • Reboot your VM, without the CD to check that it works, and proceed with the contextualization of the system, with either :
    • if same arch :

      $ kvm -no-acpi -m 512 debian-6.0.7-amd64-one.img 
    • or :

      $ qemu-system-x86_64 -no-acpi -m 512 debian-6.0.7-amd64-one.img 

Customize the booted image to add contextualization boot scripts

Note: for OpenNebula 4.2 there is no need to modify rc.local file. Instead, launch you image and install image contextualization package. See Generic Contextualisation documentation.

Note: the following assumes that you want to proceed to Generic Contextualization (as opposed to another mechanism proposed in OpenNebula, see the docs above).

  • Add the following lines to /etc/rc.local (adapted from http://opennebula.org/documentation:archives:rel3.2:cong#example to use mount -t iso9660 /dev/sr0 /mnt) :

    mount -t iso9660 /dev/sr0 /mnt
     
    if [ -f /mnt/context.sh ]; then
      . /mnt/init.sh
    fi
     
    umount /mnt


    as you can see, the goal is to mount the CD iso image provided to the VM instance by ?OpenManage, which will contain the context.sh and init.sh which will do the work (note that such an init script could be provided by some package ready to be installed to images, instead of having to manually modify it, see bts:657292)

You may now shutdown the VM, and copy its .img file to the OpenNebula monitor host, and create an image that will be registered in the available images for VM instanciation.

See OpenNebula/PreparingDebianVmTemplate for hints on how to prepare the Debian VM template that will be booted off the image.