NFS: Difference between revisions
→Using bind mounts: Add link to the filesystem bind mount section Tags: Mobile edit Mobile web edit Advanced mobile edit |
Cleaned up client section Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
| Line 54: | Line 54: | ||
This configuration exposes all our shares to 2 local IPs; you can find more examples at [https://wiki.gentoo.org/wiki/NFSv4 Gentoo's wiki on NFS]. | This configuration exposes all our shares to 2 local IPs; you can find more examples at [https://wiki.gentoo.org/wiki/NFSv4 Gentoo's wiki on NFS]. | ||
To list the current loaded exports, use: <code>exportfs -v</code> | |||
Other options are available on the [https://search.nixos.org/options?query=nfs NixOS option page] or via the <code>nixos-option</code> command. | Other options are available on the [https://search.nixos.org/options?query=nfs NixOS option page] or via the <code>nixos-option</code> command. | ||
| Line 86: | Line 88: | ||
= Client = | = Client = | ||
To ensure the client has the necessary utilities installed, add | To ensure the client has the necessary NFS utilities installed, add the following to your system configuration (for example, in <code>configuration.nix</code>). | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
boot.supportedFilesystems = [ "nfs" ]; | boot.supportedFilesystems = [ "nfs" ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
NFS shares can be mounted on a client system using the standard <code>filesystem</code> option. Continuing the server example, to mount the <code>tomoyo</code> share: | |||
Continuing the server example, | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| Line 103: | Line 104: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
In the above configuration, replace "server" with the appropriate IP address or DNS entry of your NFS server. Other, regular [https://search.nixos.org/options?query=filesystems.%3Cname%3E filesystem options] apply. | |||
{{note| On the client side, the exposed shares are as if they were exposed at the root level - i.e. <code>/export/foo</code> becomes <code>/foo</code> (in the <code>device</code> option) }} | |||
== Specifying NFS version == | == Specifying NFS version == | ||
| Line 145: | Line 149: | ||
== Using systemd.mounts and systemd.automounts == | == Using systemd.mounts and systemd.automounts == | ||
Here is an example with auto-disconnecting and lazy-mounting implemented, and the <code>noatime</code> mount option added. | This section provides an alternative approach for users who prefer to manage mounts using dedicated systemd units. Here is an example with auto-disconnecting and lazy-mounting implemented, and the <code>noatime</code> mount option added. | ||
Note that <code>wantedBy = [ "multi-user.target" ];</code> is required for the automount unit to start at boot. | Note that <code>wantedBy = [ "multi-user.target" ];</code> is required for the automount unit to start at boot. | ||