NFS-Ganesha can publish a CephFS directory as an NFSv4 export for application hosts that cannot mount CephFS directly. The export keeps CephFS as the backing filesystem while presenting a standard NFS endpoint to Linux clients.
The nfs manager module owns the NFS cluster and stores export definitions in Ceph instead of local files on the gateway host. In this setup, cephadm manages the NFS-Ganesha daemon, cephfs is the existing filesystem name, and /cephfs is the NFSv4 pseudo path presented to clients.
Run the cluster and export commands from a Ceph admin shell that can reach the monitors. Choose a client network that should be allowed to mount the export, keep root squashing enabled unless the workload needs root identity passthrough, and prove the handoff from a separate NFS client before giving the path to applications.
Related: How to create a CephFS filesystem
Related: How to mount CephFS on Linux
Related: How to manage Ceph services with cephadm
$ ceph fs status cephfs
cephfs - 3 clients
======
RANK STATE MDS ACTIVITY DNS INOS
0 active cephfs.ceph-node1.a1b2 Reqs: 0 /s 12 15
POOL TYPE USED AVAIL
cephfs_metadata metadata 96.0M 2.0T
cephfs_data data 1.3G 2.0T
STANDBY MDS
cephfs.ceph-node2.c3d4
$ ceph mgr module enable nfs
$ ceph nfs cluster create cephfs-nfs "1 ceph-node1"
Replace ceph-node1 with the gateway host or placement string that should run the NFS daemon.
$ ceph orch ps --service_name nfs.cephfs-nfs --refresh NAME HOST PORTS STATUS REFRESHED AGE nfs.cephfs-nfs.0.0.ceph-node1 ceph-node1 *:2049 running (35s) 5s ago 35s
$ ceph nfs cluster info cephfs-nfs --format json-pretty
{
"cephfs-nfs": {
"backend": [
{
"hostname": "ceph-node1",
"ip": "192.0.2.21",
"port": 2049
}
],
"port": 2049
}
}
$ ceph nfs export create cephfs \ --cluster-id cephfs-nfs \ --pseudo-path /cephfs \ --fsname cephfs \ --path=/ \ --client_addr 192.0.2.0/24 \ --squash root_squash \ --sectype sys
Exporting / publishes the whole CephFS namespace through this NFS pseudo path. Use a subdirectory path for application-scoped exports.
$ ceph nfs export ls cephfs-nfs --format json-pretty
[
"/cephfs"
]
$ ceph nfs export info cephfs-nfs /cephfs --format json-pretty
{
"export_id": 1,
"path": "/",
"cluster_id": "cephfs-nfs",
"pseudo": "/cephfs",
"access_type": "RW",
"squash": "root_squash",
"protocols": [
4
],
"transports": [
"TCP"
],
"fsal": {
"name": "CEPH",
"fs_name": "cephfs"
},
"clients": [
{
"addresses": [
"192.0.2.0/24"
],
"access_type": "RW",
"squash": "root_squash"
}
]
}
$ sudo mkdir -p /mnt/cephfs-nfs
$ sudo mount -t nfs -o vers=4.1 ceph-node1:/cephfs /mnt/cephfs-nfs
Use the hostname, backend IP address, or ingress virtual IP returned by ceph nfs cluster info.
$ findmnt /mnt/cephfs-nfs TARGET SOURCE FSTYPE OPTIONS /mnt/cephfs-nfs ceph-node1:/cephfs nfs4 rw,relatime,vers=4.1,proto=tcp
$ printf 'nfs ganesha test\n' > /mnt/cephfs-nfs/ganesha-test.txt
Run the write as a user that has permission on the exported CephFS path. With root_squash, client-side root is mapped before CephFS permissions are checked.
$ cat /mnt/cephfs-nfs/ganesha-test.txt nfs ganesha test
$ rm /mnt/cephfs-nfs/ganesha-test.txt
$ sudo umount /mnt/cephfs-nfs