>

How to: attach a usb disk to a Hyper-V virtual machine

As the most of you know, Hyper-V does not support usb redirection. But with some relative easy steps we can redirect our usb disk to a Hyper-V virtual machine.

First on your Hyper-V Server host open Server Manager and select Disk Management

Then select your usb disk and right mouse click and choose Offline.

When done we close Server Management and open Hyper-V Manager. Select the settings of the virtual machine you would like to attach the usb drive to.

Select IDE Controller or SCSI Controller. Before you choose let me explain why I would choose the SCSI controller instead of the IDE controller for an usb redirected drive. A Hyper-V virtual machine can only boot from an IDE hard drive, you can only add a dvd drive on an IDE controller, you can only add 4 IDE devices. Another thing I would prefer to add an usb disk to the SCSI controller is I can add or remove disks to the virtual machine when it is running, to add an IDE controller disk I need to stop the virtual machine then add the disk and then start the virtual machine.

Now to add your usb disk to you virtual machine we choose Add

Now we choose for Physical hard disk: and choose the disk we would to add. If you have more disks available you can choose from a simple pull down list. You will only see here the disks that are set to offline so that was the first step we had to do. If you would like to add an internal hard disk you have to put it offline before you can add it.

Note: before you set another disk offline be sure there are no operating, system or application files on it because otherwise these or your whole server will crash.

When finished choose OK on the bottom of the screen and the disk is added to your virtual machine.

When we are going to look at your virtual machine and open Disk Management.

You will see the disk directly attached and you can use it within your virtual machine

If you would remove the drive from the virtual machine, go back to your Hyper-V Manager virtual machine settings on your host server.

Select the drive and choose remove and choose Apply or OK at the bottom of the screen.

After you have removed the disk from the virtual machine go back to Disk Management

Right click the drive and choose Online. Now the drive is available on your host server.

You can use this if you need to copy some files directly from the usb disk to the virtual machine or vice versa. Another thing you could use this is for is Windows / SBS backup this needs a local attached disk, although I don’t think this is a supported configuration! You can even if you have chosen for the SCSI controller change the backup disk when your virtual machine is running.

Posted in Blog, Howto, Hyper-V by ronnypot at March 25th, 2011.
Tags: , ,

