I have been experiencing random weirdness with CIFS on Ubuntu 20.04. Every now and then the current working directory will disappear. I can usually get things back to normal by “cd ..; cd myDir” but that’s a pain – more of a pain when a build has failed because the current directory evaporated on the Gradle script.
So I decided to try NFS. Setting up NFS is not too hard. I found a very useful page on LinuxConfig.org that got me 90% of the way there.
In short, on the server:
$ sudo apt install nfs-kernel-server $ sudo systemctl enable --now nfs-server
Then edit /etc/exports on the server to include the line:
It looks as if there’s no easy way for NFS to handle DHCP unless the file server can look up the IP. Boo. Going onward and knowing my network is now less protected:
$ sudo exportfs -arv
At this point, the LinuxConfig.org instructions start pointing you to server configuration. However, there’s a vital step omitted – pretty much every sane app will fail with “no locks available.” Why? StackExchange to the rescue. Enabling NFS doesn’t enable rpc-statd.
$ sudo systemctl enable rpc-statd $ sudo systemctl start rpc-statd
As the StackExchage article says, “Thanks, systemd!”
Next you can set up the client:
$ sudo mount -t nfs4 my-server-fqdn:/myshareddisk /localmnt
Hey, it mounted, and it looks like a file system. Now anyone on my network can mount my NFS server! Exposing it to ransomware and all sorts of excellent things like that. Err… good?
Last step is to make it automount on the client by editing /etc/fstab:
my-server-fqdn:/myshareddisk /localmnt nfs4 defaults,user,exec 0 2
I’m really unsure about this, and may need to undo it or at least find a way to stop it advertising to everyone. But it’s that way for now.