Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Created March 11, 2013 17:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save ei-grad/5135864 to your computer and use it in GitHub Desktop.
Save ei-grad/5135864 to your computer and use it in GitHub Desktop.
Script to convert Github Enterprise OVA image to tar.gz for LXC.
#!/bin/bash
[ "`whoami`" != "root" ] && echo "Should be run by root!" && exit 1
[ -e *.vmdk ] || ( echo Extracting VMDK image from *.ova ... ; tar xf *.ova )
[ -e github.img ] || ( echo Converting *.vmdk to raw image ... ; qemu-img convert *.vmdk github.img )
echo Preparing mounts ...
losetup -f github.img -P
vgchange -ay enterprise-11
mkdir -p root/rootfs
cd root
mount /dev/enterprise-11/root rootfs
cd rootfs
mount /dev/loop0p1 boot
# XXX: configure network, rc hacks, etc.
#...
cd ../ # change dir to one which contain the 'rootfs' directory
echo "Creating github.tgz ..."
tar czf ../github.tgz .
echo "Umounting ..."
cd ../
umount root/rootfs/boot && umount root/rootfs && rm -r root/rootfs root
vgchange -an enterprise-11
losetup -d /dev/loop0
echo Done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment