mounting nfs shares in ubuntu server
During setup of our home NAS my household (mostly me) decided to separate our media services and our media files into two separate servers. This would help to keep our file storage server's resources separate from our application server's resources.
I'd never mounted a network file share before, so I thought I'd document the procedure.
Reading about a Network File System File permissions number calculator
Steps + commands
- ssh to your server, mine was internal.
ssh [email protected]
- Determine your mount point from the NAS, I did this by running the following on the NAS server.
- Note: We use an OpenMediaVault server, so our NFS mounts are under
/export/
- Note: We use an OpenMediaVault server, so our NFS mounts are under
ls -l /export/
# output sample
root@your-nas:~# ls -l /export/
total 4
drwxrws--- 2 root users 4096 Dec 8 17:25 MediaShare
- Create your mount point
mkdir -p /mnt/your-mount-here
- Use the above information to mount to your destination server.
sudo mount -t nfs4 192.168.1.234:/export/MediaShare /mnt/your-mount-here
- Now make the mount persist on reboots, if you don't want the mount to persist then skip this step.
sudo umount /mnt/your-mount-here/
- Edit the
fstab
to include our mount, use elevated permissions to allow writes to it
# ... some other stuff
191.168.1.234:/export/MediaShare /mnt/your-mount-here nfs defaults 0 0
- Set the permissions that you need, I did a
chown
for my user and set the files to755
sudo chown -R ${USER:GROUP} /mnt/your-mount-here/
sudo chmod -R 755 /mnt/your-mount-here/
-
Test and check the permissions to ensure you don't have errors
- I first ran a
stat
to check permissions
stat /mnt/your-mount-here/ you@your-server:/$ stat /mnt/your-mount-here/ File: /mnt/your-mount-here/ Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fd00h/64768d Inode: 3145730 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 1000/ you) Gid: ( 0/ root) Access: 2021-12-09 01:51:14.485360884 +0000 Modify: 2021-12-09 01:43:15.653176950 +0000 Change: 2021-12-09 01:51:14.485360884 +0000 Birth: -
- I also created a test file to check for errors
touch /mnt/your-mount-here/test.py
- I first ran a