fs mounts: add nofail and mount-timeout to reduce shutdown hangs on nfs

This commit is contained in:
Colin 2023-06-15 10:08:54 +00:00
parent 17041384e9
commit 5562d60cbb

View File

@ -1,3 +1,6 @@
# docs
# - x-systemd options: <https://www.freedesktop.org/software/systemd/man/systemd.mount.html>
{ pkgs, sane-lib, ... }: { pkgs, sane-lib, ... }:
let fsOpts = rec { let fsOpts = rec {
@ -6,9 +9,11 @@ let fsOpts = rec {
"noatime" "noatime"
"x-systemd.requires=network-online.target" "x-systemd.requires=network-online.target"
"x-systemd.after=network-online.target" "x-systemd.after=network-online.target"
"x-systemd.mount-timeout=10s" # how long to wait for mount **and** how long to wait for unmount
"nofail" # don't fail remote-fs.target when this mount fails
]; ];
auto = [ "x-systemd.automount" ]; auto = [ "x-systemd.automount" ];
noauto = [ "noauto" ]; noauto = [ "noauto" ]; # don't mount as part of remote-fs.target
wg = [ wg = [
"x-systemd.requires=wireguard-wg-home.service" "x-systemd.requires=wireguard-wg-home.service"
"x-systemd.after=wireguard-wg-home.service" "x-systemd.after=wireguard-wg-home.service"
@ -43,7 +48,7 @@ let fsOpts = rec {
# note: client uses a linear backup, so the second request will have double this timeout, then triple, etc. # note: client uses a linear backup, so the second request will have double this timeout, then triple, etc.
nfs = common ++ [ nfs = common ++ [
# "actimeo=10" # "actimeo=10"
# "bg" "bg"
"retrans=4" "retrans=4"
"retry=0" "retry=0"
"soft" "soft"
@ -52,14 +57,14 @@ let fsOpts = rec {
}; };
in in
{ {
environment.pathsToLink = [ # fileSystems."/mnt/servo-nfs" = {
# needed to achieve superuser access for user-mounted filesystems (see optionsRoot above) # device = "servo-hn:/";
# we can only link whole directories here, even though we're only interested in pkgs.openssh # noCheck = true;
"/libexec" # fsType = "nfs";
]; # options = fsOpts.nfs ++ fsOpts.auto ++ fsOpts.wg;
# };
fileSystems."/mnt/servo-nfs" = { fileSystems."/mnt/servo-nfs/media" = {
device = "servo-hn:/"; device = "servo-hn:/media";
noCheck = true; noCheck = true;
fsType = "nfs"; fsType = "nfs";
options = fsOpts.nfs ++ fsOpts.auto ++ fsOpts.wg; options = fsOpts.nfs ++ fsOpts.auto ++ fsOpts.wg;
@ -109,6 +114,12 @@ in
noCheck = true; noCheck = true;
}; };
environment.pathsToLink = [
# needed to achieve superuser access for user-mounted filesystems (see optionsRoot above)
# we can only link whole directories here, even though we're only interested in pkgs.openssh
"/libexec"
];
environment.systemPackages = [ environment.systemPackages = [
pkgs.sshfs-fuse pkgs.sshfs-fuse
]; ];