NFS File Access

Network File System (NFS) allows ZeroFS to share directories and files with clients over a network. Users and programs can access files on the ZeroFS mount almost as if they were local files.

Installation

No installation required - NFS clients are included in most operating systems:

  • macOS: Built-in NFS support
  • Linux: Usually pre-installed; if not: sudo apt install nfs-common (Debian/Ubuntu) or sudo yum install nfs-utils (RHEL/CentOS)
  • Windows: Enable "Services for NFS" in Windows Features

Basic Usage

Mounting ZeroFS

# Create mount point
sudo mkdir -p /mnt/zerofs

# Mount ZeroFS
sudo mount -t nfs -o nolocks,vers=3,tcp,port=2049,mountport=2049 127.0.0.1:/ /mnt/zerofs

Unmounting

# macOS/Linux
sudo umount /mnt/zerofs

# Windows
umount Z:

Mount Options

Required Options

OptionDescription
vers=3Use NFS version 3 (required by ZeroFS)
tcpUse TCP transport
port=2049ZeroFS NFS port
mountport=2049Mount protocol port
nolock/nolocksDisable NFS locking

Performance Options

OptionDescription
asyncAsynchronous I/O (better performance)
rsize=1048576Read buffer size (1MB)
wsize=1048576Write buffer size (1MB)
actimeo=120Cache attributes for 120 seconds

Reliability Options

OptionDescription
hardRetry indefinitely on failure
softFail after retrans attempts
timeo=600Timeout in deciseconds (60s)
retrans=3Number of retries

Configuration

Persistent Mounts

Add to /etc/fstab for automatic mounting:

# Linux
127.0.0.1:/ /mnt/zerofs nfs vers=3,nolock,tcp,port=2049,mountport=2049,_netdev 0 0

# With performance options
127.0.0.1:/ /mnt/zerofs nfs vers=3,nolock,tcp,port=2049,mountport=2049,async,rsize=1048576,wsize=1048576,_netdev 0 0

Multi-Client Access

To allow access from multiple machines:

# Start ZeroFS listening on all interfaces
ZEROFS_NFS_HOST=0.0.0.0 zerofs s3://bucket/path

# From client machines
sudo mount -t nfs -o vers=3,nolock,tcp server-ip:/ /mnt/zerofs

Troubleshooting

Mount Fails

# Check if ZeroFS is running
ps aux | grep zerofs

# Verify port is open
nc -zv 127.0.0.1 2049

# Check for errors
dmesg | tail -20

# Try verbose mount
mount -v -t nfs -o vers=3,nolock,tcp 127.0.0.1:/ /mnt/zerofs

Permission Denied

# NFS uses numeric UIDs/GIDs
# Check your UID
id -u

# Files created by different UIDs may not be accessible
# Use consistent UIDs across systems or run ZeroFS with specific UID

Stale File Handle

# Unmount and remount
sudo umount -f /mnt/zerofs
sudo mount -t nfs -o vers=3,nolock,tcp 127.0.0.1:/ /mnt/zerofs

Performance Issues

# Check mount options
mount | grep zerofs

# Add performance options if missing
sudo mount -o remount,async,rsize=1048576,wsize=1048576 /mnt/zerofs

# Monitor NFS statistics
nfsstat -c  # Client statistics

Advanced Usage

Custom NFS Port

# Start ZeroFS on custom port
ZEROFS_NFS_HOST_PORT=2050 zerofs s3://bucket/path

# Mount using custom port
sudo mount -t nfs -o vers=3,nolock,tcp,port=2050,mountport=2050 127.0.0.1:/ /mnt/zerofs

Read-Only Mount

# Mount as read-only
sudo mount -t nfs -o vers=3,nolock,tcp,ro 127.0.0.1:/ /mnt/zerofs-ro

Autofs Configuration

For on-demand mounting, configure autofs:

# /etc/auto.master
/mnt/auto /etc/auto.zerofs --timeout=60

# /etc/auto.zerofs
zerofs -fstype=nfs,vers=3,nolock,tcp,port=2049,mountport=2049 127.0.0.1:/

Security Considerations

NFS Limitations

Be aware of these NFS characteristics:

  • No File Locking: ZeroFS doesn't support NFS locking protocols
  • UID/GID Mapping: NFS uses numeric IDs, not usernames
  • Stateless Protocol: No persistent connections
  • Cache Coherency: Multiple clients may see stale data briefly
  • fsync Limitations: Due to NFS COMMIT semantics, fsync operations may not provide the durability guarantees expected. Applications requiring strict fsync behavior should consider using 9P instead.

Next Steps

Was this page helpful?