From 61cf8114ea71d62fe953cd4a9d97e8a8ca8fbf30 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Thu, 22 May 2014 18:40:13 +0200 Subject: [PATCH] xen-image-maker: add support vor XenCenter xva image output. --- config/xen-image/README | 4 ++++ config/xen-image/ipfire.cfg | 8 +++---- config/xen-image/xen-image-maker.sh | 37 ++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/config/xen-image/README b/config/xen-image/README index 3813572e00..a59b6fabb3 100644 --- a/config/xen-image/README +++ b/config/xen-image/README @@ -18,3 +18,7 @@ other usefull commands from the Dom0: - shutdown the fire: "xm shutdown ipfire-xen" - reset the fire: "xm destroy ipfire-xen" - look what is going on: "xm top" or "xm list" + +This script can also build a Citrix XenCenter xva image. +- run "XEN_IMAGE_TYPE=xva sh xen-image-maker.sh" to build an xva image. +- import the vm with "xe vm-import file=ipfire.xfa" diff --git a/config/xen-image/ipfire.cfg b/config/xen-image/ipfire.cfg index 594c82a5f9..38bfdff5e5 100644 --- a/config/xen-image/ipfire.cfg +++ b/config/xen-image/ipfire.cfg @@ -17,8 +17,8 @@ vif = [ disk = [ - 'file:/mnt/test/ipfire-boot.img,xvda1,w', - 'file:/mnt/test/ipfire-swap.img,xvda2,w', - 'file:/mnt/test/ipfire-root.img,xvda3,w', - 'file:/mnt/test/ipfire-var.img,xvda4,w' + 'file:./ipfire-boot.img,xvda1,w', + 'file:./ipfire-swap.img,xvda2,w', + 'file:./ipfire-root.img,xvda3,w', + 'file:./ipfire-var.img,xvda4,w' ] #### Change path diff --git a/config/xen-image/xen-image-maker.sh b/config/xen-image/xen-image-maker.sh index 762a86ec89..06f9f2e564 100644 --- a/config/xen-image/xen-image-maker.sh +++ b/config/xen-image/xen-image-maker.sh @@ -51,6 +51,25 @@ IMGvar=./$SNAME-var.img KERNEL=linux-$KERN_TYPE-$KVER-$KERN_PACK.ipfire +if [ "$XEN_IMG_TYPE" == "xva" ]; then + # download xva.py if it not exist. + if [ ! -e xva.py ]; then + wget http://source.ipfire.org/source-2.x/xva.py + fi + # XenCenter use other devicenames and + # xvdd seems to be reserved (converter bug?). + P1=xvda + P2=xvdb + P3=xvdc + P4=xvde +else + # old style xen image partition names + P1=xvda1 + P2=xvda2 + P3=xvda3 + P4=xvda4 +fi + rm -rf $TMPDIR && mkdir -p $MNThdd && mkdir -p $ISODIR echo -------------------------------------------------------- echo - Download $SOURCEISO ... @@ -97,7 +116,8 @@ mount -o loop $IMGboot $MNThdd/boot mount -o loop $IMGvar $MNThdd/var # Install IPFire without kernel modules -tar -C $MNThdd/ -xvf $ISODIR/$SNAME-$VERSION.tlz --lzma \ +xz -d < $ISODIR/$SNAME-$VERSION.tlz > $TMPDIR/$SNAME-$VERSION.tar +tar -C $MNThdd/ -xvf $TMPDIR/$SNAME-$VERSION.tar \ --exclude=lib/modules* --exclude=boot* --numeric-owner #Install Kernel @@ -110,7 +130,7 @@ mkdir $MNThdd/boot/grub echo "timeout 10" > $MNThdd/boot/grub/grub.conf echo "default 0" >> $MNThdd/boot/grub/grub.conf echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf -echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/xvda3 rootdelay=10 panic=10 console=$CONSOLE ro" \ +echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE ro" \ >> $MNThdd/boot/grub/grub.conf echo " initrd /ipfirerd-$KVER-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf echo "# savedefault 0" >> $MNThdd/boot/grub/grub.conf @@ -139,10 +159,10 @@ mount --bind /proc $MNThdd/proc mount --bind /dev $MNThdd/dev mount --bind /sys $MNThdd/sys chroot $MNThdd /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" -sed -i -e "s|DEVICE1|/dev/xvda1|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE2|/dev/xvda2|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE3|/dev/xvda3|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE4|/dev/xvda4|g" $MNThdd/etc/fstab +sed -i -e "s|DEVICE1|/dev/$P1|g" $MNThdd/etc/fstab +sed -i -e "s|DEVICE2|/dev/$P2|g" $MNThdd/etc/fstab +sed -i -e "s|DEVICE3|/dev/$P3|g" $MNThdd/etc/fstab +sed -i -e "s|DEVICE4|/dev/$P4|g" $MNThdd/etc/fstab sed -i -e "s|FSTYPE|$FSTYPE|g" $MNThdd/etc/fstab @@ -181,6 +201,11 @@ umount $MNThdd umount $ISODIR rm -rf ./ipfire-tmp + +if [ "$XEN_IMG_TYPE" == "xva" ]; then + python xva.py --sparse -c $SNAME.cfg -f $SNAME.xva + rm -f $SNAME*.img +fi echo -------------------------------------------------------- echo - Done. echo -------------------------------------------------------- -- 2.39.2