Mount DVD drive inside unpriviledged container not working


I’m currently using LXD containers for running Wine and games inside, thanks to great tutorials from Simos Xenitellis.
However there’s one issue I’m stuck with. I cannot mount a DVD inside the container (ubuntu 18.04 based). The host is also ubuntu 18.04 desktop.

It works if I set the container in privileged mode, but I would like to get access from unprivileged one.

lxc config device add ubuntu1804 cdrom unix-block source=/dev/sr0 path=/dev/sr0

sudo ls -la /var/lib/lxd/storage-pools/lxd-zfs/containers/ubuntu1804
total 16
drwxr-xr-x+  4 231072 231072    6 déc.  27 11:15 .
drwx--x--x   3 root   root   4096 déc.  27 11:15 ..
-r--------   1 root   root   4567 mars  28 21:46 backup.yaml
-rw-r--r--   1 root   root   1048 déc.   6 18:05 metadata.yaml
drwxr-xr-x  22 231072 231072   22 févr. 11 15:17 rootfs
drwxr-xr-x   2 root   root      7 déc.   6 18:05 templates

sudo setfacl -m u:231072:rwx /dev/sr0

# file: dev/sr0
# owner: root
# group: cdrom

Inside container:
sudo mount /dev/sr0 /mnt
mount: /mnt: permission denied.

No related messages in dmesg or /var/log/syslog

Any help would be appreciated !! Thanks :slight_smile:

Normal containers are not allowed to “mount” anything. You rather mount it in the host and add the mountpoint as a “disk” device.

err, how about this:

IMO, it should work. But it does not, tried it myself with host 18.04/container 18.04 and host 16.04 / host 18.04 or 16.04 all with snap 3.11 (The OP did not say what is used but from the id used it’s probably snap too)

In the howto he is adding a device of type USB not unix-block

@XuRuHang, is there a requirement for the container to mount the physical Unix block device? Such as due to some copy-protection restriction in the game? Or, you want to just access some game assets?

The full documentation of the LXD disk device is at There are a few extra parameters to the lxc config device add ... disk line, such as the propagation parameter.

1 Like

yes exactly I would like to access optical drives in a more convenient way, both for copy protection (despite Wine is not dealing with all types, some are well managed) and also to access assets on the disk required by some games, or even during game installation.

I will dig in the documentation links sent, and will let you know

Thanks a lot!

I’m giving an update on this topic
Well I first tried to use “propagation” option for lxc config device but seems not working in my ubuntu 18.04 (LXD 3.0.3):
Invalid device configuration key for disk: propagation

I got more or less some success by following these steps:

  1. load the cdrom on drive
  2. unmount on host (was automounted)
  3. type:
    lxc config device add ubuntu1804 cdrom disk readonly=true source=/dev/sr0 path=/mnt/cdrom

then I was able to use the cdrom inside my container ubuntu1804

For changing CD, typed:
lxc config device remove ubuntu1804 cdrom
Then did steps 1 to 3 again with another CD

Works but not exactly as I wanted by giving full control inside the container : load cdrom in drive, then just mount it inside the container

Containers cannot mount anything, even a simple .img file.

You could write an udev rule that add/removes the device from the container when needed.