How do I use an actual drive (like a USB stick) in VirtualBox?

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Maks7584
Posts: 2
Joined: 1. May 2023, 21:09

How do I use an actual drive (like a USB stick) in VirtualBox?

Post by Maks7584 »

Let's say I want to install Ubuntu on an USB stick using VirtualBox. How can I make a VM that instead of writing to a virtual drive, writes to an USB stick?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How do I use an actual drive (like a USB stick) in VirtualBox?

Post by scottgus1 »

There is a process called Raw Disk Access that can give Virtualbox direct access to a physical disk, see the manual, https://www.virtualbox.org/manual/ch09.html#rawdisk

It is an experts-only feature and with wrong use can hose your PC. We don't show folks how to do it on the forum.
Maks7584 wrote:writes to an USB stick?
You'll find that USB sticks will die an early death if you install a modern OS on it. USB sticks are not designed for the constant writes a modern OS does.

A USB-3-or-faster-connected SSD drive will be OK, though. Don't unplug the drive while the VM is running.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How do I use an actual drive (like a USB stick) in VirtualBox?

Post by mpack »

Maks7584 wrote:How can I make a VM that instead of writing to a virtual drive, writes to an USB stick?
A VM can't use anything other than virtual drives - being a virtual machine. The only question is whether it accesses the drive using high level fast cached file I/O, or slow low level uncached sector I/O - the latter of which will require fighting Windows for admin rights. So I hope you weren't assuming that raw access would be faster.

A better option IMO would be to locate the entire VM on the external drive, which incidentally should be an SSD or mechanical drive, not a USB flash drive (see Scott's comments).

That said... I assume you have good reason for wanting to use an external drive, but note that it carries several risks, the principle one being the unreliability of the USB connection which can lead to the drive being corrupted and data lost. Not a problem if you make backups and/or don't store anything important in there.
Post Reply