How do I OFFLINE a USB thumbdrive for direct use in VBox?

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Ben321
Posts: 32
Joined: 30. Dec 2016, 01:51

How do I OFFLINE a USB thumbdrive for direct use in VBox?

Post by Ben321 »

I know that Virtualbox needs a harddrive to be offline so that Windows isn't locking it, in order for it to be usable in VBox (as VBox needs raw access to the drive). The thread at viewtopic.php?f=6&t=38914 shows how to do it for a conventional harddrive, and this might even work for a USB plugin harddrive. But a USB thumbdrive is something else. The technique they tell you how to use (using DISKPART take the drive offline) does NOT work for USB thumbdrives. Diskpart displays the following error message when I attempt to do so "The operation is not supported on removable media.". So now I have a real problem. I get the error VERR_ACCESS_DENIED from VBox when trying to use the drive while it's online, but Windows DISKPART won't let me take the drive offline.

The full text of the error is:
Permission problem accessing the file for the medium 'C:\Users\Ben\AppData\Local\Temp\USB8G.vmdk' (VERR_ACCESS_DENIED).


Result Code:
VBOX_E_FILE_ERROR (0x80BB0004)
Component:
MediumWrap
Interface:
IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
Callee:
IVirtualBox {9570b9d5-f1a1-448a-10c5-e12f5285adad}
Callee RC:
VBOX_E_OBJECT_NOT_FOUND (0x80BB0001)
Is there a solution to this? I'm about to have a nervous breakdown, as everything I attempt to do to fix this problem, only presents further problems. I'm willing to do basically anything at this point to get it to work, even if it means hacking the Windows registry to take the drive offline.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How do I OFFLINE a USB thumbdrive for direct use in VBox?

Post by scottgus1 »

You face two problems: one you can fix and one you can't. It appears you are trying Raw Disk Access, which requires Run As Administrator for every step in Virtualbox on a Windows host. Also, Windows apparently does not allow USB drives to be taken off-line.

You can try passing the USB drive into the VM with a USB filter. It will be seen as a USB drive by the VM OS, see USB basics and troubleshooting
Ben321
Posts: 32
Joined: 30. Dec 2016, 01:51

Re: How do I OFFLINE a USB thumbdrive for direct use in VBox?

Post by Ben321 »

scottgus1 wrote:You face two problems: one you can fix and one you can't. It appears you are trying Raw Disk Access, which requires Run As Administrator for every step in Virtualbox on a Windows host. Also, Windows apparently does not allow USB drives to be taken off-line.

You can try passing the USB drive into the VM with a USB filter. It will be seen as a USB drive by the VM OS, see USB basics and troubleshooting
That FIXED. I needed to run VBox as administrator. I had assumed previously that since VBox was such a powerful program, one that would obviously need admin access, that it would contain code to automatically elevate itself to have admin permissions. It turns out that I was mistaken. I needed to explicitly do "run as administrator" when starting it to give it admin permissions. After that though it worked fine.

On your last statement though, using the USB filter won't work for booting in VBox. That only works to allow already booted guest OS's to access USB devices (and I believe may in fact require Guest Additions, which are something that is installed in an OS, and therefore not available in the pre-boot environment as would be needed to let VBox see a real USB device as a bootable drive). It's not therefore possible, from my understanding to have VBox capture a USB stick to use as a boot device.
My intent is to make my real USB drive be bootable by letting VBox see it as a harddrive, and then install a bootable OS on it through VBox, and then use that configured USB drive as a bootable live-OS external drive to boot a real PC into the OS on the USB stick.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How do I OFFLINE a USB thumbdrive for direct use in VBox?

Post by scottgus1 »

Ben321 wrote:using the USB filter won't work for booting in VBox.
This is true, when using the legacy BIOS. Apparently the EFI BIOS supports booting from USB, though I have not tried it.

The reason why the misguided advice was given is because you presented us with an "XY problem".
Stack Exchange wrote:The XY problem is asking about your attempted solution rather than your actual problem.
The first post doesn't mention booting from USB as the intent, so advice about a workaround to the presented problem was provided. A USB filter will not help with booting from USB. Only Raw Disk Access or EFI BIOS will boot from USB.

BTW, avoid running Virtualbox as Admin as much as possible. Virtualbox is a powerful program, which means any unexpected host malware could have a chance to dig in deeper if a Run-As-Admin Virtualbox is present.
Ben321
Posts: 32
Joined: 30. Dec 2016, 01:51

Re: How do I OFFLINE a USB thumbdrive for direct use in VBox?

Post by Ben321 »

scottgus1 wrote:
Ben321 wrote:using the USB filter won't work for booting in VBox.
This is true, when using the legacy BIOS. Apparently the EFI BIOS supports booting from USB, though I have not tried it.

The reason why the misguided advice was given is because you presented us with an "XY problem".
Stack Exchange wrote:The XY problem is asking about your attempted solution rather than your actual problem.
The first post doesn't mention booting from USB as the intent, so advice about a workaround to the presented problem was provided. A USB filter will not help with booting from USB. Only Raw Disk Access or EFI BIOS will boot from USB.

BTW, avoid running Virtualbox as Admin as much as possible. Virtualbox is a powerful program, which means any unexpected host malware could have a chance to dig in deeper if a Run-As-Admin Virtualbox is present.
Yes I'm definitely using BIOS mode, not EFI mode.

It is working now in terms of being able to access my real USB thumbdrive from inside VBox. I have full read write access when booting the virtual machine from a DOS bootdisk. However, a new problem now presents itself. The guest OS is REFUSING to boot from the the physical drive (as accessed via this raw disk access VMDK file). I used FDISK and FORMAT to partition the drive, and format it and automatically copy the required DOS system files. This SHOULD render it bootable. But it doesn't. Unlike when using a purely virtual drive, when using a real drive, VBox doesn't treat it as bootable. I do want to make it bootable on a real PC, but I also want to make it bootable in VBox, so I can test it, before using it on a real computer. I'm GUESSING that that a real computer would see it as bootable, but for some reason VBox doesn't see it as bootable. As of right now, I'm just trying to install a very simple OS, DOS 6.22. So it shouldn't be too hard to get it to work.

Can you tell me why VBox doesn't see a physical drive (as accessed via the physical drive access technique) as being bootable?
Post Reply