How to Access Local and USB Hard Drives In Your Hyper-V Virtual Machine

There are dozens of scenarios where you would want to access a physical hard drive from inside your Hyper-V virtual machine ranging from accessing and importing data, dumping data from the virtual machine into the external drive, and importing or exporting disc images.

Whatever reason you have for wanting to access an existing local hard drive in your Hyper-V machine it’s, unfortunately, a bit complicated giving the drives access to the virtual machine. Unlike other virtualization solutions (VMware and VirtualBox) there is no easy way to just share resources between the host machine and the Hyper-V virtual machine.

To use a drive within a Hyper-V machine you need to take the drive, while physically attached and mounted to the host machine, offline and then reroute the offline-to-the-host disk into the virtual machine. Let’s take a look at how to do that now.

A quick note before we proceed: this trick only works with hard drives (magnetic hard drives, solid-state hard drives, and removable USB hard drives) but does not work, alas, with removable media like flash drives.

Drive Preparation and Mounting In Hyper-V

There are two primary steps to the procedure. First we need to manage the disk from within Windows on the host machine to bring it offline (but still powered and attached to the host computer) and then we need to tell Hyper-V to take control of the now-offline disk.

Preparing the Drive

The first step is to bring the disk offline. To do so open up the Disk Management application by searching for the application name or typing “diskmgmt.msc” in the search box and running the app. Within Disk Management look for the drive you wish to pass through to the virtual machine.

Although it’s probably safe to assume, since you’re playing around with Hyper-V and concerned with matters like physical-disk-pass-through, that you’re already familiar with Disk Management it would be remiss of us not to issue a standard warning: Disk Management is a powerful tool and you can do terrible things to your system by mucking about within the management system. Double check each step and make sure you’re working with the right disk(s).

clip_image001

In our case we want to pass Disk 10, a USB backup HDD, through to the virtual machine so we can dump some backup files from our virtual machine onto the disk. To prepare the disk we must first locate it in the list of drives within Disk Management, right click on it, and select “Offline” from the right-click context menu as seen in the screenshot above.

clip_image002

Confirm the disk is offline. If you wish to bring the disk back online, after you’re done using it within the virtual machine, simply return to this menu, right click on the disk, and select “Online” to bring the disk back online for the host operating system.

Adding the Drive to the Virtual Machine

Once the disk is offline to the host operating system it’s time to add the disk to the virtual machine within Hyper-V. Launch Hyper-V and, from your Virtual Machines list, select the machine you wish to pass the hard disk through to.

clip_image003

Right click on the machine and select “Settings…”

clip_image004

From within the Settings menu for that specific virtual machine, select “SCSI Controller” from the left hand navigation pane. Select “Hard Drive” and click the “Add” button.

Note: We’ve presumed you wish to pass the hard drive through to the virtualized operating system which means you already have a SCSI controller and virtual disk for the OS. If you do not yet have a SCSI controller you will need to first select “Add Hardware” at the top of the navigation pane and add a “SCSI Controller” to your virtual machine.

clip_image005

Select “Physical hard disk” and then, from the drop down menu, select the disk you brought offline in the previous section of the tutorial. Don’t worry there’s no chance you’ll accidentally select a disk from the host machine that you didn’t intend to use. The only disks you can select in the physical hard disk menu are disks that are powered and attached to the host machine but in an offline state. If you didn’t put it offline it isn’t even an option.

Confirm the disk selected is the disk you want. Press the “Apply” button and then “OK”. Boot up your virtual machine.

Accessing Your Pass-through Hard Disk

In the vast majority of cases the disk should be automatically detected by the host operating system as if it was simply a physical disk attached to the real machine the virtual machine is emulating.

If the disk isn’t immediately accessible to the virtual machine operating system you may need to open up, in the case of Windows, Disk Management and bring the disk online. When using other operating systems you’ll need to perform an equivalent action to access the disk through the virtual OS.

A very important word of caution here. The OS in the virtual machine has no idea that this disk actually belongs to your host machine and it will act upon the disk however you tell it to act upon the disk. If the disk does not automatically mount in your virtual machine OS you need to use a mounting procedure (refer to documentation for the particular OS in question) to mount the disk in the non-destructive way so that it can be returned to the host operating system later on.

When you no longer need the disk in the virtual machine simply boot down the virtual machine. Do not attempt to make changes to the drive state via the host machine until you’ve turned off the virtual machine the drive is connected to.

You can outright remove the hard drive from the virtual SCSI controller in your virtual machine if you aren’t going to use it again or you can leave the entry. Any time the physical drive is disconnected from the host machine or you’ve made it online for the host operating system the drive will simply appear as unavailable to the virtual machine.

Virtualization 101 – Getting started

