Difference between revisions of "USB Devices"
From Linux-VServer
(→Unhide the `/proc/bus/usb` directory) |
|||
(9 intermediate revisions by 6 users not shown) | |||
Line 20: | Line 20: | ||
</pre> | </pre> | ||
− | + | :''Note'' this is a bit of brute force. It enables ''all'' guests to see USB (assuming they have the right `fstab` entry, below, and doesn't turn it off. If you want to be more fancy, you can probably rehide the USB when the guest is shut down. However, this will break if you have more than once guest using USB | |
− | + | ||
− | + | ||
== Mount the USB filesystem in the guest == | == Mount the USB filesystem in the guest == | ||
Line 41: | Line 39: | ||
Now enter the guest, and see if you can see `/proc/bus/usb/devices`. Better still, plug in a USB device and see if it shows up in there. | Now enter the guest, and see if you can see `/proc/bus/usb/devices`. Better still, plug in a USB device and see if it shows up in there. | ||
+ | |||
+ | == Declare USB tree in UBUNTU Lucid Lynx == | ||
+ | |||
+ | On the new Ubuntu (10.04), /proc/bus/usb does no longer exist. Here is a solution to declare the USB tree : | ||
+ | |||
+ | <pre> | ||
+ | mkdir -p /vservers/<guest>/dev/bus/usb | ||
+ | echo "/dev/bus/usb /dev/bus/usb ext3 rbind 0 0" >> /etc/vservers/<guest>/fstab | ||
+ | </pre> | ||
+ | |||
+ | == Thanks == | ||
+ | |||
+ | Information came from [http://www.paul.sladen.org/vserver/archives/200610/0053.html this thread] (credit: Daniel Hokka Zakrisson) and from followup in IRC on 21 April 2007, again credit to Daniel. | ||
+ | |||
+ | [[Category:Documentation]] |
Latest revision as of 20:43, 21 October 2011
By default, USB devices you plug in to your physical host are not available to your vserver guests. To make all your USB devices available to a specific guest, follow these instructions:
Contents |
[edit] Unhide the `/proc/bus/usb` directory
On the host, you can do one of the following:
To do it as a one-off, type the following as root:
vnamespace -n bash umount -n /proc/bus/usb setattr --~hide /proc/bus setattr --~hide /proc/bus/usb
- Note: this creates a new namespace and lauches bash in that context. It then umounts the USB filesystem and then unhides the USB subsystem. Note that this doesn't unmount USB for the host, or any existing guests, but the umount is necessary for the setattr to take effect.
To make this persist for a specific guest, add the following to `/etc/vservers/<guest>/scripts/pre-start`:
vnamespace -n bash -c "umount -n /proc/bus/usb ; setattr --~hide /proc/bus ; setattr --~hide /proc/bus/usb"
- Note this is a bit of brute force. It enables all guests to see USB (assuming they have the right `fstab` entry, below, and doesn't turn it off. If you want to be more fancy, you can probably rehide the USB when the guest is shut down. However, this will break if you have more than once guest using USB
[edit] Mount the USB filesystem in the guest
Now we edit the `fstab` file for the guest. The following works on a host running Debian Etch and a guest running Ubuntu 6.06.1. To find the way that `usbfs` is mounted in the host, I used:
cat /proc/mounts | grep usbfs
which returned:
usbfs /proc/bus/usb usbfs rw,nosuid,nodev,noexec 0 0
Paste this line (or the one that suits your distro) to the end of `/etc/vservers/<guest>/fstab`, and restart the guest.
[edit] Test it
Now enter the guest, and see if you can see `/proc/bus/usb/devices`. Better still, plug in a USB device and see if it shows up in there.
[edit] Declare USB tree in UBUNTU Lucid Lynx
On the new Ubuntu (10.04), /proc/bus/usb does no longer exist. Here is a solution to declare the USB tree :
mkdir -p /vservers/<guest>/dev/bus/usb echo "/dev/bus/usb /dev/bus/usb ext3 rbind 0 0" >> /etc/vservers/<guest>/fstab
[edit] Thanks
Information came from this thread (credit: Daniel Hokka Zakrisson) and from followup in IRC on 21 April 2007, again credit to Daniel.