Howto add disk to unprivileged container?

I want to share host directory with unprivileged container but nothing show in container

lxc config device add container_name share_name disk source=/mnt/tmp path=/mnt/tmp

but /mnt/tmp not show in container?
what am i doing wrong?

I have

No such file or directory - Could not create shmounts temporary dir

in lxc.log for container


I cannot reproduce on Ubuntu 20.04 and LXD 3.23.

It has been reported at Can you check whether a restart of the container is able to show /mnt/tmp?

According to the code, LXD tries to create a temporary file in the mounted point, and fails if it is read-only. My cursory look into the code does not show why there should be a temporary file in there.
For testing purposes, can you

  1. Run first sudo chmod 777 /mnt/tmp/
  2. Create a new container as usual, then add the disk device
  3. Report if it worked this time.

You might be able to bypass this issue if you add more parameters to the disk device, per

I use Ubuntu 18.04 and LXD 3.23
container is unprivileged
some idmap config for container

volatile.idmap.base: “0”
volatile.idmap.current: ‘[{“Isuid”:true,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’ ‘[{“Isuid”:true,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.idmap: ‘[{“Isuid”:true,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’

I used chmod 777
nothing changed