It’s no secret I like Virtualization technologies a lot. I have written several other articles on some of my tips and tricks mostly involving creating Virtual Machines of OS X. You can read some of those here, here, here or simply just search my blog.

For those who support multiple operating systems or simply have a desire to learn about them, Virtualization is a fantastic way to just that. Virtualization, in computing, is the creation of a virtual (rather than actual) version of something, such as a hardware platform, operating system, a storage device or network resources. Here is a good description tailored to the IT professional or CEO http://youtu.be/MnNX13yBzAU but you can get a good grasp of the concepts.

At my organization I have installed and manage a VMware ESXi clustered installation on a SAN (Storage Area Network) with hardware and software that starts in the six figures. This is obviously way out of reach of the home user or enthusiast. But Virtualization can be inexpensive and or downright free for the taking. Microsoft, VMware and Virtual Box all have freeware solutions!

For this article I am going to concentrate on the hardware required and the simplest to use application for the novice or even intermediate user – VirtualBox a freeware application by Oracle. So on to the hardware:

Virtualization product or solution such as VMWare Workstation (and the ‘industrial ESXi), VirtualBox and Windows Virtual PC often require Hardware Assisted Virtualization (HAV) CPU feature in order to function properly as it allows a virtual machine hypervisor to run an unmodified operating system without incurring significant emulation performance penalties. The largest chip makers, Intel and AMD implement hardware assisted virtualization in their processors as Intel VT (VT-x) and AMD-V respectively. However, not all modern CPU has hardware-assisted virtualization capability built-in though; you will want to make sure. The VT capability in the processor on the computer is built onto the tiny piece of chip, and cannot be added or removed using any manual process. And even if the CPU features VT, it must be enabled in BIOS.

Most newer CPUs include VT operation by default. However, some older or even current processors available for purchase for DIY or operating on OEM computers may not support VT. When there is no VT support, Virtual Machine Technologies based on VT may fail to install or cannot be powered up and started.

If you are going to create or use virtual machines you should verify, check, determine or get to know whether his or her PC computer supports hardware-assisted virtualization. There are a few software utilities you can use to quickly determine whether there is hardware virtualization system on the system CPU. One is name named SecurAble which is able to display hardware virtualization support status as Yes, No, Locked On and Locked Off. The other is Microsoft’s HAV Detection tool.

SecurAble Detects CPU Processor Security Features (Bit Length, DEP and Virtualization)

Most users who buy computer are just paying notice to the speed (how fast) and size of RAM memory (how big) of the PC. In fact, most modern CPU microprocessors have great lots of features and capabilities other than constantly higher clock rate. With the evolving of software development, some of these features are now required. With SecurAble, user can easily check and determine if the system is x86 or x64 architecture, support hardware DEP and/or hardware virtualization.
SecurAble probes the system’s processor, determine the presence, absence and operational status and displays the status of the three most significant security-related processor features:

  • 64-bit instruction extensions
  • Hardware support for detecting and preventing the execution of code in program data areas
  • Hardware support for system resource “virtualization”

clip_image001

All these features are deemed to be security-important by developer of SecurAble, GRC. 64-bit capable CPUs have the ability to run the 64-bit versions of Microsoft’s substantially more secure Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008 and Windows 7 operating systems, which has the operating system kernel locked down. Hardware-enforced DEP can stop exploitation of buffer overflow attacks, while virtualization technology (VT) can be used to create fully contained environments that can be used to insulate the real hosting operating system from any actions taken by software running within the “virtual” environment.

SecurAble is free to use, and no installation require.

I use SecurAble the most for checking for Hardware-Assisted Virtualization.

Download SecurAble.

http://www.grc.com/securable.htm

Microsoft has also released a application tool that able to detect status of Hardware-Assisted Virtualization (HAV) support on the computer system’s CPU microprocessor. Aptly named as Hardware-Assisted Virtualization Detection Tool or simply as HAV Detection Tool, the utility can detect and check if the computer meets the processor requirements to run Windows Virtual PC, i.e. hardware-assisted virtualization.

clip_image002

Download HAV Detection Tool: havdetectiontool.exe

Using HAV Detection Tool is easy, just run the executable, and the results of whether hardware virtualization support is existed on the system or not (together with ability to install Windows Virtual PC) will be displayed on result dialog. It’s standalone program, thus no installation or un-installation required

So after you’ve determined you can run virtual machines with HAV you’ll want to try some VM’s out.

As I mentioned for home use I’ve found Virtual Box to be the easiest to use and configure. You can get it here and get the ‘Extension Pack’ here. Install the application first (get the right one for you platform – Windows, Mac, Linux) Then install the Extension pack; it will install automatically IF you’ve already installed the base application first.

Once installed you are ready to start working with just about any operating system you want to within your current system!

Here is a fantastic walk through of how to simply create a VM from a downloaded Linux installation disk (ISO)

