How To Use Host USB Device From Guest In VirtualBox


Sometime back I explained how to use the host serial port from guest os in VirtualBox, In this post I will explain you how to use the host USB device from the guest.

First Thing First :

VirtualBox is distributed in both closed source (binary) and open source (GPL V2) editions. Note that the open source edition does not provide USB support. Please refer to VirtualBox Editions page for more information.

Thanks mbuotidem for letting me know about this missing piece of information.

 

For this post I will show you how you can use the USB Thumb Drive connected to host USB port from guest OS. The procedure remains same for other USB devices as well. Even though Virtual Box allows you to enter lot of information for USB device configuration you really don’t have to worry about it if you just want to access the selected device.

VirtualBox Configuration:

Before going to actual configuration ensure that the USB device you want access from guest is connected. Once the device is detected by your host OS, open the USB configuration options dialog for the guest’s virtual machine in Virtual Box.

1. Check “Enable USB Controller” check box. If the device is USB 2.0 complaint check “Enable USB 2.0 (EHCI) Controller check box. Now the USB Configuration Dialog Box will should look like the image below:

Basic USB Configuration Without Any Filters

Basic USB Configuration Without Any Filters

2. Now we need to tell virtual box which USB device(s) connected to host should be accessible from guest. This is done using the USB filters, only the device which matches the filter are accessible from the guest. Virtual box allows you to create filter based on vendor or product category and so on but we will ignore all that in this post and create filter which matches to exactly one and only one device that we want to share.

So while on the USB configuration options dialog box press “Alt+Ins” or click on “Add Filter From Device” button (Second button from top with green plus symbol). This will bring the pop-up menu with all USB devices connected to the host (See image below).

List of available USB Devices

List of available USB devices

3. In the pop-up menu scroll down the device you want to access and click on it or press the enter key (In my example I want to access the USB FLASH Drive). A new filter for this device will be added to the list of filter as shown in the image below:

Filter is added for selected device

Filter is added for selected device

4. Here we are done with the Virtual Box configuration, however, if you are interested in more details double click on the selected filter and it will bring up the detailed information about the selected device, this information might be useful for you to access your device from the guest (See the image below).

Filter Information

Filter Information

5. Using the same method I have added one more filter from my AVR JTAG debugger. See the image below for my final setup.

One more filter

One more filter

Now we are all set to see it working, Whatever we have done till now is one time procedure and this need not be repeated when you remove and reconnect your USB device. However, there is one more one time activity that will happen when you start the virtual machine.

USB Driver Installation:

Virtual Box provides its own USB drivers to provide this access so when you start the virtual machine using the USB devices on the host, windows might ask you to install these driver, Nothing to worry everything required is already installed with Virtual Box.

1. As soon as you start the virtual machine, Windows will pop-up a Found New Hardware Wizard as shown below:

USB driver installation request

USB driver installation request

2. Select “No, Not this time” radio button  and click on next, this time wizard will ask you to choose between installation method (see image below)

USB driver installation method

USB driver installation method

3. Select “Install the software automatically” and click on next, This will start the driver installation process. Virtual Box USB driver does not seem to be added to compatibility list of Windows drivers so you might get a request to confirm whether you want to continue installation or no. Don’t worry its just a check from Microsoft, we trust the Virtual Box team so we will choose to install the driver by pressing “Continue Anyway” button. (See image below).

USB driver compatibility check

USB driver compatibility check

4. You will get the successful completion dialog box for the driver installation, close that dialog box and your virtual machine will continue with booting operation. You might have to do this again if you connect the same device to some other USB port on the computer.

Verification Under Guest OS:

Now we will have to verify whether the device is accessible from the guest or not first before trying to access it.

1.  Before doing any other verification, lets ensure that virtual machine is able to find our devices. To do this start your virtual machine and move the mouse over a small USB icon in lower right corner of the virtual machine, If you have done everything correctly and the devices are attached to the computer you should be able to see the list of accessible devices in the tooltip as shown in the image below. Remember this is the first check, you don’t have to do anything else except running your virtual machine.

List of accessible USB devices

List of accessible USB devices

2. From this point onwards I will provide kubuntu (Linux) specific information as my guest OS is Kubuntu. Now we know that virtual box was able to find the two USB devices we have selected now we will verify whether the OS is able to find them as well. So open the konsole and type lsusb, this command will give you a list of available USB devices (see the image below). If you are able to see you device here it means you are all set to use it. If your device is not the FLASH drive, you can stop here you are ready to use it using your application program.

List of accessible USB devices

List of accessible USB devices

