Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Do I rightly understand that USB was not working with VirtualBox until you had the devgid=102,devmode=664 usbfs line in fstab nd not the other usbfs line?
Yup, you got it.
Slackware 13.0 (which is in many, many ways different that Slackware 12.2 and previous releases) uses UDEV and HAL to automagically mount devices (as I understand it; could be wrong about that); you plug in a flash drive, it is seen, it mounts (if you're a member of the plugdev group (which is 83), the Device Notifier pops up, you click it and there your go. On my system, vboxusers is group 102. Again, I'm not all that sure that I completely understand all of it, but that's what I think happens. Without that /etc/fstab entry, a guest operation system cannot see the flash dive (VirtualBox does see it, recognizes what it is, but does not pass that along to a guest operating system).
And, of course, with that /etc/fstab entry, the automagic mount no long happens so I have to figure out some way to manually mount the thing without VirtualBox running, write to or read from, unmount, start VirtualBox and use the flash drive. Neat, eh? I'm not thrilled with the way this works, but it does work and, for now, that's good enough to get done what I have to.
BTW, before I added my user account to the vboxusers group, everything worked in virtualbox EXCEPT for USB devices. After just that one minor change, which had to be done manually, USB devices are accessible in the virtual machines. I find it odd that everything else worked just fine without the user being added to that group. One would think that there would be just a few other permissions needed to run VMs on a workstation, hence the necessity of a vboxusers group. Just my $.02.
BTW, before I added my user account to the vboxusers group, everything worked in virtualbox EXCEPT for USB devices. After just that one minor change, which had to be done manually, USB devices are accessible in the virtual machines. I find it odd that everything else worked just fine without the user being added to that group. One would think that there would be just a few other permissions needed to run VMs on a workstation, hence the necessity of a vboxusers group. Just my $.02.
Given that VirtualBox comprises kernel modules and some setuid-root executables:
And, of course, with that /etc/fstab entry, the automagic mount no long happens so I have to figure out some way to manually mount the thing without VirtualBox running, write to or read from, unmount, start VirtualBox and use the flash drive. Neat, eh? I'm not thrilled with the way this works, but it does work and, for now, that's good enough to get done what I have to.
Which group's GID have you got in the usbfs' devgid? I am running Slackware 13.0 and VBox 3.0.6; with the plugdev GID configured in the devigid, when a USB memory stick is inserted Slackware mounts it and opens a Thunar window showing its contents. When I use a VM's window's Devices->"USB Devices" menu to list the USB devices and click in the device's box, it is unmounted on the host and available to the VM. When I clear the device's box, releasing the device from the VM, the device is mounted on the host and a Thunar window again opened. Is that what you would like to happen?
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Which group's GID have you got in the usbfs' devgid? I am running Slackware 13.0 and VBox 3.0.6; with the plugdev GID configured in the devigid, when a USB memory stick is inserted Slackware mounts it and opens a Thunar window showing its contents. When I use a VM's window's Devices->"USB Devices" menu to list the USB devices and click in the device's box, it is unmounted on the host and available to the VM. When I clear the device's box, releasing the device from the VM, the device is mounted on the host and a Thunar window again opened. Is that what you would like to happen?
Oh, yeah, that's what I would like to happen, only thing is, I can't figure out how to do it. If I have this in /etc/fstab,
a flash drive does not mount but WinXP in VirtualBox can see and access it (the GID, 102, is the group id for vboxusers). Other than that line, there isn't anything in /etc/fstab about USB. Have I missed something somewhere?
If I have this entry in /etc/fstab in addition to the one above, I can't see the flash drive in either the Slackware side or the VirtualBox side
Code:
usbfs /proc/bus/usb usbfs auto 0 0
Must have missed something somewhere in my basic education, methinks.
Change 102 to the number of the plugdev group (83?) and make sure the VBox user is in the plugdev group (and, if you have to add the user to the plugdev group, log out and back in).
Sasquatch replied (I don't think he ever sleeps and always gives great advice). Here's what he wrote:
Quote:
Originally Posted by Sasquatch
Newer distributions no longer support the method that was used since 1.5 or somewhere near that. It was on /proc/bus/usb, but is now obsolete. Instead of that, some udev rules are created when you install VB (PUEL only, OSE doesn't support USB). In the rules is noted that the group vboxusers has access to USB. This is the rule:
Sure enough, there is a /etc/udev/rules.d/10-vboxdrv.rules file on my Slackware 13.0 system running VirtualBox 3.0.6 PUEL containing exactly those lines.
I'll comment out the fstab line for usbfs, see if VBox/USB is still working after the next reboot and report back.
tronayne, your USB wasn't working until you had the usbfs line in fstab; do you have /etc/udev/rules.d/10-vboxdrv.rules as above and were you in the vboxusers group?
Dang -- could have sworn I tried that once and got nowhere (I've had all user id's in plugdev since installation).
Ah, those senior moments! I've just spent 30 minutes trying to find out why xarchiver didn't work only to find I'd done all the build, even saved the SBo.tgz file for next time, but forgot to run installpkg
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Ah, those senior moments! I've just spent 30 minutes trying to find out why xarchiver didn't work only to find I'd done all the build, even saved the SBo.tgz file for next time, but forgot to run installpkg
Oh, yeah -- have a lot of those (I'm 65 and, trust me, the further you go the more you... what was I talking about?).
In /etc/usb/rules.d the file 10-vboxdrv.rules looks like this (believe that's the same as above):
That's the way it's been since the initial installation of VirtualBox (VirtualBox-3.0.8-53138-Linux_x86.run) -- and it never worked until that (apparently correct) entry in /etc/fstab.
I tried running this on SLED11 (SuSE Linux Enterprise Desktop) and get the following output:
Code:
golyaht@boaz:~/testing> ./virtualbox_usb.sh
VirtualBox PUEL version found. OK
Name of user used to run VirtualBox: golyaht
usbfs line found in /etc/fstab. OK.
Here is the usbfs line from /etc/fstab: usbfs /proc/bus/usb usbfs gid=500 0 0
ERROR: No devgid option on usbfs line in /etc/fstab
golyaht@boaz:~/testing>
Here's a new version of the script, modified to accept udev rules for VirtualBox or fstab usbfs
Code:
#! /bin/bash
# ck_vbox_USB.sh, a quick-and-dirty script to sanity-check host config for VirtualBox USB.
# Usage: no arguments or options
# Change history
# 18oct9 Charles
# * Added RPM enquiry (and skeleton dpkg enquiry).
# 20oct9 Charles
# * Added udev rules detection (fstab usbfs line no longer mandatory).
# * Added vboxdrv kernel module detection.
# * Added temporary file removal.
# Set up environment
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
set -o nounset
unset IFS
tmp_afn="$(mktemp "/tmp/$0.XXXXXX")"
[[ $? -ne 0 ]] && \echo "ERROR: unable to create temporary file (this is not a VirtualBox USB problem)" >&2 && \exit 1
trap "rm -f $tmp_afn" EXIT
# Set up line feed
lf=$'\n'
function ck_PUEL {
typeset msg OK_flag ERROR_flag
OK_flag='NO'
ERROR_flag='NO'
# Default (?) VBox config file
if [[ -r '/etc/vbox/vbox.cfg' ]]; then
. /etc/vbox/vbox.cfg
license_afn="$INSTALL_DIR/LICENSE"
if [[ -r "$license_afn" ]]; then
if grep 'PUEL' "$license_afn" > /dev/null ; then
OK_flag='YES'
else
ERROR_flag='YES'
fi
else
echo "WARNING: Could not read '$license_afn' identified by /etc/vbox/vbox.cfg" >&2
fi
fi
# RPM
if type rpm > /dev/null 2>&1 ; then
case "$( rpm -qi VirtualBox 2>&1 )" in
*PUEL* )
OK_flag='YES'
;;
*'is not installed'* )
;;
* )
ERROR_flag='YES'
esac
fi
# .deb
if type dpkg > /dev/null 2>&1 ; then
\echo 'WARNING: this script is not programmed for .deb package systems'
fi
# Report findings
if [[ "$OK_flag" = 'YES' ]]; then
\echo 'VirtualBox PUEL version found. OK'
if [[ "$ERROR_flag" = 'YES' ]]; then
\echo 'WARNING: VirtualBox non-PUEL version also found. ???' >&2
fi
elif [[ "$ERROR_flag" = 'YES' ]]; then
\echo 'ERROR: Installed VirtualBox is not the PUEL version so USB not supported' >&2 && \exit 1
else
\echo 'WARNING: unable to determine which version of VirtualBox, if any, is installed'
fi
} # ck_PUEL
# Check for VirtualBox PUEL version
ck_PUEL
# Get user name
while true
do
\echo -n 'Name of user used to run VirtualBox: '
read user
grep "^$user:" /etc/passwd > /dev/null && break
echo "User $user not found in /etc/passwd. Try again (or Ctrl+C to exit)"
done
# Is VirtualBox using udev rules?
vbox_udev_rules_afn='/etc/udev/rules.d/10-vboxdrv.rules'
if [[ -e "$vbox_udev_rules_afn" ]]; then
\echo "This computer has udev rules file for VirtualBox, $vbox_udev_rules_afn. OK"
# Get group and access mode
[[ ! -r "$vbox_udev_rules_afn" ]] && \echo "ERROR: $vbox_udev_rules_afn not readable by this script (OK for VirtualBox USB if readable by root)" >&2 && \exit 1
grep -E '^SUBSYSTEM=="(usb")|(usb_device")' "$vbox_udev_rules_afn" > "$tmp_afn"
while read line
do
IFS=','; array=($line); unset IFS
for ((i=1; i<${#array[*]}; i++))
do
field="${array[$i]}"
case "$field" in
*'GROUP="'* )
buf="${field#*GROUP=\"}"
buf="${buf%\"*}"
if [[ "${group:-}" = '' ]];then
group="$buf"
elif [[ "$buf" != "$group" ]]; then
\echo "WARNING: different groups ('$group' and '$buf') in $vbox_udev_rules_afn. Ignoring '$buf'"
fi
;;
*'MODE="'* )
buf="${field#*MODE=\"}"
buf="${buf%\"*}"
if [[ "${mode:-}" = '' ]];then
mode="$buf"
elif [[ "$buf" != "$mode" ]]; then
\echo "WARNING: different modes ('$mode' and '$buf') in $vbox_udev_rules_afn. Ignoring '$buf'"
fi
;;
esac
done
done < "$tmp_afn"
[[ "${group:-}" = '' ]] && \echo "ERROR: No group found for 'usb' or 'usb_device' in $vbox_udev_rules_afn" >&2 && \exit 1
[[ "${mode:-}" = '' ]] && \echo "ERROR: No mode found for 'usb' or 'usb_device' in $vbox_udev_rules_afn" >&2 && \exit 1
\echo "Group used for VirtualBox USB access is $group."
else
# No udev rues -- needs fstab with usbfs line
\echo "This computer does not have udev rules file for VirtualBox, $vbox_udev_rules_afn. Checking fstab"
grep -v '^#' /etc/fstab | grep usbfs > /"$tmp_afn"
while read line
do
[[ "${array:-}" != '' ]] && echo "WARNING: More than one usbfs line in /etc/fstab. Effect on VirtualBox unknown$lfHere is fstab:$lf$(cat /etc/fstab)" >&2 && break
\echo "usbfs line found in /etc/fstab. OK."
\echo "Here is the usbfs line from /etc/fstab: "$line
# Get GID and access mode
array=($line)
options="${array[3]}"
IFS=','; array=($options); unset IFS
for ((i=0; i<${#array[*]}; i++))
do
option="${array[$i]}"
case "$option" in
'devgid='* )
gid="${option#devgid=}"
;;
'devmode='* )
mode="${option#devmode=}"
;;
esac
done
[[ "${gid:-}" = '' ]] && \echo "ERROR: No devgid option on usbfs line in /etc/fstab" >&2 && \exit 1
[[ "${mode:-}" = '' ]] && \echo "ERROR: No devmode option on usbfs line in /etc/fstab" >&2 && \exit 1
done < "$tmp_afn"
[[ "${array:-}" = '' ]] && echo "ERROR: no usbfs line in /etc/fstab" >&2 && \exit 1
\echo "Group ID (GID) used for VirtualBox USB access is $gid."
fi
# Check group by name or ID
if [[ "${group:-}" != '' ]]; then
group_line="$(grep "^$group:" /etc/group)"
[[ "$group_line" = '' ]] && \echo "ERROR: group '$group' does not exist in /etc/group" >&2 && \exit 1
\echo "Group $group found in /etc/group. OK."
\echo "Here is group $group from /etc/group: $group_line"
else
group_line="$(grep "^[^:]*:[^:]*:$gid:" /etc/group)"
[[ "$group_line" = '' ]] && \echo "ERROR: GID $gid does not exist in /etc/group" >&2 && \exit 1
\echo "GID $gid found in /etc/group. OK."
\echo "Here is group $gid from /etc/group: $group_line"
fi
IFS=':'; array=($group_line)
group="${array[0]}"; gid="${array[2]}"
IFS=','; array=(${array[3]}); unset IFS
OK='no'
for ((i=0; i<${#array[*]}; i++))
do
user_in_group="${array[$i]}"
case "$user_in_group" in
"$user" )
OK='yes'
break
;;
esac
done
[[ "$OK" = 'no' ]] && \echo "ERROR: User ($user) is not in GID $gid" >&2 && \exit 1
\echo "User $user is in group $group with GID $gid. OK."
# Check access mode
# udev rules usually has 4 digits, fstab 3 digits. Assume it's OK for either to have 3-4 ...
\echo "Access mode used for VirtualBox USB access is $mode."
[[ "${#mode}" -lt 3 || "${#mode}" -gt 4 || "${mode//[0-9]/}" != '' ]] && \echo "ERROR: access mode ($mode) is not 3 to 4 integers" >&2 && \exit 1
group_mode="${mode:((${#mode} - 2)):1}"
let group_write=group_mode-4
[[ $group_write -lt 2 ]] && \echo "ERROR: access mode ($mode) does not include 'group write'" >&2 && \exit 1
\echo "Access mode ($mode) includes 'group write'. OK"
# Check kernel module vboxdrv loaded
if ! lsmod | grep '^vboxdrv' > /dev/null ; then
\echo "ERROR: kernel module vboxdrv not loaded" >&2 && \exit 1
else
\echo "Kernel module vboxdrv loaded. OK"
fi
\echo "All tests passed. OK. :-)"
exit 0
The script is evolving, thanks to people like you who are testing it on different platforms.
Turns out VirtualBox after version ~1.5 uses udev rules if available in which case there is no need for a usbfs line in fstab. I've just posted a new version of the script that takes account of that.
I don't know SLED11 or if it supports udev. Assuming it doesn't then you need to get the fstab usbfs line right. Yours looks OK except for the options column where you have gid=500. Usually it needs something like devgid=102,devmode=664. The 102 needs to be changed to the number of a group that the VirtualBox VM user is a member of. If SLED11 has a group for USB device users -- perhaps usbusers (on Slackware it's group plugdev) -- then that is the best choice. If not, use vboxusers. Check your /etc/group file for a list of group names and numbers (know as group IDs or GIDs).
I'll comment out the fstab line for usbfs, see if VBox/USB is still working after the next reboot and report back.
It's working fine with no usbfs line in fstab. But I know a defective fstab usbfs line will break VirtualBox USB. Presumably the fstab line overrides the udev rules. Time for another modification to the script.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.