[Lxc-users] usb devices

Toby Corkindale toby.corkindale at strategicdata.com.au
Tue Aug 3 01:07:31 UTC 2010


On 03/08/10 09:04, Nirmal Guhan wrote:
> Hi,
>
> Am running fedora 12 with 2.6.32.10-90.fc12.i686 kernel. Currently I
> use bind mount to access usb disks. For instance :
>
> /media /lxc/f12/usbdisk none bind 0 0
>
> udev mounts usb devices on /media. There are some issues with this approach :
>
> 1) Since this is hard coded config, it has to be updated everytime the
> mount point (/media in this case) changes.
> 2) If I unmount /media from the host, the container can still access
> the disk from /usbdisk i.e ls /usbdisk and other operations work
> within container but not /media from the host. How is this possible ?
> 3)  By #2, I assume there is some sort of usb pass-through within
> container? Is this true ?

No, it's not true. There is no special USB pass-thru to the container.

By making a bind-mount, you are replicating part of the filesystem so 
that it is inside the bit of the filesystem that LXC is using.
This is done at the filesystem level - not at the USB level.

This explains why you can still access it after unmounting at the host 
level. You have effectively mounted it twice, so it needs to be 
unmounted from both locations too.

> 4) Hot swap does not work within the container. After usb device is
> reinserted, container cannot recognize it but host can.
> 5) "mount" within the container  always displays just one single line
> while I have few more in fstab including the above /media stuff.
>       none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

Again, that's because of the way LXC works with the filesystem.

Perhaps you could just bind-mount the whole /media directory into the 
guest containers, to their /media directory? That might work better for 
you, although still not quite what you want.


-Toby




More information about the lxc-users mailing list