# How to run a version 2 NFS server?

## MrZammler

Hi,

I'm trying to force my gentoo's nfs server to run with version 2. I'm running a systemd system, and I know it did at some point. However, now it will only run a version 3 server.

```

winterland linux # rpcinfo | grep nfs

    100003    3    tcp       0.0.0.0.8.1            nfs        superuser

    100003    3    udp       0.0.0.0.8.1            nfs        superuser

    100003    3    tcp6      ::.8.1                 nfs        superuser

    100003    3    udp6      ::.8.1                 nfs        superuser

```

```

winterland linux # cat /proc/fs/nfsd/versions 

-2 +3

```

/etc/conf.d/nfs is told to run a version 2 server:

```

winterland linux # more /etc/conf.d/nfs

# /etc/conf.d/nfs

# If you wish to set the port numbers for lockd,

# please see /etc/sysctl.conf

# Optional services to include in default `/etc/init.d/nfs start`

# For NFSv4 users, you'll want to add "rpc.idmapd" here.

NFS_NEEDED_SERVICES="rpc.idmapd"

# Number of servers to be started up by default

OPTS_RPC_NFSD="8 -V 2 -V 3"

# Options to pass to rpc.mountd

# ex. OPTS_RPC_MOUNTD="-p 32767"

OPTS_RPC_MOUNTD="-V 2 -V 3"

# Options to pass to rpc.statd

# ex. OPTS_RPC_STATD="-p 32765 -o 32766"

OPTS_RPC_STATD=""

# Options to pass to rpc.idmapd

OPTS_RPC_IDMAPD=""

# Options to pass to rpc.gssd

OPTS_RPC_GSSD=""

# Options to pass to rpc.svcgssd

OPTS_RPC_SVCGSSD=""

# Options to pass to rpc.rquotad (requires sys-fs/quota)

OPTS_RPC_RQUOTAD=""

# Timeout (in seconds) for exportfs

EXPORTFS_TIMEOUT=30

# Options to set in the nfsd filesystem (/proc/fs/nfsd/).

# Format is <option>=<value>.  Multiple options are allowed.

#OPTS_NFSD="nfsv4leasetime=30 max_block_size=4096"

#NFSD_OPTS="-V 2"

```

Have CONFIG_NFSD in kernel which should handle version 2:

```

winterland linux # grep NFS /usr/src/linux/.config

CONFIG_NFS_FS=y

CONFIG_NFS_V2=y

CONFIG_NFS_V3=y

CONFIG_NFS_V3_ACL=y

CONFIG_NFS_V4=y

# CONFIG_NFS_SWAP is not set

# CONFIG_NFS_V4_1 is not set

CONFIG_ROOT_NFS=y

# CONFIG_NFS_USE_LEGACY_DNS is not set

CONFIG_NFS_USE_KERNEL_DNS=y

CONFIG_NFSD=y

CONFIG_NFSD_V3=y

# CONFIG_NFSD_V3_ACL is not set

# CONFIG_NFSD_V4 is not set

CONFIG_NFS_ACL_SUPPORT=y

CONFIG_NFS_COMMON=y

```

However, it just doesn't run...

No clue as to what else I can check.. Any ideas?

----------

## Hu

Why do you want to run a legacy version NFS server?  Do you have some custom device that cannot use a modern NFS protocol?

----------

## MrZammler

Yes, I mount the nfs share on an Amiga. As it might be expected, it's nfs client only made it as far as version 2  :Smile: 

I've noticed that /usr/lib64/systemd/system/nfsd.service which starts nfs doesn't take into account anything from /etc/conf.d/nfs:

```

[Unit]

Description=NFS server

After=rpcbind.service

Requires=rpcbind.service

[Service]

Type=oneshot

ExecStart=/usr/sbin/rpc.nfsd 8

ExecStartPost=/usr/sbin/exportfs -a

ExecStop=/usr/sbin/rpc.nfsd 0

ExecStopPost=/usr/sbin/exportfs -a -u

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

```

I've added:

```

ExecStart=/usr/sbin/rpc.nfsd 8 -V 2

```

and works as expected:

```

winterland linux # cat /proc/fs/nfsd/versions 

+2 +3

```

Anyone knows why it's that?

----------

## Hu

Configuration in /etc/conf.d is for OpenRC users.  Some systemd services might include tricks to respect your OpenRC settings.  Modifying a systemd service file outside the configuration protected area is likely a bad idea, since it will be overwritten on the next merge of the owning package.

----------

## MrZammler

 *Hu wrote:*   

> Configuration in /etc/conf.d is for OpenRC users.  Some systemd services might include tricks to respect your OpenRC settings.  Modifying a systemd service file outside the configuration protected area is likely a bad idea, since it will be overwritten on the next merge of the owning package.

 

Yes, I know it will be overwritten.

I know I saw somewhere while searching that indeed systemd should pick up settings from /etc/conf.d/nfs, or at least did so at some point.

Will copying nfsd.service to /etc/systemd/system/ let it take precendance over the default file?

----------

## Hu

I masked systemd and do not use or support it.  I have no idea whether that would work, but if it did, there might be negative consequences if upstream publishes a modified version and some of the modifications are required, since your override would not receive those.

----------

## MrZammler

So, it seems nfs-utils now ship 2 versions of nfsd.service:

nfsd.service:

```

[Unit]

Description=NFS server

After=rpcbind.service

Requires=rpcbind.service

[Service]

Type=oneshot

EnvironmentFile=/etc/conf.d/nfs

ExecStart=/usr/sbin/rpc.nfsd $OPTS_RPC_NFSD

ExecStartPost=/usr/sbin/exportfs -a

ExecStop=/usr/sbin/rpc.nfsd 0

ExecStopPost=/usr/sbin/exportfs -a -u

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

```

and 

nfsd.service-r1:

```

[Unit]

Description=NFS server

After=rpcbind.service

Requires=rpcbind.service

[Service]

Type=oneshot

ExecStart=/usr/sbin/rpc.nfsd 8

ExecStartPost=/usr/sbin/exportfs -a

ExecStop=/usr/sbin/rpc.nfsd 0

ExecStopPost=/usr/sbin/exportfs -a -u

RemainAfterExit=yes

[Install]

WantedBy=multi-user.target

```

nfs-utils-1.2.9-r2.ebuild and upwards installs the r1 version, so no more /etc/conf.d/nfs reference. 

Anyone knows if there is a new way of configuring the behaviour of the nfs server?

----------

