Skip to content

Instantly share code, notes, and snippets.

@nrh
Forked from ei-grad/ghe-lxc-image
Created July 11, 2013 09:58
Show Gist options
  • Save nrh/5974156 to your computer and use it in GitHub Desktop.
Save nrh/5974156 to your computer and use it in GitHub Desktop.
#!/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