Apr 23, 2012

How to Create an Ubuntu Template for HyperVM

,


HyperVM is a multi-server virtualization software platform developed by Lxcenter that enables its users to create, manage and deploy Xen and OpenVZ virtual private servers. You can create a template using, for example, the Ubuntu operating system, configure it and use it to deploy multiple virtual machines with just a few mouse clicks. You can also add repositories, networks and even software packages to your new template to ensure the virtual machine is up and running as soon as the template is applied.

Instructions

    • 1
      Open the "Applications" menu, select "Accessories" and click "Terminal" to open the Terminal utility.
    • 2
      Create an ext3 filesystem with a size of 10 gigabytes to store the new template by running these commands:
      sudo lvcreate -L 10G -n Ubuntu-disk VolGroup00
      sudo mkfs.ext3 /dev/VolGroup00/Ubuntu-disk
    • 3
      Create a tmp folder and mount the new filesystem by running these commands in the Terminal:
      sudo mkdir /mnt/tmp
      sudo mount /dev/VolGroup00/Ubuntu-disk /mnt/tmp
    • 4
      Get and install an older version of debootstrap to avoid dependency problems by running these commands in the Terminal:
      wget http://www.modernadmin.com/downloads/ostemplates/debootstrap-1.0.10-1.fc10.noarch.rpm
      sudo rpm -Uvh debootstrap-1.0.10-1.fc10.noarch.rpm
    • 5
      Get and install Ubuntu in the tmp folder using debootstrap by running this command in the Terminal:
      sudo debootstrap --include=udev,ssh,quota --arch amd64 jaunty /mnt/tmp http://uk.archive.ubuntu.com/ubuntu/
    • 6
      Insert some sources for the APT tool in the template, in case you need to download some packages later. Use these commands:
      sudo cat <<EOF > /mnt/tmp/etc/apt/sources.list
      deb http://gb.archive.ubuntu.com/ubuntu/ jaunty main restricted universe multiverse
      deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty main restricted universe
      deb http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted universe multiverse
      deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty-updates main restricted universe
      deb http://security.ubuntu.com/ubuntu jaunty-security main restricted universe
      deb-src http://security.ubuntu.com/ubuntu jaunty-security main restricted universe
      EOF
    • 7
      Create a network interface and configure the template for optimal performance by running these commands in the Terminal:
      sudo cat <<EOF > /mnt/tmp/etc/network/interfaces
      auto eth0 lo
      iface eth0 inet static
      address IP.Address
      netmask 255.255.255.0
      up route add -net IP.address netmask 255.255.255.0 dev eth0
      up route add default gw IP.address
      iface lo inet loopback
      EOF
      sudo cat <<EOF > /mnt/tmp/etc/hosts
      127.0.0.1 localhost Ubuntu template
      EOF
      sudo cat <<EOF > /mnt/tmp/etc/hostname
      Ubuntu template
      EOF
      sudo cat <<EOF > /mnt/tmp/etc/fstab
      proc /proc proc defaults 0 0
      devpts /dev/pts devpts defaults 0 1
      /dev/sda2 none swap sw 0 1
      /dev/sda1 / ext3 errors=remount-ro 0 1
      EOF
      sudo cat <<EOF > /mnt/tmp/etc/event.d/xvc0
      start on stopped rc2
      start on stopped rc3
      start on stopped rc4
      start on stopped rc5
      stop on runlevel 0
      stop on runlevel 1
      stop on runlevel 6
      respawn
      exec /sbin/getty 38400 xvc0
      EOF
      sudo rm -rf /mnt/tmp/etc/event.d/tty1
      sudo echo “alias eth0 xennet” > /mnt/tmp/etc/modprobe.d/xen
      #echo “xvc0″ >> /mnt/tmp/etc/securetty
      sudo cat /dev/null > /mnt/tmp/etc/udev/rules.d/70-persistent-net.rules
      Replace "IP.Address" with your IP address and "Ubuntu template" with the name of your template.
    • 8
      Chroot to the new template and set a new password by running these commands in the Terminal:
      sudo chroot /mnt/tmp
      passwd your_password
      Replace "your_password" with a real password.
    • 9
      Unmount the Ubuntu template by running the following commands in the Terminal:
      exit
      sudo umount /mnt/tmp
    • 10
      Create a TAR.GZ archive out of the template by running these commands:
      cd /mnt/tmp
      sudo tar czf /home/hypervm/xen/template/ubuntu-9.04-x86_64-UbuntuTemplate.tar.gz .
      sudo chmod 755 /home/hypervm/xen/template/ubuntu-9.04-x86_64-UbuntuTemplate.tar.gz
 

HowToYo Copyright © 2011 | Template design by O Pregador | Powered by Blogger Templates