Migrate from NFS Kernel Server to NFS-Ganesha server under CentOS Stream 9

This article is to show how to migrate from the NFS kernel server to the NFS-Ganesha server under CentOS Stream 9. The most important thing for migrating from one program to another program is how much downtime will be and what is expected to be done by the clients. In this case, what the clients are needed to do when NFS-Ganesha is used for the server?

main menu
install nfs ganesha

Here are the main points when migrating from NFS Kernel Server to the NFS-Ganesha:

  • The nfs-tuils and nfs-ganesha packages and in general, the two software, are perfectly fine installed on the same system. There are no conflicts when NFS Kernel Server and the NFS-Ganesha server are installed at the same time on the same system.
  • The clients, do not need to do anything, except remount the NFS mounts.
  • It should be installed a new community repository by installing the centos-release-nfs-ganesha5 package. The Special Interest Groups (SIG) maintains the repository and the group is within the CentOS community

For installation of NFS-Ganesha and a detailed information check out the older article on the subject – Simple export of a ext4 directory with NFS Ganesha 3.5 server in CentOS 8 with SELinux enforcing, Simple export of a ext4 directory with NFS Ganesha 3.5 server in CentOS 8 without SELinux and Create and export a GlusterFS volume with NFS-Ganesha in CentOS 8

Prerequisite – NFS Kernel Configuration

NFS Kernel Server is installed with nfs-utils packages (and its dependencies) and it has the following simple configuration:

[root@srv ~]# cat /etc/exports
/mnt/storage           192.168.0.0/24(rw,sync,no_root_squash,no_subtree_check)

And here are the NFS services on the system:

[root@srv ~]# systemctl |grep nfs
  proc-fs-nfsd.mount                                         loaded active mounted   NFSD configuration filesystem
  var-lib-nfs-rpc_pipefs.mount                               loaded active mounted   RPC Pipe File System
  nfs-idmapd.service                                         loaded active running   NFSv4 ID-name mapping service
  nfs-mountd.service                                         loaded active running   NFS Mount Daemon
  nfs-server.service                                         loaded active exited    NFS server and services
  nfsdcld.service                                            loaded active running   NFSv4 Client Tracking Daemon
  nfs-client.target                                          loaded active active    NFS client services

The server’s firewall has been tuned for the NFS kernel server, so no need to edit anything in the firewall for the NFS-Ganesha server.

STEP 1) Install the repository package and the NFS-Ganesha server package.

While still running the NFS Kernel Server (because this article is about how to migrate from it to the NFS-Ganesha), search for the latest NFS-Ganesha repository package and install it.

[root@srv ~]# dnf search nfs-ganesha
Last metadata expiration check: 1:57:17 ago on Mon 12 Jun 2023 12:10:01 PM UTC.
========================================== Name & Summary Matched: nfs-ganesha ==========================================
centos-release-nfs-ganesha4.noarch : NFS-Ganesha 4 packages from the CentOS Storage SIG repository
centos-release-nfs-ganesha5.noarch : NFS-Ganesha 5 packages from the CentOS Storage SIG repository

At present, there are two NFS-Ganesha versions available – 4 and 5. Use the latest one – version 5.

[root@srv ~]# dnf install -y centos-release-nfs-ganesha5.noarch
Last metadata expiration check: 1:58:55 ago on Mon 12 Jun 2023 12:10:01 PM UTC.
Dependencies resolved.
=========================================================================================================================
 Package                                    Architecture        Version                 Repository                  Size
=========================================================================================================================
Installing:
 centos-release-nfs-ganesha5                noarch              1.0-1.el9s              extras-common              7.5 k
Installing dependencies:
 centos-release-storage-common              noarch              2-5.el9s                extras-common              8.3 k

Transaction Summary
=========================================================================================================================
Install  2 Packages