This method can be used for installing Windows VMs too! If you have a Windows installation CD/DVD and you wish to install it as a VM you can. [For OS X you will have to follow some of the very specific tutorials I have put together – Apple does not like you to install OS X on non Apple hardware]

VirtualBox.org has a very detailed description and walkthroughs too, you can find that here.

The easiest way to get started with VirtualBox is to import an already made image/appliance. Virtualbox.org has many already made Linux installations you can get them here. And with a little diligent searching you can find LOADS of them.

I hope this helps some to get started and have a better understanding of these technologies. More knowledge and experience can only be good.

Here is an image of some of the VM’s on one of my home machines in Virtual box.

clip_image004

As I noted if you are interested in OS X VMs you can go here and read the second half on using Virtual Box. Here are two walkthroughs from other tech sites worth checking out too.

http://thetechjournal.com/electronics/computer/steps-to-install-mac-os-x-snow-leopard-in-virtualbox-on-windows-7.xhtml

and here: http://www.sysprobs.com/mac-os-guest-virtualbox-326-snow-leopard-1064-windows-7-32-bit

OS X Virtual Machines Two Methods

I recently had the need to test some ‘fixes’ for a co-workers iMac. Since I don’t like to make system changes on ‘live’ machines I went to my Virtual Machines (VM) and was able to easily test what I needed. I mentioned that to a colleague and they asked me to explain how I was able to create VMs of OS X.  So I thought I would put together some of my older tutorials I’ve created and update and add loads of information for those that want it.

I have three Virtual Machine solutions I use. One is based on the industry leader – VM Ware, another the open source (and much improving) Virtual box and finally Microsoft’s Virtual Server (now HyperVisor). I will not discuss Microsoft’s VM solution here because I have not used it to create OS X VMs.

There is lots of information on how do create an OS X VM on both of these VM platforms but I hope I can give some of you some direction. There are now some greatly improved and easier to use ‘boot loaders’ and patches (kexts) for getting OS X to run in a VM or as a Hackintosh as mentioned in some of my previous posts. For some information on that check out these sites.

Hackintosh.com

OSx86 Project

myHack

Chameleon OSx86

Here is my workhorse server System configuration and specs:
Windows 2003 Server SP2
QuadCore Intel Core 2 Quad Q6600
Abit IP35 Pro
8GB RAM
1.5TB SATA HDD (7200RPM)
GeForce 9600 GT (512 MB)
2 Realtek RTL8169/8110 Gigabit Ethernet NIC
Using VMwave Server Console:
Version 1.0.0 build 28343

First up the solution I have been using the longest – VM Ware. I have included as many screen captures where necessary to show some of the configuration changes I made. The VirtualBox solution is actually really easy now so I will explain that one last.

To get it up and running I followed the steps here:

I followed that fairly closely with some exceptions which are in the screen captures below and I will note later*. These guys are great and should be recognized.

Some other sites that were of great help:

http://wiki.osx86project.org/wiki/index.php/Main_Page

I run an older version of VMware Server and so did not use the freely available VMware Player or the new VMware Server version2.x. Since my version is older, I suspect the newer free version would have worked as well. [After writing this and doing a lot of reading on the new – version 2.x of VMware Server- I now don’t think I would recommend it. Stick with the new free VMplayer/workstation version or VMWare server 1.5x or lower.]

I may try the new VMWare server versions on my other server eventually.  But if it’s not broke don’t futz with it.

VMware products are available here:

http://www.vmware.com/

http://www.vmware.com/download/player/

I own Virtual CD v9, Alcohol 120, and a few other CD emulators but I am sure you can find free ones. Here are a few:

DAEMON Tools lite

MS Virtual CD

MagicDisc

I have a few copies of Mac OS’s around from 9 on up to 10.5 (Legal for my Mac’s – some alive and some put to rest), But I decided to try a version that had already been prepped/patched for running on x86 – it is named the “Mac OS X 10.4.8 [JaS AMD-Intel-SSE2-SSE3 with PPF1 & PPF2].iso distro”. I some others I’m going to try too – “Kalyway_10.5.2_DVD_Intel_Amd.iso” and “JaS.OSx86.10.5.4.Client.Server.Intel.SSE2.SSE3.iso”

If you want those you will have to ‘hunt’ for them (there is a torrent of information available to you hunters our there…). There are continuing updates to some of these builds to include the latest loaders built in.

Also did an ‘upgrade’ with a new Snow Leopard disk I have.

And just so you know;

“Even though Apple suggests Mac users without Leopard buy the $169 Mac box set to get Snow Leopard, anyone can purchase the $29 Snow Leopard disc and install Snow Leopard in its entirety without having already installed Leopard. This means the $29 Snow Leopard DVD isn’t an "upgrade" at all; it’s the full-on Mac OS X operating system for 30 bucks.”

