在 Linux 上的 VirtualBox 中从虚拟机访问 USB
USB VirtualBox
![](/data/attachment/album/202309/25/002722v04rbi1g34084gf1.jpg)



> 
> 你完全可以从虚拟机内部访问 USB 存储器。如果你使用的是 Linux 上的 VirtualBox，下面将介绍如何做到这一点。
> 
> 
> 


当你插入 USB 时，你的宿主操作系统可以轻松访问它并使用其中的文件。这并不奇怪。


如果你在 Linux 上使用带有 VirtualBox 的虚拟机，那么可以付出一些努力并从虚拟机访问插入物理机的 USB。


让我逐步引导你了解如何在 VirtualBox VM 中访问 USB 磁盘。


### 如何在 VirtualBox VM 中访问 USB 驱动器


默认情况下，你无法使用 VirtualBox 访问 USB 驱动器，因为你必须安装扩展包管理器，此外，还有一些配置部分。


这就是我将本教程分为三个简单步骤的原因。那么让我们从第一步开始。


#### 步骤 1：安装 VirtualBox 扩展包（在主机上）


这是本教程中最重要的一步，因为你将安装 VirtualBox 的扩展，这将使你能够在虚拟机中使用 USB 驱动器。



> 
> ? 你应该安装与你安装的 VirtualBox 版本相同版本的扩展包。
> 
> 
> 