Total download size: 16 k
Installed size: 2.2 k
Downloading Packages:
(1/2): centos-release-nfs-ganesha5-1.0-1.el9s.noarch.rpm                                  14 kB/s | 7.5 kB     00:00    
(2/2): centos-release-storage-common-2-5.el9s.noarch.rpm                                  15 kB/s | 8.3 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    9.4 kB/s |  16 kB     00:01     
CentOS Stream 9 - Extras packages                                                        1.5 MB/s | 2.1 kB     00:00    
Importing GPG key 0x1D997668:
 Userid     : "CentOS Extras SIG (https://wiki.centos.org/SpecialInterestGroup) <security@centos.org>"
 Fingerprint: 363F C097 2F64 B699 AED3 968E 1FF6 A217 1D99 7668
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                 1/1 
  Installing       : centos-release-storage-common-2-5.el9s.noarch                                                   1/2 
  Installing       : centos-release-nfs-ganesha5-1.0-1.el9s.noarch                                                   2/2 
  Verifying        : centos-release-nfs-ganesha5-1.0-1.el9s.noarch                                                   1/2 
  Verifying        : centos-release-storage-common-2-5.el9s.noarch                                                   2/2 

Installed:
  centos-release-nfs-ganesha5-1.0-1.el9s.noarch               centos-release-storage-common-2-5.el9s.noarch              

Complete!

Now, install the NFS-Ganesha server:

[root@srv ~]# dnf install -y nfs-ganesha nfs-ganesha-vfs nfs-ganesha-selinux
CentOS-9-stream - NFS-Ganesha 5                                                          9.1 kB/s |  14 kB     00:01    
Dependencies resolved.
=========================================================================================================================
 Package                                Architecture     Version                    Repository                      Size
=========================================================================================================================
Installing:
 nfs-ganesha                            x86_64           5.2-1.el9s                 centos-nfs-ganesha-5           698 k
 nfs-ganesha-selinux                    noarch           5.2-1.el9s                 centos-nfs-ganesha-5            23 k
 nfs-ganesha-vfs                        x86_64           5.2-1.el9s                 centos-nfs-ganesha-5            53 k
Installing dependencies:
 avahi-libs                             x86_64           0.8-12.el9                 baseos                          68 k
 checkpolicy                            x86_64           3.5-1.el9                  appstream                      347 k
 libicu                                 x86_64           67.1-9.el9                 baseos                         9.6 M
 libntirpc                              x86_64           5.0-1.el9s                 centos-nfs-ganesha-5           119 k
 libprometheus-cpp                      x86_64           1.1.0-1.el9s               centos-nfs-ganesha-5           145 k
 libwbclient                            x86_64           4.17.5-102.el9             baseos                          43 k
 policycoreutils-python-utils           noarch           3.5-1.el9                  appstream                       77 k
 python3-audit                          x86_64           3.0.7-103.el9              appstream                       84 k
 python3-distro                         noarch           1.5.0-7.el9                baseos                          37 k
 python3-libsemanage                    x86_64           3.5-2.el9                  appstream                       80 k
 python3-policycoreutils                noarch           3.5-1.el9                  appstream                      2.1 M
 python3-setools                        x86_64           4.4.2-2.1.el9              baseos                         600 k
 python3-setuptools                     noarch           53.0.0-12.el9              baseos                         944 k
 samba-client-libs                      x86_64           4.17.5-102.el9             baseos                         5.0 M
 samba-common                           noarch           4.17.5-102.el9             baseos                         150 k
 samba-common-libs                      x86_64           4.17.5-102.el9             baseos                         101 k

Transaction Summary
=========================================================================================================================
Install  19 Packages