I bought a few upgrade disks here, since I will be upgrading my physical a well as virtual/Hackintosh ones.

Below is a capture of my ‘vmx’ file with the changes I made:

clip_image002

OS X ON VM Ware: Follow these instructions in the link I posted above. Just take note where I changed some options.

Here are some captures of one of my OSX ‘Virtual Machines’ running on my pc.

clip_image002[4]

clip_image004

clip_image006

clip_image008

clip_image010

clip_image012

I have reduced the plethora of VMWare VMs I was running to two for now (OSX and an Ubuntu desktop/client).

But I did have a couple of Vista’s instances, an Ubuntu Desktop, an Ubuntu Server, 2 WinXP, and Windows Server 2008 with Exchange 2007 and SQL2005(time limited) all running and talking to each other!

I use some of my images of existing (real world/live business servers – PDC, Exchange, SQL and other application servers) virtualized to experiment with upgrade/optimization strategies.

I just convert my recent images – (Acronis and Ghost type)together and converted to Virtual Machines [http://www.vmware.com/products/converter/get.html]. Big time and space issue now.

OS X on Virtual Box

First you will need the newest Virtual Box application, get it here. You will also need a ‘patched’ ISO version of OS X Snow Leopard such as one of the latest as mentioned above. Or  The group Hazard has put out a good patched Snow Leopard installer that should do fine (just search for it on Google). Of course, if you feel bad about downloading the ISO of Snow Leopard, you could always go buy a copy to feel a bit better, karmically.

Install VirtualBox.

Then click on New at the top left. At the Create New Virtual Machine window, click Next.

clip_image001

At this window type OSX as the name and it will automatically change the system and version. The next window will let you choose your RAM amount:

clip_image001[4]

If you can spare it, crank it up as far as you can go, but 1024MB should be sufficient.

clip_image001[6]

This is where you’ll make your hard disk. 30GB should be enough so what it comes down to is dynamic or static. Dynamic will expand on use and Static will be a fixed 30GB no matter how much data is actually in it. Dynamic is better for not taking up your hard drive but static will give you better performance. I normally use dynamic. Click next unless you want to change it from dynamic or if you want to increase the disk size or file location.

clip_image001[8]

It will show a summary of your settings. Click Finish, then click Settings at the top.  Make sure you choose only one ‘core’ for processor too.

At this window click on System in the left pane and uncheck Enable EFI

image

image

Now click on the Storage button on the left. From there click on Empty under the OSX.vdi, then click the folder with the green arrow on the right (next to "CD/DVD Device").

clip_image001[12]

clip_image001[14]

At this window click the Add button at the top. Then find and add the OSX86 ISO (Hazard or other) you downloaded earlier. Then highlight it and click Select at the bottom.

image

image

Then click OK, and hit the Start button on the left side of the main VirtualBox window.

image

As it starts up, click inside the window and hit F8. Then at the boot: prompt type –v so you can see what exactly went wrong if something does go wrong. All the services will run and eventually you should come to the language screen. Choose your language then click next.

If you are unable to move your mouse around then hit Right-Ctrl + I.  To ‘free your mouse to move outside of the VM window hit the right ‘Alt’ key.

Click Continue and Agree. Next, start up Disk Utility by going to Utilities in the menu bar.

clip_image001[16]

At this screen highlight 20GB VBOX HARDDISK. Then click the Erase tab, name it what you want in the name box and click the Erase button on the bottom right of the window. It shouldn’t take long. Then click Disk Utility in your menu bar and quit it.

Now you’re back at the installer. Highlight the drive that is now showing up and click Continue.

clip_image001[18]

The next window is important!

Don’t click ANYTHING YET!

Click the Customize button on the bottom left. Expand the options (arrows) and check the necessary boxes for your processor.

AMD Users check:
Any Updates included at the top.
Drop down Kernels and choose Legacy kernel.
AMD option below System support.

Intel Users check:
Any Updates included at the top.
Drop down bootloaders and check the newest Chameleon.
Drop down Kernels and choose Legacy kernel.

Then click Done and hit the Install button. To speed up the process you can click Skip when the disc check pops up.

clip_image001[20]

As soon as it says "installation finished" and starts counting down to restart, press the right Ctrl key. Click on Devices at the top of the VirtualBox window, hit CD/DVD Devices and click Unmount CD/DVD Device.  Remember you will probably have  to hit the right ‘Alt’ key to ‘free’ your mouse! Do that before you get to the end of the install.

Then go to Machine > Reset and click Reset at the prompt. Next you’ll see the Chameleon loader , click inside the VM and hit and hit enter and then OS X will begin to boot.

clip_image001[22]

After it boots you will see the setup screens for OS X! You’re good to go.

On a side note if you use NAT for networking you can control your Virtual Machines from any computer on your network or even remotely using a multitude of remote access solutions.