要安装 VirtualBox 扩展包，只需访问 [VirtualBox 官方下载页面](https://www.virtualbox.org/wiki/Downloads)，向下滚动一点，你将找到下载扩展包的选项：


![](/data/attachment/album/202309/25/002742hqro4rbjz0vvr0z8.png)


下载完扩展包后，请执行 3 个简单步骤：


* 转到 “<ruby> 文件 <rt>  File </rt></ruby>” > “<ruby> 工具 <rt>  Tools </rt></ruby>” > “<ruby> 扩展包管理器 <rt>  Extension Pack Manager </rt></ruby>”
* 点击 “<ruby> 安装 <rt>  Install </rt></ruby>” 按钮
* 从文件管理器中选择下载的文件：


![](/data/attachment/album/202309/25/002743tolba6zq977e6w7g.png)


它将打开一个新的提示来安装扩展包，你所要做的就是点击“安装”按钮并接受条款和条件：


![](/data/attachment/album/202309/25/002744w3npgcf9ag2i3fau.png)


我们就完成了扩展包的安装。


#### 步骤 2：将用户添加到 vboxusers 组（在宿主机上）


要在 VirtualBox 中使用 USB 驱动器，你的当前用户需要位于 `vboxusers` 组中。


我知道这听起来有点复杂，但 [将用户添加到组](https://learnubuntu.com/add-user-group/) 是一个命令过程，将用户添加到 `vboxusers` 组可以通过以下方式完成：



```
sudo usermod -aG vboxusers $USER

```

**完成这两个步骤后，重启系统以使这些步骤生效。**


#### 步骤 3：将 USB 驱动器添加到虚拟机



> 
> ? 在为特定虚拟机添加 USB 之前，请确保其已关闭（未保存），否则你将无法按照给定的说明进行操作。
> 
> 
> 


要为虚拟机添加 USB，你必须遵循以下简单步骤：


* 选择你想要使用 USB 的虚拟机并点击 “<ruby> 设置 <rt>  Settings </rt></ruby>”
* 转到 “USB” 选项卡
* 选中 “<ruby> 启用 USB 控制器 <rt>  Enable USB Controller </rt></ruby>” 框并单击 “+” 按钮选择 “USB”：


![](/data/attachment/album/202309/25/002744pyri44afzafxfhy6.png)


这就好了！现在你可以启动虚拟机，并且 USB 驱动器应该出现在文件管理器中。就我而言，它是 Ubuntu，所以它看起来像这样：


![](/data/attachment/album/202309/25/002745bfgkfokfyqxyfodd.png)


### 更多 USB 和 VM 技巧


如果你在虚拟机中使用 USB 看起来很酷，那么在虚拟机中从 USB 启动就更酷了！这里有一个关于 [如何在 VirtualBox 中从 USB 驱动器启动](https://itsfoss.com/virtualbox-boot-from-usb/) 的详细指南：



> 
> **[如何在 VirtualBox 中从 USB 驱动器启动](https://itsfoss.com/virtualbox-boot-from-usb/)**
> 
> 
> 


我希望本指南对你有所帮助。


*（题图：MJ/d9a1b4b5-30ec-4019-979f-b258a1fc075f）*




---


via: <https://itsfoss.com/virtualbox-access-usb/>


作者：[Sagar Sharma](https://itsfoss.com/author/sagar/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

When you plug in a USB, your host OS can easily access it and use the files on it. That's not a surprise.

If you are using virtual machines with Virtual Box on Linux, you can put some effort and access the USB plugged in to your physical machine from the VM.

Let me walk you through step-by-step how you can access a USB disk in VirtualBox VM.

## How to access a USB drive in VirtualBox VM

By default, you can not use VirtualBox to access the USB drive as you have to install the extension pack manager and additionally, a little configuration part is also there.

This is the reason why I've divided this tutorial into three easy steps. So let's start with the first one.

### Step 1: Install the VirtualBox extension pack (on host)

This is the most important step of this tutorial as you are about to install an extension of VirtualBox which will enable you to use a USB drive in a VM.

To install the VirtualBox extension pack, simply visit the [official download page of VirtualBox](https://www.virtualbox.org/wiki/Downloads), scroll down a bit and there you will find an option to download the extension pack:

![download VirtualBox extension pack](https://itsfoss.com/content/images/2023/09/download-VirtualBox-extension-pack.png)

Once you are done downloading the extension pack follow 3 simple steps:

- Go to
`File`

>`Tools`

>`Extension Pack Manager`

- Hit the
`Install`

button - Select the downloaded file from the file manager:

![](https://itsfoss.com/content/images/2023/09/Install-VirtualBox-extension-pack-to-use-USB-in-VM.png)

It will open a new prompt to install the extension pack where all you have to do is hit the Install button and accept the terms and conditions:

![](https://itsfoss.com/content/images/2023/09/Install-VirtualBox-extension-pack.png)

And we are done with the installation of the extension pack.

### Step 2: Add the user to the vboxusers group (on host)

To use a USB drive in VirtualBox, your current user needs to be in the `vboxusers`

group.

I know it sounds a little complex but[ adding a user to the group](https://learnubuntu.com/add-user-group/) is one command process and to add your user to `vboxusers group can be done by following:

`sudo usermod -aG vboxusers $USER`


**Once you are done with these two steps, reboot your system to take effect from the steps.**

**Step 3: Add USB drive to VM **

To add USB for VM, you have to follow the given simple steps:

- Select the VM on which you want to use USB and hit
`Settings`

- Go to
`USB`

tab - Check the
`Enable USB Controller`

box and select the USB by clicking on`+`

button:

![Enable USB drive for VM in VirtualBox](https://itsfoss.com/content/images/2023/09/Enable-USB-drive-for-VM-in-VirtualBox.png)

And that's it! Now you can start your VM and the USB drive should reflect in the file manager. In my case it was Ubuntu, so it looked like this:

![Use USB drive in VirtualBox VM](https://itsfoss.com/content/images/2023/09/Use-USB-drive-in-VirtualBox-VM-1.png)

## More USB and VM trick

If using USB in a VM looks cool to you, booting from it in the VM is even cooler! And here's a detailed guide on [how to boot from a USB drive in VirtualBox](https://itsfoss.com/virtualbox-boot-from-usb/):

[Boot From a USB Drive in VirtualBox in LinuxYou can use a live Linux USB with virtual machines in VirtualBox. It saves you the annoyance of rebooting your host machine.](https://itsfoss.com/virtualbox-boot-from-usb/)![](https://itsfoss.com/content/images/2023/09/boot-from-usb-in-vbox.png)


![](https://itsfoss.com/content/images/2023/09/boot-from-usb-in-vbox.png)

I hope you will find this guide helpful.