macdaddybighorn

NFS in LXC

Mar 21st, 2024
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ***On the Host, perform the following to set up apparmor profile allowing NFS in an LXC***
  2. nano /etc/apparmor.d/lxc/lxc-default-with-nfs
  3. # Paste this all in the file
  4.  
  5. # Do not load this file. Rather, load /etc/apparmor.d/lxc-containers, which
  6. # will source all profiles under /etc/apparmor.d/lxc
  7.  
  8. profile lxc-container-default-with-nfs flags=(attach_disconnected,mediate_deleted) { #include <abstractions/lxc/container-base>
  9.  
  10. # allow NFS (nfs/nfs4) mounts.
  11. mount fstype=nfs*,
  12. mount fstype=rpc_pipefs,
  13. }
  14.  
  15. apparmor_parser -r /etc/apparmor.d/lxc-containers
  16.  
  17. [Build container, privileged and NFS flags, Debian 12, specify network interface and IP]
  18.  
  19. Add the following to LXC configuration file (nano /etc/pve/lxc/100.conf) to bind mount folder (if desired)
  20. lxc.mount.entry: /path/to/host/folder path/to/lxc/folder none bind 0 0
  21. lxc.apparmor.profile: lxc-container-default-with-nfs
  22.  
  23. [start the LXC]
  24.  
  25. ***Inside the LXC, perform the following***
  26. systmctl mask system-logind #only do this if there is a delay in the LXC after logging in
  27. apt update && apt upgrade
  28. apt install nfs-common nfs-kernel-server unattended-upgrades
  29. nano /etc/exports
  30. [update with folders you want to share]
  31. exportfs -rv
  32.  
Advertisement
Add Comment
Please, Sign In to add comment