Score:0

Unable to mount NFS filesystem of ubuntu 22.04 on ubuntu 18.04

am flag

I have two ubuntu systems

  1. PC1 is running ubuntu 18.04
  2. PC2 is running ubuntu 22.04

Case 1: Now server is running on 1 and client on 2. In this case file system mounted properly on PC2 that is ubuntu22.04

case 2: Now server is running on 2 and client on 1. In this case file system not mounting. Checked everything is fine. Showing the error message connection timed out.

sudo mount -t nfs -o mountvers=4.0 serverip:/Path /local/mount/point

tried with mountvers=3 also

can you please help me out for case 2.

Score:1
nu flag

Connection timed out usually means the server is ignoring your request due to a firewall, or simply the network is not configured correctly.

Checking Connectivity

Ensure you can ping the client and the client can ping the server to verify connectivity. If you can not, ensure both have IP addresses first with something such as ip -br addr and look to see if they are on the same network with valid IP address.

Configuring NFSv4

NFS using NFSv4 requires these services to work as specified by Redhat (Note I prefer using Redhat documentation as they cover more in-depth details, and are easier to navigate, but the configuration will be very similar between the 2 flavors of Linux).

nfsd
rpc.mountd
rpc.nfsd
rpc.rquotad
rpc.idmapd

Ensuring exports

Ensure your /etc/exports are correct. (This example is to allow ClientIP to mount /Path as read/write)

/Path clientIP(rw)

Run exportfs to export the nfs share. This doesnt need to be done if we restart the nfs process anyway but this will allow you to share and unshare exports without restarting the nfs service.

exportfs -a # export all shares

Configuring Firewall (Optional, but highly recommended/required if firewall is in place)

  • Using firewalld
# On server
firewall-cmd --permanent --add-service nfs
firewall-cmd --reload
systemctl restart nfs-server

# On client, this is required for NFSv4.0 but later versions from NFSv4.1 dont require it. NFSv4.1 and later do the callback on the same connection initiated by the client.
# echo "fs.nfs.nfs_callback_tcpport = <callback-port>" >/etc/sysctl.d/90-nfs-callback-port.conf
# sysctl -p /etc/sysctl.d/90-nfs-callback-port.conf
# firewall-cmd --permanent --add-port=<callback-port>/tcp
# firewall-cmd --reload
  • Using ufw
ufw allow from ClientIP to any port nfs
ufw status

Verification

Verify on the server with netstat -tuna the nfs is running.

Verify nfs works by doing systemctl restart nfs-server then check status with systemctl status nfs-server. If all is good then the server should be working.

Mounting on client

Run mount -t nfs -o nfsvers=4.0,port=2049,tcp ServerIP:/Path /local/dir

Documentation

Redhat: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_file_systems/exporting-nfs-shares_managing-file-systems#doc-wrapper

Digitalocean: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-22-04

Linuxhint: https://linuxhint.com/install-and-configure-nfs-server-ubuntu-22-04/

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.