Cleanest way to mount folder from host to container rw

I had the same problem.

The solution is shiftfs:

  1. Check wether your kernel includes shiftfs (to my knowledge only ubuntu’s kernel does).
    You can check that with:

modinfo shiftfs

1.a) If your kernel does not include it, you can use dkms to install shiftfs:

I created a github repo with scripts to install shiftfs via dkms:

  1. Activate it within lxd:
    Excerpt from comment by stgraber:
  • sudo snap set lxd shiftfs.enable=true
  • sudo systemctl reload snap.lxd.daemon

Check whether it is activated:

  • lxc info

And should see:

    shiftfs: "true"
  1. To use it with your container, you just need to add “shift: true” to your disk device.
    For example:
    folder1:
    path: /home/user1/folder1
    source: /home/hostuser1/folder1
    shift: true
    type: disk

And it should work.

Edit: Added my github repo.