D
D
devalone2019-02-04 00:52:17
linux
devalone, 2019-02-04 00:52:17

How to mount device in lxc without reboot?

I created a container for esp32 programming and for this I wrote in the config:

lxc.mount.entry = /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file

everything works, but when I pull out and insert the board, ttyUSB0 is no longer available from lxc. Is there a way to somehow solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
latush, 2019-02-04
@latush

lxc-device seems to be designed for this

D
devalone, 2019-02-05
@devalone

By trial and error, inspired by this manual https://discuss.linuxcontainers.org/t/live-usb-mou... found a solution. Xs, how it works, but it works:
create a dev directory in the hamster (you can in another place):
write in the container config:
where lxcuser is the user under which lxc is run
Create a symbol file with the command:
Update the device with the command:

sudo umount /home/lxcuser/dev/ttyUSB0 && \
        sudo mount --bind /dev/ttyUSB0 /home/lxcuser/dev/ttyUSB0 && \
        sudo chmod 666 /home/lxcuser/dev/ttyUSB0

Update every time you connect a new device.
Available from container at /mnt/dev/ttyUSB0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question