preload
Feb 05

Here is script howto mount guest VM to control domain VM. If you want to make file backups from snapshot or like in my case, configure new vm ( ip address etc ) one can easily modify it.

#!/bin/bash
# contact@mceith.com 2011

if [ ! -n "$1" -o ! -n "$2" -o ! -n "$3" ]; then
  echo "Usage: $0 <target vm uuid> <control domain uuid> mount|umount"
  exit 1
fi

case "$3" in
mount)
if [ -f /tmp/tmpvbd ]; then
  echo "VBD allready exists!"
  exit 1
fi

# Get uuid of vm you want to configure
VMUUID=`xe vbd-list vm-uuid=$1 params=vdi-uuid empty=false --minimal`

# Create VBD link to VM VDI on dom0
NEWVM=`xe vbd-create vm-uuid=$2 vdi-uuid=$VMUUID device=1`

# Plug it to dom0
xe vbd-plug uuid=$NEWVM

VM_VDEV=`xe vbd-list uuid=$NEWVM params=device --minimal`1

# Lag
sleep 1

# Mount it
mount /dev/$VM_VDEV /mnt/newvm

echo $NEWVM &gt; /tmp/tmpvbd
# Do what ever you like
# ....
;;

umount)

if [ ! -f /tmp/tmpvbd ]; then
  echo "No VBDs mounted?"
  exit 1
fi

umount /mnt/newvm

NEWVM=`cat /tmp/tmpvbd`

# Unplug
xe vbd-unplug uuid=$NEWVM

xe vbd-destroy uuid=$NEWVM

rm -f /tmp/tmpvbd
;;
esac

exit $?

2 Responses to “Mount guest VM VBD to xenhost or “dom0” on XenServer”

  1. Felix Says:

    [root@xenserver ~]# sh mountvm.sh cf35d15c-f6b0-f64a-7716-a9088c4023cf 3b51fc2a-dc2f-4cb9-947e-d09b147858e6 mount
    mount: you must specify the filesystem type

  2. contact Says:

    I Assume you have hypervisor supported filesystem on guest vm?

Leave a Reply

You must be logged in to post a comment.