Skip to content

Instantly share code, notes, and snippets.

@surajRathi
Last active May 9, 2024 20:44
Show Gist options
  • Save surajRathi/1404cbbdeaa5a46c352c95b9512f6a09 to your computer and use it in GitHub Desktop.
Save surajRathi/1404cbbdeaa5a46c352c95b9512f6a09 to your computer and use it in GitHub Desktop.

To use devices inside your nspawn container do:

Edit systemd-nspawn@<machine_name>.service and add a line like the below

DeviceAllow="/dev/serial/by-id/usb-Roboteq_Motor_Controller_SDC2XXX-if00 rwm"
DeviceAllow=char-ttyACM rwm
DeviceAllow=char-usb_device rwm
DeviceAllow=ttyACM rwm

To see valid device types do:

cat /proc/devices

Then bind mount the device:

sudo machinectl bind --mkdir <machine_name> /dev/serial/by-id/usb-Roboteq_Motor_Controller_SDC2XXX-if00

See man systemd.resource-control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment