GitHub on KVM

GitHub Enterprise is a version of GitHub that you can run locally on a company network. It comes as a virtual machine image in Open Virtualization Format and GitHub support it running on the VirtualBox and VMWare hypervisors. At Navetas we use the KVM hypervisor so I have recently been looking at how to convert the GitHub Enterprise VM image to run under KVM.

  1. Download the GitHub Enterprise VM Image in Open Virtualization Archive (.ova) format.
  2. Extract the contents of the archive with:
     tar -xf github-enterprise-11.10.270-i386.ova
    This will give you a set of files:
    • github-enterprise-11.10.270-i386-disk1.vmdk - The disk image
    • github-enterprise-11.10.270-i386.ovf - An XML description of the virtual machine
    • - Hashes of the other two files
  3. Install VMWare Workstation to get the vmware-vdiskmanager tool.
  4. Convert the GitHub disk image to use a preallocated virtual disk (watch out - this file will be 10GB!):
     vmware-vdiskmanager -r github-enterprise-11.10.270-i386-disk1.vmdk -t 2 github-enterprise-11.10.270-i386-disk1-preallocated.vmdk
  5. Convert the preallocated VMWare disk image to qcow2 format with qemu-img:
     qemu-img convert -O qcow2 github-enterprise-11.10.270-i386-disk1-preallocated-flat.vmdk github-enterprise-11.10.270-i386-disk1-preallocated-flat.qcow2
  6. You can now create a KVM virtual machine using the generated qcow2 disk image as a boot disk!

It's worth noting that GitHub do not support running GitHub Enterprise under the KVM hypervisor.

Expanding Disk Image (added 2012/07/20)

The disk image can also be converted to RAW format with qemu-img, and then written directly to an LVM volume (using dd), then the virtual machine can boot off that. If more space is required in the GitHub machine then you can:

  1. Copy the 10GB RAW image into a Volume Group that is bigger - say 100GB
  2. Boot up GitHub & log in with SSH
  3. Run ghe-grow-root -d /dev/vda6

This should make GitHub use all the available disk space.

Posted on 06 Jul 2012
With thanks to