Archived
Merge pull request 'fix(pxe-boot): fix NFS mount in LXC — NFSv3+nolock and skip rpc_pipefs' (#75) from worktree-debian-pxe into main
Reviewed-on: #75
This commit is contained in:
@@ -1,24 +1,42 @@
|
|||||||
{ config, vars, ... }:
|
{ config, lib, vars, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# Use the same FQDN approach as docker/mount-data.nix — a bare hostname is
|
# Use the same FQDN approach as docker/mount-data.nix — a bare hostname is
|
||||||
# unreliable: systemd-resolved only tries LLMNR for single-label names, and
|
# unreliable: systemd-resolved only tries LLMNR for single-label names, and
|
||||||
# a global search domain causes it to skip the interface-scoped LAN DNS.
|
# a global search domain causes it to skip the interface-scoped LAN DNS.
|
||||||
nfsServer = "${vars.nfsServerHost}.${vars.homeDomain}";
|
nfsServer = "${vars.nfsServerHost}.${vars.homeDomain}";
|
||||||
|
|
||||||
# x-systemd.automount is unsupported inside LXC containers (systemd logs
|
|
||||||
# "Starting of <unit>.automount unsupported" and never mounts). Use nofail
|
|
||||||
# there so a boot with the NFS server unreachable doesn't hang instead.
|
|
||||||
automountOpts = if config.boot.isContainer then [ "nofail" ] else [ "x-systemd.automount" ];
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
fileSystems.${vars.nfsShares.proxmoxPxeImages.mountpoint} = {
|
fileSystems.${vars.nfsShares.proxmoxPxeImages.mountpoint} = {
|
||||||
device = "${nfsServer}:${vars.storageRoot}/${vars.nfsShares.proxmoxPxeImages.subpath}";
|
device = "${nfsServer}:${vars.storageRoot}/${vars.nfsShares.proxmoxPxeImages.subpath}";
|
||||||
fsType = "nfs";
|
fsType = "nfs";
|
||||||
options = [
|
options = [
|
||||||
"nfsvers=4.2"
|
|
||||||
"_netdev"
|
"_netdev"
|
||||||
"noatime"
|
"noatime"
|
||||||
] ++ automountOpts;
|
] ++ (if config.boot.isContainer
|
||||||
|
# NFSv4 requires rpc_pipefs (sunrpc filesystem), which Proxmox LXC
|
||||||
|
# containers block unless `features: mount=nfs` is set. Use NFSv3+nolock
|
||||||
|
# instead: no rpc_pipefs dependency at the protocol level, and rpcbind
|
||||||
|
# on the server handles port resolution without needing client-side
|
||||||
|
# sunrpc infrastructure. nofail keeps boot clean if server is unreachable.
|
||||||
|
then [ "nfsvers=3" "proto=tcp" "nolock" "nofail" ]
|
||||||
|
else [ "nfsvers=4.2" "x-systemd.automount" ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
# NixOS pulls var-lib-nfs-rpc_pipefs.mount (the sunrpc filesystem) into
|
||||||
|
# nfs-client.target for any nfs fileSystems entry. In LXC containers the
|
||||||
|
# sunrpc mount is blocked by Proxmox's AppArmor profile, causing it to fail
|
||||||
|
# and the activation to report an error even though our mount uses nofail.
|
||||||
|
# Add ConditionVirtualization=!container via drop-in so systemd skips the
|
||||||
|
# unit entirely in containers (skip = inactive, not failed), which keeps
|
||||||
|
# nfs-client.target green and activation clean.
|
||||||
|
systemd.units = lib.mkIf config.boot.isContainer {
|
||||||
|
"var-lib-nfs-rpc_pipefs.mount" = {
|
||||||
|
overrideStrategy = "asDropin";
|
||||||
|
text = ''
|
||||||
|
[Unit]
|
||||||
|
ConditionVirtualization=!container
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user