Friday, June 27, 2008

Upgrading Hyper-v to the final release wasn't as smooth as I thought it would be.

I was a little surprise that the upgrade wasn't as seamless. I followed the instruction from http://support.microsoft.com/kb/950050, but still had issues. After the upgrade, I couldn't start any of my VMs. I had to delete and create new ones. Then my network adapter was removed, so I had to create a new network adapter. My VM finally came up, but the mouse didn't work, so I had to install the new integration services. I just finished that. My system is rebooting, so I'll see what other problems I'll run into.

Thursday, June 5, 2008

How to mount a vhd file to the host

Why would you want to do that? Well there are many reasons, but most important is to get to the data.

Here is how I do it.

I use Ben's script
http://blogs.msdn.com/virtual_pc_guy/archive/2008/02/01/mounting-a-virtual-hard-disk-with-hyper-v.aspx

I just edit the script and put in the drive, path and filename of the vhd that I want to mount. After editing and saving I double-click on my vbs file and it is mounted. I have one called mount vhd.vbs and one called unmount vhd.vbs. The only difference is the two scripts is the last line VHDService.Mount(VHD) to mount andVHDService.unMount(VHD) to unmount.

I then open up Disk Management under computer management. You should see a volume that is offline. Right click on choice "online". The disk will come on line and be assigned a drive letter. That's it. Now just go into explore and take a look at the disk.

Update - How to backup Virtual Server in Windows 2008

I've made some changes to how I backup my Virtual servers. The other way I wasn't able to copy over the previous backup so I wasn't get the lastest backup. Here is what I am doing now.

I have 3 files that I use.
1. script.dsh
Here's the content of it.
#DiskShadow script file
set context persistent nowriters
set metadata c:\diskshadowdata\example.cab
set verbose on
begin backup
#add volume c: alias SystemVolumeShadow
add volume d: alias DataVolumeShadow

create

#expose %SystemVolumeShadow% r:
expose %DataVolumeShadow% p:
exec c:\diskshadowdata\backupscript.cmd
end backup
#End of script

As mentioned in the previous post I explained where I got this and what changes I made. The only difference from the previous post is that I'm using the P drive instead of the Q drive.

File #2 - backupscript.cmd
I:
rmdir /S /Q backup
mkdir backup
cd \backup
P:
xcopy /E /Y "virtual servers" I:\backup\
mountvol P:\ /D

After the first file creates the shadow copy of my D drive and mounts it on the P drive, I use this file to remove the previous backup (because I don't have room and for some reason it was not overwriting the previous backup) and then copy the virtual servers.
There are definitely better ways to do this, but here is what this script does.
I change to the I drive which is the drive my USB hard drive is mount to. I then remove the directory that contains the previous nights backup. I don't have room on the USB drive to house more than one backup. I then create the same directory to put the backup virtual files in. Then I switch to the P drive which has the latest mount shadow copies in and start copying just the directory that contains the virtual server files. That directory is called "virtual servers". After the copy is done then I unmount the P drive. If you don't then you will not be able to successfully run the first script the next time you run it.

File #3 - Backup.bat
C:
cd \diskshadowdata
diskshadow /s script.dsh

This file is the one that I have the task scheduler setup to use for the nightly backup. Because I don't have my pathing setup I just cd to the diskshadow directory which has all three files in and run the "diskshadow /s script.dsh" command.

I hope I didn't confuse you.

Ask if you have any questions and I will try to explain better.