Here I created a lxc container in the host operating system, Ubuntu 22.04, whose os is the same as the host's, on a Raspberry Pi.
I want to access(r/w) files of a usb disk in the lxc container so I try to mount the device into the container following the tutorials found in the internet including some answers of questions in Stackoverflow. Sadly, all of them failed.
Here are the datails.
This is the usb device:
Bus 001 Device 007: ID 14cd:1212 Super Top microSD card reader (SY-T18)
I have mounted it into the host system.
As what those tutorials say, I add two sentences into the config
of the instance of the lxc container as follows:
lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/007 dev/bus/usb/001/007 none bind,optional,create=dir
And this is the whole config
lxc.rootfs.path = dir:/dockers/regular/rootfs
lxc.uts.name = regular
lxc.arch = armhf
# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:61:b2:40
lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/007 dev/bus/usb/001/007 none bind,optional,create=dir
Then I start the container and check out /dev
, there is a directory /dev/bus/usb/001/007
(there's no such dir before I edit the config
).
However, in the lxc container I couldn't find the usb device in /dev
and it failed when I tried to mount the usb device via its name (like sda1
) or UIID.
It means the config editing worked that I can find the /dev/bus/usb/001/007
in the container. But still I can't access the usb device.