个人工具

“UbuntuHelp:VirtualBox/USB”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(创建新页面为 '{{From|https://help.ubuntu.com/community/VirtualBox/USB}} {{Languages|UbuntuHelp:VirtualBox/USB}} To get USB support, you need the PUEL (non-free) version. Via the GUI, there i...')
 
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/VirtualBox/USB}}
 
{{From|https://help.ubuntu.com/community/VirtualBox/USB}}
 
{{Languages|UbuntuHelp:VirtualBox/USB}}
 
{{Languages|UbuntuHelp:VirtualBox/USB}}
 +
<<Include(Tag/ContentCleanup)>>
 +
== Set up USB for Virtualbox ==
 +
'''''Note: Only the non-free version has USB support at present.'''''
 +
=== For Jaunty ===
 +
From a terminal run these commands:
 +
<ol><li>Add yourself to the vboxusers group if not already there: -</li></ol>
 +
 +
<pre><nowiki>
 +
if [ "`grep vboxusers /etc/group|grep $USER`" == "" ] ; then sudo usermod -G vboxusers -a $USER ; fi
 +
</nowiki></pre>
 +
<ol><li>Enter a root shell, eg</li></ol>
 +
 +
<pre><nowiki>
 +
sudo -i
 +
</nowiki></pre>
 +
<ol><li>In that shell, set up /etc/fstab</li></ol>
 +
 +
<pre><nowiki>
 +
vGid="`grep vboxusers /etc/group|cut -d\: -f3`" # Determine the devgid for the vboxusers group
 +
if [ "$vGid" ] && [ "`grep usbfs /etc/fstab`" == "" ] ; then
 +
echo "none /proc/bus/usb usbfs devgid=${vGid},devmode=664 0 0" >>/etc/fstab
 +
mount -a
 +
fi
 +
</nowiki></pre>
 +
=== Pre-Jaunty ===
 
To get USB support, you need the PUEL (non-free) version.  Via the GUI, there is an option to enable USB.
 
To get USB support, you need the PUEL (non-free) version.  Via the GUI, there is an option to enable USB.
Furthermore, your user must be able to access /proc/bus/usb/*
 
 
Since Gutsy, /proc/bus/usb is not mounted by default. For '''Gutsy''' and '''Hardy''' you just need to edit /etc/init.d/mountdevsubfs.sh and uncomment the following lines:
 
Since Gutsy, /proc/bus/usb is not mounted by default. For '''Gutsy''' and '''Hardy''' you just need to edit /etc/init.d/mountdevsubfs.sh and uncomment the following lines:
 
<pre><nowiki>
 
<pre><nowiki>

2009年11月17日 (二) 21:05的版本

<<Include(Tag/ContentCleanup)>>

Set up USB for Virtualbox

Note: Only the non-free version has USB support at present.

For Jaunty

From a terminal run these commands:

  1. Add yourself to the vboxusers group if not already there: -
 if [ "`grep vboxusers /etc/group|grep $USER`" == "" ] ; then sudo usermod -G vboxusers -a $USER ; fi
 
  1. Enter a root shell, eg
 sudo -i
 
  1. In that shell, set up /etc/fstab
 vGid="`grep vboxusers /etc/group|cut -d\: -f3`" # Determine the devgid for the vboxusers group
 if [ "$vGid" ] && [ "`grep usbfs /etc/fstab`" == "" ] ; then
	echo "none /proc/bus/usb usbfs devgid=${vGid},devmode=664 0 0" >>/etc/fstab
	mount -a
 fi
 

Pre-Jaunty

To get USB support, you need the PUEL (non-free) version. Via the GUI, there is an option to enable USB. Since Gutsy, /proc/bus/usb is not mounted by default. For Gutsy and Hardy you just need to edit /etc/init.d/mountdevsubfs.sh and uncomment the following lines:

        #
        # Magic to make /proc/bus/usb work
        #
        mkdir -p /dev/bus/usb/.usbfs
        domount usbfs "" /dev/bus/usb/.usbfs -obusmode=0700,devmode=0600,listmode=0644
        ln -s .usbfs/devices /dev/bus/usb/devices
        mount --rbind /dev/bus/usb /proc/bus/usb

In Intrepid the lines required to mount usbfs have been removed entirely, so you need to add the following lines to /etc/init.d/mountdevsubfs.sh at the end of the do_start() function. Note that this is subtly different than the lines required for Gutsy/Hardy. the arguments for the domount function are slightly different from previous versions.

        #
        # Magic to make /proc/bus/usb work
        #
        mkdir -p /dev/bus/usb/.usbfs
        domount usbfs "" /dev/bus/usb/.usbfs usbfs -obusmode=0700,devmode=0600,listmode=0644
        ln -s .usbfs/devices /dev/bus/usb/devices
        mount --rbind /dev/bus/usb /proc/bus/usb

Then run the script that you just edited:

sudo /etc/init.d/mountdevsubfs.sh start

In order to give users in the vboxusers group write permissions to the devices in /proc/bus/usb, you'll need to edit some rules in /etc/udev/rules.d. Under Gutsy, edit /etc/udev/rules.d/40-permissions.rules to say the following:

# USB devices (usbfs replacement)
SUBSYSTEM=="usb_device",                MODE="0664", GROUP="vboxusers"

Under Hardy and Intrepid, edit /etc/udev/rules.d/40-basic-permissions.rules to say the following:

# USB devices (usbfs replacement)
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="vboxusers"
SUBSYSTEM=="usb_device",                MODE="0664", GROUP="vboxusers"

Then, restart the udev service:

sudo /etc/init.d/udev restart

Now, if you haven't done it already, make sure your user is part of the group vboxusers using the following command:

sudo usermod -G vboxusers -a `whoami`

Finally, log out and login again to apply these changes. See also: [1]