[Solved]: USB Automount
[Solved]: USB Automount
VirtualBox: 1.6.2
Host: Ubuntu Hardy 8.04 i386
Guests: Windows XP, Windows 2003 Server
I've hit a wall and hope someone can help. I'm sure (if memory serves me) that I used to be able to setup a guest with a 'default' usb filter (ie match everything) and when it boots I could just plug in any usb device and it is automatically seen by the guest. I'm reasonably certain I used to be able to do that in 1.5.6.
Running now with 1.6.2, this does not work. If I plug in a USB device to the host and issue a "VBoxManage list usbhost", it simply returns the devices with a "Current Status: Busy".
If I run under 'VirtualBox' GUI, and then select the device from the menu, it will capture it, and will show "Current Status: Captured"
Is there anyway to have the guest automatically capture the device?
Failing that, I've not yet worked out how one is able to 'trigger' a capture through VBoxSDL. There doesn't seem to be a host-key shortcut unless I'm missing something? Does that mean using VBoxSDL its impossible to use USB?
Brendan
Host: Ubuntu Hardy 8.04 i386
Guests: Windows XP, Windows 2003 Server
I've hit a wall and hope someone can help. I'm sure (if memory serves me) that I used to be able to setup a guest with a 'default' usb filter (ie match everything) and when it boots I could just plug in any usb device and it is automatically seen by the guest. I'm reasonably certain I used to be able to do that in 1.5.6.
Running now with 1.6.2, this does not work. If I plug in a USB device to the host and issue a "VBoxManage list usbhost", it simply returns the devices with a "Current Status: Busy".
If I run under 'VirtualBox' GUI, and then select the device from the menu, it will capture it, and will show "Current Status: Captured"
Is there anyway to have the guest automatically capture the device?
Failing that, I've not yet worked out how one is able to 'trigger' a capture through VBoxSDL. There doesn't seem to be a host-key shortcut unless I'm missing something? Does that mean using VBoxSDL its impossible to use USB?
Brendan
Last edited by bundabrg on 27. Jul 2008, 04:41, edited 1 time in total.
-
- Posts: 10
- Joined: 26. Jul 2008, 14:13
I write udev rules to do that, see below. Hope it is helpful to you.
you may need to modify the script a bit for your case. --brandon
Here's
you may need to modify the script a bit for your case. --brandon
Here's
- DRIVERS=="usb-storage",IMPORT{program}="usb_id --num-info --export %p", RUN+="/etc/udev/vboxusb.sh"
Code: Select all
#!/bin/sh
attach_storage()
{
set `/sbin/lsusb -d ${ID_VENDOR}:${ID_MODEL}| sed 's/:.*//g'`
while [ ! -z "$1" ]; do
case $1 in
Bus) shift
address="/proc/bus/usb/$1"
;;
Device) shift
address=${address}"/$1"
;;
esac
shift
done
if [ ! -z "$address" ]; then
su - root -c "VBoxManage controlvm winxp usbattach"
fi
}
case $DEVNAME in
/dev/sd[a-z])
attach_storage;
;;
esac
USB Automount
Im a bit confused on what to do with this. I have created the .sh file with the code provided and put it in the udev folder, but I am not sure what to do with the line
DRIVERS=="usb-storage",IMPORT{program}="usb_id --num-info --export %p", RUN+="/etc/udev/vboxusb.sh"
Do I use this to call the vboxusb.sh file, put it in the file or is there somewhere to put it in the system?
This is pretty new to me but if I can get this working I will have very happy clients so hopefully someone will beable to help me .
Thanks in advance!!
Tave
DRIVERS=="usb-storage",IMPORT{program}="usb_id --num-info --export %p", RUN+="/etc/udev/vboxusb.sh"
Do I use this to call the vboxusb.sh file, put it in the file or is there somewhere to put it in the system?
This is pretty new to me but if I can get this working I will have very happy clients so hopefully someone will beable to help me .
Thanks in advance!!
Tave
Ok, so I know how to call an sh file now.
In the command line I type "sh vboxusb.sh" to call the sh file but it still doesn't work?
Im still unsure what to do with this line.
If anyone can help I would be really appreciate it!
In the command line I type "sh vboxusb.sh" to call the sh file but it still doesn't work?
Im still unsure what to do with this line.
I have this in the file vboxusb.shDRIVERS=="usb-storage",IMPORT{program}="usb_id --num-info --export %p", RUN+="/etc/udev/vboxusb.sh"
Code: Select all
#!/bin/sh
attach_storage()
{
set `/sbin/lsusb -d ${ID_VENDOR}:${ID_MODEL}| sed 's/:.*//g'`
while [ ! -z "$1" ]; do
case $1 in
Bus) shift
address="/proc/bus/usb/$1"
;;
Device) shift
address=${address}"/$1"
;;
esac
shift
done
if [ ! -z "$address" ]; then
su - root -c "VBoxManage controlvm winxp usbattach"
fi
}
case $DEVNAME in
/dev/sd[a-z])
attach_storage;
;;
esac
-
- Posts: 4
- Joined: 19. Jul 2009, 23:59
- Primary OS: Ubuntu other
- VBox Version: OSE Debian
- Guest OSses: Vista, XP
Re: [Solved]: USB Automount
Late, but this helped me, so someone else might read it...
You'll want to put that line in a file in /etc/udev/rules.d/. Call the file whatever you please, as long as it's beginning with a number (if you're unsure which, 30 should work, check the README that should be in that directory for more info) and has extension .rules. I don't think the permissions matter.
You'll want to put that line in a file in /etc/udev/rules.d/. Call the file whatever you please, as long as it's beginning with a number (if you're unsure which, 30 should work, check the README that should be in that directory for more info) and has extension .rules. I don't think the permissions matter.
Re: [Solved]: USB Automount
To make it work I had to change a few lines:
Obviously you have to replace user_name with yours as well as vm_name.
Code: Select all
#!/bin/bash
attach_storage()
{
set `lsusb -d ${ID_VENDOR_ID}:${ID_MODEL_ID}| sed 's/:.*//g'`
while [ ! -z "$1" ]; do
case $1 in
Bus) shift
busdevice="$1"
;;
Device) shift
busdevice=${busdevice}"/$1"
;;
esac
shift
done
if [ ! -z "$busdevice" ]; then
address=$(VBoxManage list usbhost | grep "Address:" | grep $busdevice | sed -e 's/Address://' -e 's/^[ \t]*//')
if [ ! -z "$address" ]; then
su user_name -c "VBoxManage controlvm vm_name usbattach $address"
fi
fi
}
case $DEVNAME in
/dev/sd[a-z])
attach_storage;
;;
esac