From: Eric Price Date: Sun, 22 Jun 2008 05:28:55 +0000 (-0400) Subject: xen-create-image in dom0 X-Git-Tag: sipb-xen-guest-installer/1.4~3 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-autoinstaller.git/commitdiff_plain/33e173aa268c6f4f5d3d49d0ca75aeafae15eb8f xen-create-image in dom0 svn path=/trunk/packages/sipb-xen-guest-installer/; revision=635 --- diff --git a/files/usr/sbin/sipb-xen-install b/files/usr/sbin/sipb-xen-install new file mode 100644 index 0000000..f08b3fe --- /dev/null +++ b/files/usr/sbin/sipb-xen-install @@ -0,0 +1,41 @@ +#!/bin/sh + +export PATH #WTF? + +HOSTNAME="$2" +DIST="$3" +MIRROR="$4" +IMAGESIZE="$5" +IP="$6" + +ARCH=amd64 + +#LVSIZE=`lvs --noheadings --units M --nosuffix -o Size /dev/xenvg/d_foobar_hda | sed 's/\..*//'` + +if [ -z "$IP" ]; then + IP=`host $HOSTNAME.xvm.mit.edu | sed 's/.* //' | head -n 1` +fi + +VOLUME=/dev/mapper/xenvg-d_${HOSTNAME}_hda + +# If this script is interrupted, it may not clean up after itself. +# In particular, it may leave ${VOLUME}1 mounted somewhere in tmp. +# Unmount it, then kpartx -d $VOLUME to clean up. + +### +### Create the device for SIPB-Xen purposes +### +echo ,${IMAGESIZE}$',L,*\n,,S\n;\n;' | sfdisk -uM -H 255 -S 63 $VOLUME +kpartx -a $VOLUME + +# We use static IP addresses since dhcp doesn't work in paravm because +# of a UDP checksum bug. + +xen-create-image --image-dev ${VOLUME}1 --swap-dev ${VOLUME}2 --fs ext3 --ide --arch $ARCH --dist $DIST --hostname $HOSTNAME --mirror $MIRROR --ip=$IP --netmask=255.255.0.0 --gateway=18.181.0.1 --template=/dev/null --cache + +# xen-create-image always creates a config file. The +# --template=/dev/null argument makes it empty, but it still should be +# removed. +rm -f /etc/xen/$HOSTNAME.cfg + +kpartx -d $VOLUME