Harddrive

Preface

To be honest I’m not feeling too good writing this blog… And believe me,  I have frequent discussions around “How can I add a second VHD to my VM?”

Multiple drives on a endpoint dont make sense to me, I want one large spindle (except if they’re in a RAID to provide speed or redundancy). I also dont like drive letters, I had enough drive letters for the rest of my life and I’m pleased there’s a limitation in our alphabet :-). Where do I store my ISO’s? in the P or on the Q drive – Please NO! (Yes, I know you can mount drives in Windows on a subdirector as Unix does for centuries) The worst thing I can think of is having an extra drive to share data between two virtual machines…

If you really need to, use your network or a USB harddrive.

And btw wasn’t there a thing called cloud…. Sure apply for a ShareFile account. But that’s beside the scope of this blog. This blog just explains how you can create and attache a 2nd VHD file to your existing XenClient based virtual machine. Be warned, this is not a supported configuration and  may never be used in a managed environment (Using Synchronizer). So, only try this if you got a backup and if your VM’s are unmanaged and local.

And as always: DONT BLAME ME!

Why not changing the config file?

Short answer: Because it dones’t work and breaks your system.
In the early stage of XenClient, you could just add a drive in the config file.

With the newer versions if you would change / add another section like “2” with your 2nd VHD details, XenClient may not boot anymore.

Step by Step

The current setup is as follow in my test system: VM1 is a 64 Bit Win7 and VM2 is a 32 bit WinXP. We’re going to use the xec cli to gather some information. First lets find out the UUIDs, we need these number later on for the xec-vm commands.

 

<a rel="attachment wp-att-174182260" href="/blogs/2012/02/29/xenclient-best-practices-series-%e2%80%93-assign-a-2nd-vhd-to-your-vm/xec-vm/"><img class="alignnone size-full wp-image-174182260" src="/blogs/wp-content/uploads/2012/02/xec-vm.png" alt="" width="602" height="112" /></a>

 

I first want to verify how many drives are configured on my Win7 Virtual Machine. This can be done by browsing the config file e.g. cat /config/vms/e2e24c8a-9333-4ec9-bd01-fac6f6893c02.db. Or we query the config on the dbus using the command line.<!–
As you see we got two disks; disk 0 and disk 1, where disk 0 is the CDRom and disk 1 is our VHD file we run the VM from.


In the next step I’ll create a VHD file.

Now I’ll add a new disk object to the Virtual Machine.


Did you notice, the list-disks command now report 3 drives.
Since we create an empty VHD file and added a disk to Virtual Machine configuration, we finally just need to attache the VHD to that disk descriptor.



Quote: Just realized that the picture is truncated on some browsers.
The Syntax is: xec -o /vm/vm_uuid/disk/2 attach-vhd /storage/disk/disk.vhd

 

Now, lets verify by booting up our Windows Virtual Machine.

So, how about sharing a drive between two virtual machines?

As I mentioned in the beginning people wanted to attach a 2nd drive to TWO VM’s in order  to exchange data.
To do this, you would just attach the e same VHD to the second VM (in my test system the WinXP VM).

HOWEVER, because both VM’s would potentially access and modify the same data, XenClient luckily dont let you do that.
If you start the 2nd VM an error will pop up and stop the boot process.

Again, it’s possible to have both attached, but only one may run at the same time.

(Setting the disk mode to readonly wont change that)

At least, this assures that same data is being changed resulting in data inconsistency 🙂

Enjoy working with XenClient! Cheers, walter.hofstetter[at]eu.citrix.com

Connect with the XenClient team online!