我试图在Vagrant (操作系统:Windows10)中使USB设备可见,这就是为什么我将这两行添加到Vagrant文件中
vb.customize ['modifyvm', :id, '--usb', 'on']
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
vb.gui = true
# # Configure dongle
vb.customize ['modifyvm', :id, '--usb', 'on']
vb.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'VC', '--vendorid', '0x046E', '--productid', '0x0001']结束
但是当我使用vagrant up时,我看不到这个USB设备。它在VirtualBox设备管理器中标记为未知设备。设备在本地PC上可见,有时会在执行几个vagrant reload命令后变为可见。
发布于 2016-08-23 19:56:48
我找到了一个解决方案。这是一个简短的PowerShell脚本,它是基于使用devcon工具的。
# Set location where devcon tool is placed
Set-Location "D:\MSSDK\Tools\x64"
# Disconnect USB from host machine
.\devcon.exe remove *VID_096E*
# Reconect USB to virtual machine
.\devcon.exe rescandevcon.exe是MS工具包的一部分。即使没有物理断开,您也可以移除和连接任何USB设备。在USB从主机断开后,我做了重新扫描,并且在VirtualBox中可以看到USB设备。
发布于 2016-08-18 17:22:41
这可以通过VirtualBox设置-> USB -> USB设备筛选器或通过Vagrantfile定义属性来完成。
user允许用户通过VirtualBox扩展包访问user,该扩展包实现了主机和来宾机器之间的usermod集成。
在使用vagrant up启动虚拟机之前,请运行以下命令:
# You need the virtualbox-extensions package to enable USB
sudo apt install virtualbox-ext-pack # accept the license to install
# add host user to 'vboxusers' group
sudo usermod -a -G vboxusers $USER
# You will need to logout and back in or reboot to get access to USB
# Make sure you have the stuff below in your Vagrantfile, then:
vagrant up注意:- $USER应解析为主机上的当前用户。
在为Vagrantfile中的USB集成定义属性之前,您应该运行VBoxManage来帮助您获取当前安装在主机上的USB信息:
sudo VBoxManage list usbhost
[sudo] password for rohan:
Host USB Devices:
UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
VendorId: 0x0781 (0781)
ProductId: 0x5575 (5575)
Revision: 1.39 (0139)
Port: 0
USB version/speed: 2/2
Manufacturer: SanDisk
Product: Cruzer Glide
SerialNumber: xxxxxxxxxxxxxxxxxxxx
Address: sysfs:/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1//device:/dev/vboxusb/001/011
Current State: Busy # Enable USB Controller on VirtualBox
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--usb", "on"]
vb.customize ["modifyvm", :id, "--usbehci", "on"]
end
# Implement determined configuration attributes
config.vm.provider "virtualbox" do |vb|
vb.customize ["usbfilter", "add", "0",
"--target", :id,
"--name", "Any Cruzer Glide",
"--product", "Cruzer Glide"]
end如果需要对属性进行更多结果或任何修改,则根据VBoxManage在config.vm.provider中添加值
以下是可针对usbfilter定义的属性
usbfilter add <index,0-N>
--target <uuid|vmname>|global
--name <string>
--action ignore|hold (global filters only)
[--active yes|no] (yes)
[--vendorid <XXXX>] (null)
[--productid <XXXX>] (null)
[--revision <IIFF>] (null)
[--manufacturer <string>] (null)
[--product <string>] (null)
[--remote yes|no] (null, VM filters only)
[--serialnumber <string>] (null)
[--maskedinterfaces <XXXXXXXX>]在上面定义之后,可以将USB设备挂载到vagrant halt上的来宾计算机上,然后是vagrant up或vagrant provision,最后是vagrant reload。
备注:由于USB设备可能会随时间而变化,因此很难提前预测应该在Vagrantfile中定义哪个设备。因此,通过USB (设置> USB > VirtualBox设备筛选器)定义USB比上述Vagrantfile实现更可取。
https://stackoverflow.com/questions/38956127
复制相似问题