3. Kubuntu will find the new USB Flash drive and mount it automatically. Else you can find the the device id for it and mount it on your own. To find the device id go to konsole again and type “dmesg”, you should get output something like like.

    [  499.706571] usb 1-2: new full speed USB device using ohci_hcd and address 3
    [  500.708306] usb 1-2: not running at top speed; connect to a high speed hub
    [  500.727836] usb 1-2: configuration #1 chosen from 1 choice
    [  501.112837] usbcore: registered new interface driver libusual
    [  501.313497] Initializing USB Mass Storage driver...
    [  501.340048] scsi0 : SCSI emulation for USB Mass Storage devices
    [  501.355083] usbcore: registered new interface driver usb-storage
    [  501.356713] USB Mass Storage support registered.
    [  501.360476] usb-storage: device found at 3
    [  501.360493] usb-storage: waiting for device to settle before scanning
    [  506.359374] usb-storage: device scan complete
    [  506.421371] scsi 0:0:0:0: Direct-Access              USB FLASH DRIVE  34CH PQ: 0 ANSI: 0 CCS
    [  506.513462] Driver 'sd' needs updating - please use bus_type methods
    [  506.735986] sd 0:0:0:0: [sda] 4030464 512-byte hardware sectors (2064 MB)
    [  506.747472] sd 0:0:0:0: [sda] Write Protect is off
    [  506.747546] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
    [  506.747559] sd 0:0:0:0: [sda] Assuming drive cache: write through
    [  506.795751] sd 0:0:0:0: [sda] 4030464 512-byte hardware sectors (2064 MB)
    [  506.806414] sd 0:0:0:0: [sda] Write Protect is off
    [  506.806474] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
    [  506.806484] sd 0:0:0:0: [sda] Assuming drive cache: write through
    [  506.806527]  sda: sda1
    [  506.815888] sd 0:0:0:0: [sda] Attached SCSI removable disk
    [  506.857683] sd 0:0:0:0: Attached scsi generic sg0 type 0

The third line from bottom tells us that the USB Flash drive is at sda1.

4. To mount this device we need create the mount point and use the mount command see the image below for details.

Mount the USB Drive

Mount the USB Drive

See the difference between output of first and second mount command, our USB drive is mount at /media/USBDrive in the output of second mount command. Now just go to /media/USBDrive and you will be able to see the contents of the flash drive.

5. To remove the drive, click on the drive icon and select safely remove, our issue the umount command.

Final Thoughts:

1. Once everything works fine after the first boot, you don’t have to have connected your USB devices before starting the virtual machine, you can connect them after the virtual machine is started and remove them before closing the virtual machine just like a physical computer.

2. Generally the Device will not be accessible from the host once the virtual machine is started.

3. Sometimes the device is not accessible from the host even after virtual machine is closed, if this happens remove the device and re-connect it.

Links Related to This Post:

About these ads
This entry was posted in How To, Kubuntu, Tips, Virtual Box and tagged , , . Bookmark the permalink.

