diff --git a/modules/docker/mount-data.nix b/modules/docker/mount-data.nix index b245a7a..c7677a5 100644 --- a/modules/docker/mount-data.nix +++ b/modules/docker/mount-data.nix @@ -1,5 +1,15 @@ { config, lib, pkgs, vars, ... }: +let + # `x-systemd.automount` never works inside a Linux container (LXC + # included, regardless of privilege) -- confirmed live on lxc-docker: + # systemd logs "Starting of .automount unsupported" for every + # share and never mounts them. Mount eagerly there instead, with + # `nofail` so a boot with the NFS server unreachable doesn't hang + # (the VM platforms rely on automount itself to get that same + # non-blocking behavior, so they don't need `nofail` too). + automountOpts = if config.boot.isContainer then [ "nofail" ] else [ "x-systemd.automount" ]; +in { fileSystems = { ${vars.nfsShares.dockerConfig.mountpoint} = { @@ -9,9 +19,8 @@ options = [ "nfsvers=4.2" "_netdev" - "x-systemd.automount" "noatime" - ]; + ] ++ automountOpts; }; ${vars.nfsShares.dockerDatabases.mountpoint} = { @@ -21,9 +30,8 @@ options = [ "nfsvers=4.2" "_netdev" - "x-systemd.automount" "noatime" - ]; + ] ++ automountOpts; }; ${vars.nfsShares.dockerVolumes.mountpoint} = { @@ -33,9 +41,8 @@ options = [ "nfsvers=4.2" "_netdev" - "x-systemd.automount" "noatime" - ]; + ] ++ automountOpts; }; ${vars.nfsShares.nextcloudData.mountpoint} = { @@ -45,9 +52,8 @@ options = [ "nfsvers=4.2" "_netdev" - "x-systemd.automount" "noatime" - ]; + ] ++ automountOpts; }; ${vars.nfsShares.raspiVolumes.mountpoint} = { @@ -57,9 +63,8 @@ options = [ "nfsvers=4.2" "_netdev" - "x-systemd.automount" "noatime" - ]; + ] ++ automountOpts; }; }; } diff --git a/modules/raspi/mount-data.nix b/modules/raspi/mount-data.nix index 857f255..47747bb 100644 --- a/modules/raspi/mount-data.nix +++ b/modules/raspi/mount-data.nix @@ -1,4 +1,4 @@ -{ vars, ... }: +{ config, lib, vars, ... }: { fileSystems.${vars.raspiMountpoint} = { @@ -9,6 +9,15 @@ "_netdev" "noatime" + # Explicitly use NFSv4.2 if supported + "nfsvers=4.2" + ] ++ lib.optionals (!config.boot.isContainer) [ + # `x-systemd.automount` never works inside a Linux container (LXC + # included) -- confirmed live on lxc-docker: systemd logs "Starting + # of .automount unsupported" and never mounts it. `nofail` + # above already keeps boot non-blocking there, so plain eager + # mounting is fine. + # Don't mount until first access "x-systemd.automount" @@ -17,9 +26,6 @@ # Give the Pi/Tailscale a little time to appear "x-systemd.device-timeout=10s" - - # Explicitly use NFSv4.2 if supported - "nfsvers=4.2" ]; }; diff --git a/scripts/create-proxmox-resource.sh b/scripts/create-proxmox-resource.sh index 1225fbf..2f7a696 100755 --- a/scripts/create-proxmox-resource.sh +++ b/scripts/create-proxmox-resource.sh @@ -521,7 +521,17 @@ if [[ "$type" == "lxc" ]]; then # systemd routinely uses (even plain getty units), and every getty # crash-loops on a denied mount every ~3s (visible as garbage on the # console) while core services like nsncd fail the same way. - create_cmd="pct create ${vmid} ${iso_storage}:vztmpl/${remote_filename} --unprivileged 1 --features ${PROXMOX_DEFAULT_LXC_FEATURES} --rootfs ${storage}:${local_disk_size} --hostname ${name} --cores ${cores} --memory ${memory} --swap ${local_swap} --net0 name=eth0,bridge=${bridge},ip=dhcp" + # + # ...,mount=nfs;nfs4: without it AppArmor blanket-denies the `nfs`/ + # `rpc_pipefs` mount syscalls any NFS client share needs -- confirmed + # live on lxc-docker: `mount: /var/lib/nfs/rpc_pipefs: permission + # denied`. The value's `;` (Proxmox's own multi-fstype separator for + # this one feature, per PVE::LXC's use of PVE::ParseUtils::split_list) + # must stay single-quoted here: create_cmd is sent to `remote()`, which + # hands the whole string to `ssh` as a single command for the *remote* + # shell to parse -- unquoted, that `;` would be read as a remote + # command separator and silently truncate this into two commands. + create_cmd="pct create ${vmid} ${iso_storage}:vztmpl/${remote_filename} --unprivileged 1 --features '${PROXMOX_DEFAULT_LXC_FEATURES}' --rootfs ${storage}:${local_disk_size} --hostname ${name} --cores ${cores} --memory ${memory} --swap ${local_swap} --net0 name=eth0,bridge=${bridge},ip=dhcp" remote "$create_cmd" remote "pct start ${vmid}" else diff --git a/scripts/env.sh b/scripts/env.sh index b0c48c1..3fb56f2 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -45,7 +45,15 @@ # crash-loops on a denied `/run/credentials/*` mount every ~3s (visible # as garbage on the console) and core services like nsncd fail the same # way on userns_create; system.build.tarball never finishes activating. -: "${PROXMOX_DEFAULT_LXC_FEATURES:=nesting=1,keyctl=1}" +# +# mount=nfs;nfs4: without it, AppArmor blanket-denies the `nfs`/ +# `rpc_pipefs` mount syscalls any NFS client share needs -- confirmed +# live on lxc-docker (which mounts several, see modules/docker/mount-data.nix +# and modules/raspi/mount-data.nix): `mount: /var/lib/nfs/rpc_pipefs: +# permission denied`. Harmless to grant on lxc targets that don't mount +# NFS at all -- it only widens what the container is *allowed* to mount, +# nothing here forces a mount to happen. +: "${PROXMOX_DEFAULT_LXC_FEATURES:=nesting=1,keyctl=1,mount=nfs;nfs4}" export PROXMOX_HOST PROXMOX_SSH_USER PROXMOX_STORAGE PROXMOX_ISO_STORAGE \ PROXMOX_BRIDGE PROXMOX_DEFAULT_CORES PROXMOX_DEFAULT_MEMORY_MB \