Total download size: 20 M
Installed size: 70 M
Downloading Packages:
CentOS-9-stream - NFS-Ganesha 5          165% [==================================================================]  13 kB                                         167% [==================================================================-]  14 k(1/19): libntirpc-5.0-1.el9s.x86_64.rpm                                                  368 kB/s | 119 kB     00:00    
(2/19): libprometheus-cpp-1.1.0-1.el9s.x86_64.rpm                                        413 kB/s | 145 kB     00:00    
(3/19): nfs-ganesha-selinux-5.2-1.el9s.noarch.rpm                                        508 kB/s |  23 kB     00:00    
(4/19): nfs-ganesha-5.2-1.el9s.x86_64.rpm                                                1.7 MB/s | 698 kB     00:00    
(5/19): nfs-ganesha-vfs-5.2-1.el9s.x86_64.rpm                                            870 kB/s |  53 kB     00:00    
(6/19): avahi-libs-0.8-12.el9.x86_64.rpm                                                  26 kB/s |  68 kB     00:02    
(7/19): libwbclient-4.17.5-102.el9.x86_64.rpm                                             16 kB/s |  43 kB     00:02    
(8/19): python3-distro-1.5.0-7.el9.noarch.rpm                                            235 kB/s |  37 kB     00:00    
(9/19): python3-setuptools-53.0.0-12.el9.noarch.rpm                                      2.0 MB/s | 944 kB     00:00    
(10/19): python3-setools-4.4.2-2.1.el9.x86_64.rpm                                        758 kB/s | 600 kB     00:00    
(11/19): samba-common-4.17.5-102.el9.noarch.rpm                                          699 kB/s | 150 kB     00:00    
(12/19): samba-common-libs-4.17.5-102.el9.x86_64.rpm                                     641 kB/s | 101 kB     00:00    
(13/19): libicu-67.1-9.el9.x86_64.rpm                                                    2.3 MB/s | 9.6 MB     00:04    
(14/19): samba-client-libs-4.17.5-102.el9.x86_64.rpm                                     4.1 MB/s | 5.0 MB     00:01    
(15/19): policycoreutils-python-utils-3.5-1.el9.noarch.rpm                               218 kB/s |  77 kB     00:00    
(16/19): python3-audit-3.0.7-103.el9.x86_64.rpm                                          439 kB/s |  84 kB     00:00    
(17/19): python3-libsemanage-3.5-2.el9.x86_64.rpm                                        605 kB/s |  80 kB     00:00    
(18/19): checkpolicy-3.5-1.el9.x86_64.rpm                                                418 kB/s | 347 kB     00:00    
(19/19): python3-policycoreutils-3.5-1.el9.noarch.rpm                                    2.5 MB/s | 2.1 MB     00:00    
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    2.5 MB/s |  20 MB     00:08     
CentOS-9-stream - NFS-Ganesha 5                                                          1.0 MB/s | 1.0 kB     00:00    
Importing GPG key 0xE451E5B5:
 Userid     : "CentOS Storage SIG (http://wiki.centos.org/SpecialInterestGroup/Storage) <security@centos.org>"
 Fingerprint: 7412 9C0B 173B 071A 3775 951A D4A2 E50B E451 E5B5
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Storage
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                 1/1 
  Running scriptlet: samba-common-4.17.5-102.el9.noarch                                                             1/19 
  Installing       : samba-common-4.17.5-102.el9.noarch                                                             1/19 
  Running scriptlet: samba-common-4.17.5-102.el9.noarch                                                             1/19 
  Installing       : python3-setuptools-53.0.0-12.el9.noarch                                                        2/19 
  Installing       : python3-distro-1.5.0-7.el9.noarch                                                              3/19 
  Installing       : python3-setools-4.4.2-2.1.el9.x86_64                                                           4/19 
  Installing       : python3-libsemanage-3.5-2.el9.x86_64                                                           5/19 
  Installing       : python3-audit-3.0.7-103.el9.x86_64                                                             6/19 
  Installing       : checkpolicy-3.5-1.el9.x86_64                                                                   7/19 
  Installing       : python3-policycoreutils-3.5-1.el9.noarch                                                       8/19 
  Installing       : policycoreutils-python-utils-3.5-1.el9.noarch                                                  9/19 
  Installing       : libicu-67.1-9.el9.x86_64                                                                      10/19 
  Installing       : avahi-libs-0.8-12.el9.x86_64                                                                  11/19 
  Installing       : libwbclient-4.17.5-102.el9.x86_64                                                             12/19 
  Installing       : samba-common-libs-4.17.5-102.el9.x86_64                                                       13/19 
  Installing       : samba-client-libs-4.17.5-102.el9.x86_64                                                       14/19 
  Installing       : libprometheus-cpp-1.1.0-1.el9s.x86_64                                                         15/19 
  Installing       : libntirpc-5.0-1.el9s.x86_64                                                                   16/19 
  Running scriptlet: nfs-ganesha-selinux-5.2-1.el9s.noarch                                                         17/19 
  Installing       : nfs-ganesha-selinux-5.2-1.el9s.noarch                                                         17/19 
  Running scriptlet: nfs-ganesha-selinux-5.2-1.el9s.noarch                                                         17/19 
  Running scriptlet: nfs-ganesha-5.2-1.el9s.x86_64                                                                 18/19 
  Installing       : nfs-ganesha-5.2-1.el9s.x86_64                                                                 18/19 
  Running scriptlet: nfs-ganesha-5.2-1.el9s.x86_64                                                                 18/19 
  Installing       : nfs-ganesha-vfs-5.2-1.el9s.x86_64                                                             19/19 
  Running scriptlet: libwbclient-4.17.5-102.el9.x86_64                                                             19/19 
  Running scriptlet: nfs-ganesha-5.2-1.el9s.x86_64                                                                 19/19 
  Running scriptlet: nfs-ganesha-vfs-5.2-1.el9s.x86_64                                                             19/19 
  Verifying        : libntirpc-5.0-1.el9s.x86_64                                                                    1/19 
  Verifying        : libprometheus-cpp-1.1.0-1.el9s.x86_64                                                          2/19 
  Verifying        : nfs-ganesha-5.2-1.el9s.x86_64                                                                  3/19 
  Verifying        : nfs-ganesha-selinux-5.2-1.el9s.noarch                                                          4/19 
  Verifying        : nfs-ganesha-vfs-5.2-1.el9s.x86_64                                                              5/19 
  Verifying        : avahi-libs-0.8-12.el9.x86_64                                                                   6/19 
  Verifying        : libicu-67.1-9.el9.x86_64                                                                       7/19 
  Verifying        : libwbclient-4.17.5-102.el9.x86_64                                                              8/19 
  Verifying        : python3-distro-1.5.0-7.el9.noarch                                                              9/19 
  Verifying        : python3-setools-4.4.2-2.1.el9.x86_64                                                          10/19 
  Verifying        : python3-setuptools-53.0.0-12.el9.noarch                                                       11/19 
  Verifying        : samba-client-libs-4.17.5-102.el9.x86_64                                                       12/19 
  Verifying        : samba-common-4.17.5-102.el9.noarch                                                            13/19 
  Verifying        : samba-common-libs-4.17.5-102.el9.x86_64                                                       14/19 
  Verifying        : checkpolicy-3.5-1.el9.x86_64                                                                  15/19 
  Verifying        : policycoreutils-python-utils-3.5-1.el9.noarch                                                 16/19 
  Verifying        : python3-audit-3.0.7-103.el9.x86_64                                                            17/19 
  Verifying        : python3-libsemanage-3.5-2.el9.x86_64                                                          18/19 
  Verifying        : python3-policycoreutils-3.5-1.el9.noarch                                                      19/19 

