<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Camelia</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Camelia"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Camelia"/>
	<updated>2026-05-09T20:40:41Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_an_NFS_server&amp;diff=31364</id>
		<title>Setting up an NFS server</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_an_NFS_server&amp;diff=31364"/>
		<updated>2025-11-03T00:23:41Z</updated>

		<summary type="html">&lt;p&gt;Camelia: Remove duplicate &amp;quot;in the&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page documents configuring Network File System (NFS) on both server and client side including autofs and Kerberos authentication.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
Install the following package for both NFS client and NFS server service. {{Cmd|# apk add nfs-utils}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
Setting up NFS service on Alpine Linux is no different from other Linux distributions.&lt;br /&gt;
&lt;br /&gt;
=== NFS server ===&lt;br /&gt;
&lt;br /&gt;
Setup export dirs in {{Path|/etc/exports}} on your server with IP address 10.10.10.1. For example: {{Cat|/etc/exports|&amp;lt;nowiki&amp;gt;/data 10.10.10.0/24(rw,nohide,no_subtree_check,no_root_squash)    &lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After editing {{Path|/etc/exports}}, reload your setting: {{Cmd|# exportfs -afv}}&lt;br /&gt;
&lt;br /&gt;
To make NFS server service to autostart on boot: {{Cmd|# rc-update add nfs}}&lt;br /&gt;
&lt;br /&gt;
To start NFS server service now: {{Cmd|# rc-service nfs start}}&lt;br /&gt;
&lt;br /&gt;
NFS server configuration file is located in {{Path|/etc/conf.d/nfs}}.&lt;br /&gt;
&lt;br /&gt;
==== NFS version ====&lt;br /&gt;
&lt;br /&gt;
To configure nfs version in use, pass appropriate options to nfsd in {{Path|/etc/conf.d/nfs}}. For example: {{Cat|/etc/conf.d/nfs|&amp;lt;nowiki&amp;gt;# Options to pass to rpc.nfsd&lt;br /&gt;
# `-N 3` means version 3 is disabled&lt;br /&gt;
OPTS_RPC_NFSD=&amp;quot;8 -N 3&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After editing {{Path|/etc/conf.d/nfs}}, restart the server: {{Cmd|# rc-service nfs restart}}&lt;br /&gt;
&lt;br /&gt;
{{Todo|NFS v4 doesn&#039;t need rpcbind. Disabling it with command {{ic|chmod 444 /etc/init.d/rpcbind}} breaks nfs service. Help add the correct method to disable rpcbind.}}&lt;br /&gt;
=== NFS client ===&lt;br /&gt;
&lt;br /&gt;
To mount NFS shares automatically, an entry needs to made to {{Path|/etc/fstab}} as follows:{{Cat|/etc/fstab|10.10.10.1:/data /mount/point nfs4 rw,_netdev 0 0}}&lt;br /&gt;
&lt;br /&gt;
To mount nfs share from {{Path|/etc/fstab}} file at booting of the system:{{Cmd|# rc-update add nfsmount}}&lt;br /&gt;
To mount the nfs shares from /etc/fstab file now:{{Cmd|# rc-service nfsmount start}}&lt;br /&gt;
&lt;br /&gt;
You can check your boot services:{{Cmd|# rc-status}}&lt;br /&gt;
&lt;br /&gt;
{{Tip| netmount is a general service for all network-based filesystems, while nfsmount is specifically tailored for NFS.}}&lt;br /&gt;
To use netmount, here are the equivalent commands:{{Cmd|&amp;lt;nowiki&amp;gt;# rc-service netmount start&lt;br /&gt;
# rc-update add netmount&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
== Using autofs ==&lt;br /&gt;
&lt;br /&gt;
[https://docs.kernel.org/filesystems/autofs.html Autofs] is another alternative for mounting filesystems like NFS. Autofs aims to provide on-demand mounting and race free automatic unmounting of various other filesystems.&lt;br /&gt;
&lt;br /&gt;
Ensure that {{pkg|autofs}} package is installed, if not installed already. {{Cmd|apk add autofs}}&lt;br /&gt;
Add an entry in the file {{Path|/etc/auto.master}} that points to a map file to define the mount points for the {{ic|/mnt/nfs}} directory.. For example:{{Cat|/etc/auto.master|&amp;lt;nowiki&amp;gt;/mnt/nfs /etc/auto.nfs --timeout=60&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Create the Map File {{Path|/etc/auto.nfs}} that maps the NFS share {{ic|10.10.10.1:/data}} to {{ic|/mnt/nfs/share}} as follows:{{Cat|/etc/auto.nfs|share -rw 10.10.10.1:/data}}&lt;br /&gt;
Start and Enable autofs:{{Cmd|&amp;lt;nowiki&amp;gt;# rc-update add autofs&lt;br /&gt;
# rc-service autofs start&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Eventhough autofs is primarily a client-side tool it can also be used on servers for dynamic mounting if required. For an use case of using Autofs on servers, refer to [[Raspberry_Pi_4_-_Persistent_system_acting_as_a_NAS_and_Time_Machine#Adding_and_Sharing_a_Disk|Sharing a Disk]] page.&lt;br /&gt;
&lt;br /&gt;
== Kerberos authentication ==&lt;br /&gt;
&lt;br /&gt;
By default, NFS security only validates the IP of the client. You can add user level authentication with a Kerberos authentication protocol. The choices are:&lt;br /&gt;
* [https://web.mit.edu/kerberos/www/ MIT KRB5] available in {{pkg|krb5}} package&lt;br /&gt;
* [https://github.com/heimdal/ Heimdal] available in {{pkg|heimdal}} package &lt;br /&gt;
&lt;br /&gt;
{{Note|It is recommended to have the same Kerberos flavor across the network as both implementations are not completely mutually compatible.}}&lt;br /&gt;
&lt;br /&gt;
The example given below uses MIT KRB5 syntax. So install the server package {{pkg|krb5-server}} on server and {{pkg|krb5}} package for client machines. &lt;br /&gt;
&lt;br /&gt;
=== Server configuration ===&lt;br /&gt;
&lt;br /&gt;
Assuming you setup Kerberos in the network, create ticket to your NFS machine :&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# kadmin: addprinc -randkey nfs/nfs1.example.com@EXAMPLE.COM}}&lt;br /&gt;
&lt;br /&gt;
And add it to the machines krb5.keytab file:&lt;br /&gt;
{{Cmd|# kadmin: ktadd nfs/nfs1.example.com@EXAMPLE.COM}}&lt;br /&gt;
&lt;br /&gt;
Then, edit your {{Path|/etc/exports}}, and add sec=krb5 (only authentication), sec=krb5i (also hmac signing) or sec=krb5p (also encryption). For example:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/exports|&amp;lt;nowiki&amp;gt;/data 10.10.10.0/24(rw,nohide,no_subtree_check,sec=krb5p,no_root_squash)    &lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
After editing {{Path|/etc/exports}}, reload your setting&lt;br /&gt;
{{Cmd|# exportfs -afv}}&lt;br /&gt;
&lt;br /&gt;
User id mapping is managed by &amp;lt;code&amp;gt;nfsidmap&amp;lt;/code&amp;gt; utility from {{pkg|nfs-utils}} package.&lt;br /&gt;
&lt;br /&gt;
=== Client configuration ===&lt;br /&gt;
&lt;br /&gt;
In order for the client to connect to NFS via kerberos, enable and start rpc.gssd service.&lt;br /&gt;
{{Cmd|# rc-update add rpc.gssd}}&lt;br /&gt;
{{Cmd|# rc-service rpc.gssd start}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.archlinux.org/title/NFS NFS in Arch wiki]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Nfs-utils NFS in Gentoo Wiki] &lt;br /&gt;
* [https://wiki.debian.org/NFSServerSetup#NFSv4_only NFS Server Setup in Debian wiki]&lt;br /&gt;
* [[Raspberry_Pi_4_-_Persistent_system_acting_as_a_NAS_and_Time_Machine]]&lt;br /&gt;
* [https://www.willowbarraco.fr/my-perfect-music-synchronization-solution/ NFS and FS-cache based synchronization solution ]&lt;br /&gt;
[[Category:Server]]&lt;/div&gt;</summary>
		<author><name>Camelia</name></author>
	</entry>
</feed>