44 Responses to How To Use Host USB Device From Guest In VirtualBox

  1. Pingback: Topic Drivers » How To Use Host USB Device From Guest In Virtual Box

  2. Pingback: Credit Repair Software: Part I-Installation

  3. ezee says:

    I clicked on add filter but it is saying “no device” ..something close to that, despite of my pen drive is already mounted on ubuntu

  4. excogitator says:

    @ezee

    What is your guest and host OS? Looks like you have ubuntu as host? if you confirm i will try with that setup.

  5. Dieter Ammann says:

    When I add the USB device is states, Not available

  6. will says:

    Thanks, I’ve spent a long time trying to figure out how to get this to work. Thank you so much!

  7. Pingback: VirtualBox USB. Sometimes things can be simple. « VincisBlog

  8. Clintstone says:

    The tutorial was great…I am still having problems trying to install a usb device to communicate with a program I have running in XP as a guest on a Mac OS. Everything was fine with the filter but when I open XP it never asks for drivers or sees the Hardware? Thanks very much. I really want to make this work.

    • excogitator says:

      Hi Clintstone,

      I am not sure i understood your problem exactly, just make sure that you have guest additions installed in your guest OS and try again.

      Regards,
      – Excogitator

    • Clintstone says:

      There was an update and then my stuff started to function perfectly. I am running XP and plan to install Windows 7 after I install a larger HD. Thanks for the help.

  9. Gowtham says:

    i used same procedures but nothing seems works

  10. Brandon says:

    Great explanation!

  11. Achim says:

    Nice explanation – but what do I do when the USB section is completely missing?

    Running OpenSuse 11.3 and OS§ 3.2.6 r63112

    Thanks very much

  12. mbuotidem says:

    yeah, Achim, i too was completely confused when i couldn’t find the USB section under the settings of my virtual box. I found that using Virtual Box closed source version, instead of the ose(open source version) solved that problem. I think the blog writer should mention that at the top of the tutorial.

    thanks for the tutorial, it was very helpful

    • excogitator says:

      It’s good point, USB support is not available in open source edition, more details about editions can be found here . Will update the post.

      Thanks for dropping by.

      – Excogitator

  13. David Bobson says:

    Article was very useful and nicely laid out. Thanks.

    I was wondering if you have seen this error before. Popup window labled VirtualBox – Error; Error msg is: Failed to attach the USB device USB Disk 2.0 [1029] to the virtual machine . Msg goes on about the USB device.

    I received this message when the icon for the USB in the guest partition does not show any available devices. Then left mouse click on the icon and select the — USB Device 2.0 [1029].

    I am running WinXP, SP3. Guest Partition is Linux, Crunchbang.

    Linux displays the root hub with lsusb.

    Running the command: VBoxManage list usbhost

    C:\Portable-VirtualBox\app32>VBoxManage list usbhost
    VirtualBox Command Line Management Interface Version 3.1.2
    (C) 2005-2009 Sun Microsystems, Inc.
    All rights reserved.

    Host USB Devices:

    UUID: b6efd3fd-051f-48ea-9a33-e484363f19d5
    VendorId: 0x04b3 (04B3)
    ProductId: 0x310b (310B)
    Revision: 1.96 (0196)
    Address: {745A17A0-74D3-11D0-B6FE-00A0C90F57DA}001
    Current State: Busy

    UUID: 5caaa4a1-7164-4630-9593-fce070b515dd
    VendorId: 0x090c (090C)
    ProductId: 0x1000 (1000)
    Revision: 16.41 (1641)
    Manufacturer: USB
    Product: DISK 2.0
    SerialNumber: J1TFY98PX72JTWDJ
    Current State: Captured

    Any insight would be helpful.

  14. Sorry. I’m experiencing problems. I have ASUS F3J series notebook. Running Ubuntu 10.04 (fully updated 28Jul10). VirtualBox is 3.2.6 r63112. USB memory stick is a SanDisk cruzer colors+ 2GB. Guest OS is Win XP SP3. VirtualBox shows for USB device filter = 1 (1 Active).

    When XP starts it does not detect presence of USB device. “Add New Hardware” in control panel does not detect the presence of a USB device. USB device is shown in grey in guest machine when USB icon is clicked and it can be ticked to make it “On”.

    Sincere thanks for your effort in producing a fine tutorial.

    Any hints would be warmly accepted. Wishing you well for the future.

    Kevin

  15. Sorry.. amendment. “and it can be ticked to make it “On”” should be changed to “and it CANNOT be ticked to make it “On””

  16. Rémi says:

    Your tutorial is very good and all is ok when the user logged in the host system is admin. But if it is only a standart user (for example, in a company, ti protect the host system and give “freedom” in a host one) the host system require an admin password ! How to work around this problem ?
    Thanks

  17. Jonny says:

    Hello thanks for a god work the Virtualbox
    I have Virtualbox Maverick(Ubuntu) and have Win 7 in virtualbox.
    my usb devices is shown but i don get the right drivers in Win7 its a unknown device. The virtualbox guest is installed. i have managed the filters so the deviceś is present in win7 but they don work because the wrong drivers.
    what should i do?
    Thanks for help.

  18. Pingback: 2010 in review « Software, Tools, Tips, Tricks

  19. jaredborit_amaw says:

    the procedure was great and it does really work…..
    thank you so much……

  20. Greyback says:

    Hi, This helped me very much, straightforward and no-nonsense, thanks so much for this post!
    Proudly running XP in a Virtual Box at this moment.

  21. abih says:

    It works!!! insightful and easy explanation.

  22. Balaji says:

    Hi,ti

    I am using Windows 7 as the Host and have Red Hat 5 installed as the guest(virtual machine) in Virtual Box. I am unable to use USB. It wont even detect. I am using the Oracle VM Box 4.1.0 and i also have its extension installed did enabled and tried to start client. Even checked fdisk -l but it wont even show the NTFS partition. Please advise how to make USB enabled in VM’ed Red Hat. Please help

    • excogitator says:

      Hi Balaji,

      I am not sure that i understood your problem.

      What are you trying to do? Attach USB harddisk and want to access it in VM?
      Is Virtual box (application running on Windows 7) able to detect this device? If, yes have you checked dmesg on your Red Hat VM to see whether the device was detected or not by the kernel (note that GUI tools may or may not show the attached devices based on your configuration, check with dmesg instead)

      • Balaji says:

        Yes, Win7 is the host where i have installed VirtualBox. RHEL5 is the guest OS within VitrualBox. USB devices are working fine with in Windows7. But i try to mount that USB device by right clicking on the Virtualbox option(bottom right of VB) where we CD, USB, network option it throws an error “failed to attach the usb device Unknown s?device to the virtual machine. USB device HP v165w with UUID is busy with a previous request”.

        I have checked that no files are being opened from the USB but still get the same even if i reconnect, reboot.

        Any idea how to fix this?

  23. Louis M. Ayers says:

    I’m trying to run MS-DOS 6.22 as a guest on VB 4.1.0 r73009 running in Win 7 64-bit Home Premium. I can get everything to work except the USB – I can attach the drive and VB says it’s attached, but I cannot find it – all drives E: – G: (the legal drive letters) are all invalid!

    My question – how do I attach a USB drive and access it like a normal drive, with a drive letter?

    Thanks in advance.

    Sparky

    • excogitator says:

      If my understanding is correct, MS-DOS 6.22 does not have USB support. Virtual Box is passing the device to your MS-DOS machine but MS-DOS does not understand this device. Perhaps you can mount your USB drive on your host machine (Win 7) and share it with MS-DOS VM as shared folder.

  24. Landon says:

    Oh my God I looked everywhere for the answer and it was this easy? thanks!!! Now how do I view my cd drive???????

  25. JC Hendee says:

    I think it is important to note that there may be hardware limitations involved. I was attempting to get a Samsung Galaxy Tab 7+ hooked via USB to WinXp-SP3 in VirtualBox running on OS X 10.6.8. It was complete no go. The device popped up in VirtualBox as “Android [0400]” but wouldn’t go further than that no matter what. And when I launched WinXP-SP3 in VirtualBox, all WinXP kept telling me was that the device could not be mounted. It knew it was there but could not speak to it.

    I followed all instructions in this article, and it was easy to do. But in some cases, it just isn’t going to work. I’ve tested the same device in an old notebook running WinXP-SP3, and it mounts instantly, showing both internal and external SD cards. VirtualBox is great, but there’s no getting around that a vm’ed environment is dependent upon the host environment, its drivers, and its hardware. Apple is notorious for not wanting any but their own devices to connect to their own devices, and with newer platforms of Android stripped down to MTP protocol, don’t blame the author here if something doesn’t work for your. Welcome to war between Apple, Microsoft… and Google.

    • excogitator says:

      Thanks for the update, I agree that this method may not work in some scenarios.

      If your only need is to mount tab’s file system in VM, you can try this workaround:

      1. Mount the tab’s file system on host as usual.
      2. Use Virtual Box’s shared folder to share them with the VM.
      3. Mount the shared folder in VM.

      I have never worked with any Apple stuff yet, so one thing less to worry about :).

  26. tim says:

    Thanks for this tutorial.

  27. Nitin Singh says:

    HI I am working in IT Company as a software tester, and i am using Virtual Machine for my application because application is in 8 language and i want to check functionality of application in different language with different operating system.

    and there is one special functionality in application that is working after the connection of some hard ware device in the USB port.

    So i want to know that can we access the USB port and CD drive data from my Virtual machine (VM Ware/Vcenter/LAB Manager).
    If Ur Answer is yes, so tell me how i can use USB Device and CD Drive data.

    Please do the needful.

    Regards
    Nitin Singh
    Please contact me by below mail ID
    Nitin.pcst1@yahoo.com

  28. SitaRaama says:

    Can you tell me how to do the same with Ubuntu 10.1 in virtual machine as guest OS.

  29. Pingback: Rooting Samsung Galaxy Tablet 10.1 with VirtualBox on Mac OS X | The Revolver's Notepad

  30. Thanks for finally talking about >How To Use Host USB Device From Guest In VirtualBox | Software, Tools, Tips, Tricks <Liked it!

  31. Pingback: ROM Kitchen modified from dsixda’s HTC Kitchen | Green Rom Project – News

  32. AMT says:

    Thank you very very very much …. it’s relay impressive show. i had the same problem and now done. thanks again.

  33. Isobel says:

    Great info. Lucky me I came across your website by accident (stumbleupon).
    I’ve saved as a favorite for later!

  34. Pingback: Debug a Bluetooth App with Android Emulator on PC | All Things Technical

  35. hamza62240 says:

    Hi, I enabled this USB drive on my Mac OS X guest OS but instead of working, it crashed the guest OS (Kernel Panic). It told me to restart.

    Didn’t happen on VMware. I acced. moved my shared folders in VMware out of the dock, now I had to switch to VirtualBox to do my work. I also needed to use my USB but it gave a Kernel Panic.
    I was gonna use the SMB protocol to share the folder.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s