Installed:
  avahi-libs-0.8-12.el9.x86_64                             checkpolicy-3.5-1.el9.x86_64                                  
  libicu-67.1-9.el9.x86_64                                 libntirpc-5.0-1.el9s.x86_64                                   
  libprometheus-cpp-1.1.0-1.el9s.x86_64                    libwbclient-4.17.5-102.el9.x86_64                             
  nfs-ganesha-5.2-1.el9s.x86_64                            nfs-ganesha-selinux-5.2-1.el9s.noarch                         
  nfs-ganesha-vfs-5.2-1.el9s.x86_64                        policycoreutils-python-utils-3.5-1.el9.noarch                 
  python3-audit-3.0.7-103.el9.x86_64                       python3-distro-1.5.0-7.el9.noarch                             
  python3-libsemanage-3.5-2.el9.x86_64                     python3-policycoreutils-3.5-1.el9.noarch                      
  python3-setools-4.4.2-2.1.el9.x86_64                     python3-setuptools-53.0.0-12.el9.noarch                       
  samba-client-libs-4.17.5-102.el9.x86_64                  samba-common-4.17.5-102.el9.noarch                            
  samba-common-libs-4.17.5-102.el9.x86_64                 

Complete!

STEP 2) Migrate configuration from NFS Kernel server to NFS-Ganesha server.

