Skip to content

Creates and installs a new instance of a virtual machine (guest) in a KVM node.

Notifications You must be signed in to change notification settings

funollet/vmbootstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lxcinstance

Deploys an LXC container with lxc-create -t debian plus a couple of customizations. This is a fast way of creating local containers for development. You probably want to ajust it according to your development environment.

vminstance

Creates a new instance of a virtual machine in the (localhost) node, ready to boot via PXE. Another system must take care of boostrapping it (suggestion: FAI).

The script can also mount/umount volumes associated to a virtual machine, and delete it (both the guest definition and its volumes).

vmbootstrap

Creates and installs a new instance of a virtual machine (guest) in the KVM node that runs the script. This includes:

  • Configure a libvirt instance.
  • Create filesystems.
  • Debootstrap a Debian system.
  • Make the guest bootable: install a kernel and configure Grub.
  • Configure the guest so it can be accessed by SSH.

vmbootstrap configures the VM just to the point of being usable with ssh. Any other configuration is left to deployment tools (Capistrano, Fabric) or configuration management tools (Puppet, Chef, Cfengine).

Right now only KVM is supported for virtualization and only Debian guests can be installed.

The guest is installed with debootstrap. This makes the configuration easier to tweak than with a tool based on presseding debian-installer.

This script is largely inspired by:

Filesystem layout

Every guest's partition has a LV on the KVM node. No partitions neither LVM is done inside the guest. That makes easy to grow disks and resize/fsck filesystems from the KVM node.

The only exception is for /boot: the disk has a partition so we can install Grub on the MBR.

So, if we have a VG called 'host' and the new machine is called 'guest', there will be three LV on the host:

/dev/host/guest-boot
/dev/host/guest-root
/dev/host/guest-swap

Guest's /etc/fstab will look like this:

/dev/vda1   /boot   ext3   defaults   0 0
/dev/vdb    /root   ext3   defaults   0 0
/dev/vdc    none    swap   sw         0 0

Network and default values

The libvirt instance has the network configured as 'bridge'.

Default values are infered from the KVM host. All of them can be customized in a configuration file (~/.vmbootstrap).

Utilities

Some steps this scripts does are useful too while doing VM maintenance, so command-line options are provided for invoking them:

  • Mount /boot and / (under /mnt/<guest-name>/).
  • Umount.
  • Re-install Grub.
  • Remove a guest's definition and the volumes it was using.

Alternatives

virt-install can do most of these tasks but must be preseed.

vmbuilder will become a very nice option once it supports Debian hosts. Does a similar subset of tasks but doesn't use debootstrap.

Bernd Zeimetz wrote a vmbuilder extension that supports Debian Etch (but not yet Lenny). David Wendt was working on support for Debian as a GSoC-2009.

Cobbler has a lot of (useful) features but installation on Debian doesn't look straighforward.


Jordi Funollet [email protected] Fri, 18 Sep 2009 00:25:26 +0200

About

Creates and installs a new instance of a virtual machine (guest) in a KVM node.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages