分享

VirtualBox使用U盘 - Linux - yorks天地

 不打酱油 2010-09-27

VirtualBox使用U盘

找工作回来,电脑交换给同乡使用。电脑出现了问题,然后他就重新安装了,不知道怎么回事,连我Linux下的分区都搞坏了,只好重新安装系统。还好偶原来一般安装软件都在一个独立的分区,重新安装的软件 不多,只有几个,VirtualbBox就是其中一个。

下载安装好最新的http://download./virtualbox/3.1.6/VirtualBox-3.1.6-59338-Linux_x86.run后, 发现在guest里面用不了U盘。怎么解决呢?

一、想起了VirtualBox安 装目录下有一个UserManual.pdf的使用手册,便查看关于USB的相关设置


 

11.5.7 USB not working

If USB is not working on your Linux host, make sure that the current user is a member

of the vboxusers group. On older hosts, you need to make sure that the user has

permission to access the USB ?lesystem (usbfs), which VirtualBox relies on to retrieve

valid information about your host’s USB devices. The rest of this section only applies

to those older systems.

Note: The current rdesktop-vrdp implementation does not support accessing

USB devices through the sysfs!

As usbfs is a virtual ?lesystem, a chmod on /proc/bus/usb has no effect. The

permissions for usbfs can therefore only be changed by editing the /etc/fstab ?le.

For example, most Linux distributions have a user group called usb or similar, of

which the current user must be a member. To give all users of that group access to

usbfs, make sure the following line is present:

# 85 is the USB group

none /proc/bus/usb usbfs devgid=85,devmode=664 0 0

Replace 85 with the group ID that matches your system (search /etc/group for “usb”

or similar). Alternatively, if you don’t mind the security hole, give all users access to

USB by changing “664” to “666”.

The various distributions are very creative from which script the usbfs ?lesys-

tem is mounted. Sometimes the command is hidden in unexpected places.

For SuSE 10.0 the mount command is part of the udev con?guration ?le

/etc/udev/rules.d/50-udev.rules. As this distribution has no user group called

usb, you may e.g. use the vboxusers group which was created by the VirtualBox

installer. Since group numbers are allocated dynamically, the following example uses

85 as a placeholder. Modify the line containing (a linebreak has been inserted to

improve readability)

总的来说意思有如下几点:

  1. 确保正在使用VirtualBox的 用户是否为用户组vboxusers一员.

  2. 确保该用户是否有权限去读写usbfs这 个文件系统

  3. 修改/proc/bus/usb没 有效果,只能通过修改/etc/fstab文件。

  4. 修改/etc/fstab文 件,让USB用户组必须有权限去读写usbfs.加入:

    none /proc/bus/usb usbfs devgid=85,devmode=664 0 0

    其中devgid, 85USB用户组的iddevmode,664 为对usbfs 文件系统的权限664

  5. 如果系统没有usb用户组,那么你需要用vboxusers这个在安装VirtualBox的时候产生的用户组。

二、了解后,接着下一步:

2.1、添加当前用户为vboxusers一员

[root@localhost yorks]# cat /etc/group |grep vboxusers

vboxusers:x:501:

[root@localhost yorks]# /usr/sbin/usermod -G vboxusers -a yorks

[root@localhost yorks]# cat /etc/group |grep vboxusers

vboxusers:x:501:yorks


2.2、查看是否有USB的用户组

[root@localhost yorks]# cat /etc/group|grep usb

[root@localhost yorks]# cat /etc/group|grep USB

[root@localhost yorks]#

这里两个都没有,因为没有 任何东西输出。

2.3、修改/etc/fstab文件。

[root@localhost yorks]# echo "none /proc/bus/usb usbfs devgid=501,devmode=664 0 0" >> /etc/fstab

[root@localhost yorks]# tail -2 /etc/fstab

/dev/sda7 /home ext3 defaults 0 0

none /proc/bus/usb usbfs devgid=501,devmode=664 0 0

[root@localhost yorks]#

注意:501是在2.1查到的vboxusersid.

2.4、重新执行/etc/fstab的挂载操作。

[root@localhost yorks]# mount -a

mount: none already mounted or /proc/bus/usb busy

[root@localhost yorks]#

出错了。

2.5google: none /proc/bus/usb usbfs devgid=501,devmode=664 0 0,结果:

Fedora中 文论坛里面的说的。发现/proc/bus/usb/sys/bus/usb/drivers不同,于是就试着修改,/proc/bus/usb换成/sys/bus/usb/drivers

再次测试:

[root@localhost yorks]# mount -a

[root@localhost yorks]#

这次没有错误了。接着打开VirtualBox,出现了这个提示:

不鸟它。启动guest,插 上U盘,提示找到新硬件...OK啦。。享用吧

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多