The NFS-Ganesha configuration file is /etc/ganesha/ganesha.conf and there is a sample configuration file /etc/ganesha/vfs.conf for a directory NFS sharing. Use /etc/ganesha/ganesha.conf for the NFS-Ganesha configuration.

EXPORT
{
        Export_Id = 2;
        Path = /mnt/storage;
        Pseudo = /mnt/storage;
        Protocols = 3,4;
        Access_Type = RW;
        Squash = None;
        FSAL
        {
                Name = VFS;
        }
        CLIENT
        {
                Clients = 192.168.0.0/24;
        }
}

Enumerate more clients with commas. For multiple configuration examples check out the following link – https://github.com/phdeniel/nfs-ganesha/tree/master/src/config_samples.

STEP 3) Stop the NFS kernel server daemon and start the NFS-Ganesha server daemon.

First, stop the NFS Kernel Server and then start the NFS-Ganesha server. Then umount and mount it again.

[root@srv ~]# systemctl stop nfs-server
[root@srv ~]# systemctl start nfs-ganesha
[root@srv ~]# systemctl status nfs-ganesha
● nfs-ganesha.service - NFS-Ganesha file server
     Loaded: loaded (/usr/lib/systemd/system/nfs-ganesha.service; disabled; preset: disabled)
     Active: active (running) since Tue 2023-06-13 08:07:57 UTC; 3s ago
       Docs: http://github.com/nfs-ganesha/nfs-ganesha/wiki
    Process: 6939 ExecStart=/bin/bash -c ${NUMACTL} ${NUMAOPTS} /usr/bin/ganesha.nfsd -C ${OPTIONS} ${EPOCH} ${GNODEID} >
   Main PID: 6940 (ganesha.nfsd)
      Tasks: 21 (limit: 23058)
     Memory: 31.4M
        CPU: 101ms
     CGroup: /system.slice/nfs-ganesha.service
             └─6940 /usr/bin/ganesha.nfsd -C -L /var/log/ganesha/ganesha.log -f /etc/ganesha/ganesha.conf -N NIV_EVENT

Jun 13 08:07:57 srv systemd[1]: Starting NFS-Ganesha file server...
Jun 13 08:07:57 srv systemd[1]: Started NFS-Ganesha file server.

If the administrator has not umounted the NFS share prior the stop/start operateion of the NFS kernel server and the NFS-Ganesha server, an error will occur when trying to access the shared directory:

[root@client ~]# df -h /mnt/storage
df: /mnt/storage: Unknown error 521
[root@srv ~]# mount -o remount,rw /mnt/nfs/storage
mount.nfs: Unknown error 521

The remount is not possible, too.
umount and mount the network device.

[root@client ~]# umount /mnt/storage
umount.nfs4: /mnt/storage: device is busy
[root@client ~]# umount -l /mnt/storage
[root@client ~]# mount /mnt/storage
[root@client ~]# df -h /mnt/storage
Filesystem                 Size  Used Avail Use% Mounted on
192.168.0.20:/mnt/storage   70G  1.9G   69G   3% /mnt/storage

If the device is busy, just check which program is still using it with lsof utility.

[root@client ~]# lsof /mnt/storage/
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
bash    4561 root  cwd    DIR   0,77       30 67379452 /mnt/storage (192.168.0.20:/mnt/storage)

So there is a bash program, which still has an open directory /mnt/storage. Just exit the bash/script or kill it. Then a normal umount will be possible or just use “-l” to lazy detach the network share.

Disable the old service and enable the new one for the next reboot.

[root@srv ~]# systemctl disable nfs-server
Removed "/etc/systemd/system/multi-user.target.wants/nfs-server.service".
[root@srv ~]# systemctl enable nfs-ganesha
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-ganesha.service → /usr/lib/systemd/system/nfs-ganesha.service.
Created symlink /etc/systemd/system/nfs-ganesha.service.wants/nfs-ganesha-lock.service → /usr/lib/systemd/system/nfs-ganesha-lock.service.

No problems after umount/mount on the client had been seen for several weeks.

Leave a Reply

Your email address will not be published. Required fields are marked *