ProxMox Unprivileged LXC containers USB Drive


Some quick notes on bind mounting under ProxMox and getting the permissions right.


The following commands are run on the ProxMox host:

cat <<EOF >> /etc/pve/nodes/{node name}/lxc/{lxc number}.conf
mp0: /mnt/bindmounts/usb0,mp=/mnt/usb0
mp1: /mnt/bindmounts/usb1,mp=/mnt/usb1
lxc.idmap: u 0 100000 1005
lxc.idmap: g 0 100000 1005
lxc.idmap: u 1005 1005 1
lxc.idmap: g 1005 1005 1
lxc.idmap: u 1006 101006 64530
lxc.idmap: g 1006 101006 64530
EOF

echo "root:1005:1" >> /etc/subuid
echo "root:1005:1" >> /etc/subgid

chown -R 1005:1005 /mnt/bindmounts/usb0
chown -R 1005:1005 /mnt/bindmounts/usb1

mount /dev/usb0 /mnt/bindmounts/usb0 -o umask=0777,uid=1005,gid=1005
mount /dev/usb1 /mnt/bindmounts/usb1 -o umask=0777,uid=1005,gid=1005

Popular Posts