49 Responses to “How to: attach a usb disk to a Hyper-V virtual machine”

  1. Ali says:

    This is great beause recently I read in another blog “if the drive ist offline and not an USB drive” as the requirements to use a physical disk.
    Thanks
    Ali

  2. Jo says:

    If you’re using it for SBS backup how _do_ you change the USB disk? Just unplugging and swapping it made our SBS stop seeing the disk.

    • ronnypot says:

      Hi,

      You need to remove the drive as described in the article, first via hyper-v manager and then you can remove it via safely remove on the Host. The new drive must be attached via the same way as described.

      • Kolja says:

        Hi,

        we have just set up a SBS 2011 essentials on an Hyper-V host, and are now looking for a viable backup solution. Is there any way to make the process of attaching USB-Drives easier? There’s not always a trained IT-person around and we need to be able to take the backup off-site.

        Another idea would be to backup to an VHD on one of the server’s internal hard drives and then use windows server backup on the host for backing up the VHD to external drives. Is it possible to do incremental backups of VHDs without unmounting them? Or is there any other easy solution?

        Thanks a lot for your posts and hope you or someone can give us a hint

        Kolja

        • ronnypot says:

          Hi,

          Ofcourse you can use this for backups but I don’t know if this is a supported option, it will work but for production environments I would not recommend this.

          If you want to make backups from the complete vm without unmounting it and make incremental backups you have to look to any certified backup program, this kind of backups are as far as I know not with built-in programs. Microsoft has DPM that can do this, and for other party there are several who can, most cases you need to buy a separate agent for virtual machine backups.

  3. Karur Rangan says:

    Taking a usb drive offline is not supported in windows 2008 R2.
    That is the message I received when I tried Diskpart from the host machine.

    I gues I have to copy the file on to a CD and bring it in and avoid USB.

    Rangan

    • ronnypot says:

      Never had any problem with putting a usb drive offline. I always use disk management not diskpart, so maybe this will differ?

      • Karur Rangan says:

        On my windows 2008 R2 enterprise with sp1, on right click against any of the drives, including the USB drive, the option for ‘Offline’ is absent. Hence I tried Diskpart and I followed the command sequence, select volume, and offline volume id, when I got the message ‘operation not supported’.

        I don’t know why the offline option is missing.
        Thanks /Rangan

        • ronnypot says:

          Really strange, never seen that before. I would try if I can reproduce this.

          • Van Vangor says:

            Just for verification, I have a Hyper-V host running Windows 2008 R2 Data Center w/SP1 with a couple of USB drives attached. And yes, I have the ability to take the USB drives offline within Disk Management.

            I’m curious to find out what’s different about Rangan’s configuration.

            See Ya!
            Van

          • ronnypot says:

            I am running Windows 2008 R2 Standard and Enterprise and both work fine, for bringing the usb drives offline within Disk Management. So I have no clue why it won’t work within his configuration, I can not reproduce it on one of my systems.

          • hits_r says:

            Hi,

            As I am having the same issue with USB drives I found that I can’t take a USB pen drive offline, but I take take a USB HDD offline.

  4. alesko says:

    i have another challenge. I think it is not supported to backup a virtual sbs 2011 hosted on win 2008 r2 std, through windows backup of the host, when the virtual sbs has offline usb disks attached. Would you agree?

    • ronnypot says:

      Sorry just to get your question right, you want to backup the virtual machine to the host with a offline attached usb disk? The problem could be when you need to restore and the usb disk is not available the vm won’t start because it is missing the disk and you must first remove it from the configuration. So it wouldb e wise to create a backup without the disk attached.

  5. alesko says:

    You are absolutelly right, but in a case like that I would not mind setting up the VM to remove the missing disk again. The great think would be to have automated backups running within the virtual sbs AND from the host as well, at different times. Thus you can restore either a guest backup or a full set of the virtual machines (or some f them) from the host. But I remember seeing an error a few weeks ago,stating “backing up virtualmacines with offline disks attached to them is not supported.” I will try this again in a coupple of days though!

  6. Jay says:

    Hi,
    I have the same issue with “Offline” not being an option in the right click menu. If anyone figures that out please let me know…

    • ronnypot says:

      Hi,

      It looks like reading the comments from everyone that there is a difference between usb disks and usb keys. The option only seems to work for usb disks and not for usb keys.

  7. John says:

    Ronnypot: I have the same issue on a
    w2008 R2 Standard. Cannot set a usb stick to offline. The Option is not available. Any ideas?

  8. John says:

    Ronnypot: I think I answered my own question. It appears Windows 2008 R2 can distinguish between a USB stick and a removable drive. I put a removable drive on and its works as you say it does.

  9. Jay says:

    OK. This was a USB drive not a key. I used DISKPART to offline the disk. Now I am having a challenge with the disk being visibile in the virtual machine.

    • Jay says:

      As an update, i was able to attach the iscsi disk in the host to the virtual machine. Now, however, the disk is not visible inside the VM disk manager. Stuck again… anyone see this before?

      • Lena says:

        Hey Jay…were you able to get the disk to show up in the VM? I have done these steps before without issue…but for some reason…just today…the disk isn’t showing up in the VM.

  10. alesko says:

    After all it seems that the backup works both through the vm on a scsi attached (offline to the host) usb disk AND from the host itself on another online usb disk. I am not sure if it is application aware for the hyper-v, but I will try to restore a vhd and its config.

  11. M Iqbal Qureshi says:

    I am facing a strange issue while connecting the USB disk to one of the Virtual Machine in Hyper-V (WS 2008 R2).

    The virtual machine is not booting when I connect the USB disk to any of the IDE controller.

    And also, when I connect the USB disk to SCSI controller, the USB disk is not visible under Disk Management of Virtual machine.

    Any opinion!

    Best Regards,
    M Iqbal Qureshi.

  12. praseej says:

    Greate!…. keep it up, i was fedup with creating CD’s to read my VM in Hyper-V server..

    Thank you very much..

  13. Roberto says:

    Hi
    thank you for your useful post.
    Unfortunately doesn’t work for me. I need to restore a Virtual Machine ghosted in a img file with G4L. I make all the operation described in the post, I create the new disk in the target VM assegning the physical Udb disk but when i start with G4L i cannot see the disk. I tried to create the disk either in the Ide and Scsi controller but without success.
    Have you some suggestion for me please?
    Thank you in advance
    Roberto

    • ronnypot says:

      Hi,
      As said in the post this is not a supported solution it might work as a workarround but if the program you are using does not see the disk it probably won’t so you need to find another solution.

  14. Joao T says:

    Hi,
    thank you for your useful post.
    Unfortunately doesnโ€™t work for me also. I am using Virtual Machine Connection with Server 2008 R2 and runing Win 7 on VM. I follow all steps and choose a Physical hard disk: and choose the disk i would to add n prob. But after that i cannot see him active in the VM Win 7. If i go back to Disk Management in Server 2008 is standing there as offline (and i cannot put it online here says ACESS DENIED) so please give some tips how to fix this.

    Thanks in advance
    Joao

    • ronnypot says:

      Hi Joao,
      If it is attached to a virtual machine it is normal you cannot put it back online on the Windows 2008 R2. You first need to remove it from the virtual machine, after that you should be able to put it back online on the server.

      Why it is not working I am not sure but as you can read there are more people having trouble. As said it is a workarround and not supported and it looks like not all drives are working.

    • Eshahawy says:

      to see your USB drive on your Virtual Machine,
      you need to use (Disk Mangement) on (Virtual Machine), you will find the USB drive is off-line, change it to on-line, thats all

  15. Rogerio says:

    I think I figured out the problem with the missing Off Line option. ๐Ÿ˜‰

    In the Disk Mangement, the disk properties has 2 columns. The first that show the Disk and Status and a second column that show the disk it self.

    Be sure when you click with the mouse that the pointer is over the first column.

    That is it.

  16. Pieter de Niet says:

    If i add the usb disk as a scsi disk it will not appear in my virtual sbs server. When i add the disk as a IDE attached device everything went fine.

    Must i add a seperate driver in the virtual to communicate with the USB drive a a scsi device ? What am i doing wrong?

    • ronnypot says:

      Never needed to do that, I noticed that if you add a scsi device to a windows 2003 server you need to restart the virtual machine before it is active.

  17. I have had success with the USB external HDD and SBS2008 internal backups option.
    You require a scheduled task on the Hyper-V server to add and remove the hardware
    Eg: Remove the virtual SCSI interface AFTER backup is complete, and ADD the virtual SCSI interface AFTER the new disk has been attached.
    Search for the module “PSHyperV” it is a set of powershell commands that enable this level of commandline control.

    This set of commands needs to be run EVERY time the disk is swapped out. otherwise SBS2008 will not see the new disk after it has been swapped.

  18. Arny says:

    How many USB drives can you add to a virtual SBS 2011?

    Is it possible to use a USB drive rotation, as we would normally do with physical SBS 2011 boxes?

    Arny

    • ronnypot says:

      Hi,

      I don’t know how much usb drives you can add, but if you mount more than one, SBS backup will only backup to one it will not do a multiple backup when there are more than one disks available.

      Please read the comment of David Barnett het describes he is using a scheduled task to detach a disk after backup and attach another disk. I did not try this but this sounds like a fine solution for drive rotation using a virtualized SBS server.

  19. Prov25 says:

    Hi Ronny,

    Im running Hyper V Server 2008 R2 SP1 and am running SBS 2011 as a Guest.

    It works perfectly.

    My only question (because I am yet to test) is…

    If I unplug the USB drive which is online on the guest and offline on the host …will backups still work?

    If not I am guessing I will need to create a script to pull off all of the required tasks…your thoughts?

    Many thanks.

    LivingITraro

    • ronnypot says:

      Hi,

      You need to remove the scsi disk via Hyper-V manager, see one of the other comments for some information about scripting this.

  20. Oduro-Kwarteng says:

    It has been very helpful

  21. Brad says:

    Thanks for this, helped me launch an SSD while production server was running ๐Ÿ™‚

  22. Tim says:

    Worked great! Used it to move 50 GB of databases between virtual SQL servers instead of clogging up the network.

  23. Hello, that such an interesting article. What is the most advantage of using this approach than others?

Leave a Reply

Sharing Buttons by Linksku