27

I have a NFS share folder on a FreeNas system. I'm able to mount this share and use it with this command:

mount -t nfs -o proto=tcp,port=2049 192.168.0.216:/mnt/HDD1
/media/freenas/

I just don't know how to do that in /etc/fstab so it does it automatically. How can I do that?

David Foerster
  • 36,900
  • 56
  • 98
  • 152
  • Consider also doing it with systemd: https://cloudnull.io/2017/05/nfs-mount-via-systemd/ – Philippe Gachoud Aug 13 '18 at 16:35
  • I understand that I'm a bit late to this party, but using the systemd way is ten lines of code in that one example, plus two terminal commands versus one line of code for fstab. I don't know about you, but personally, I feel like brevity is the soul of wit, and even with manually making the mount destination directory, fstab feels like the faster, cleaner option. – EvilSupahFly Apr 18 '24 at 02:40

2 Answers2

47

A typical /etc/fstab entry for a NFS mount looks like as follows:

192.168.0.216:/mnt/HDD1    /media/freenas/    nfs    defaults    0 0 

The options you supply looks pretty much default, but you can add those as well:

192.168.0.216:/mnt/HDD1    /media/freenas/    nfs    defaults,proto=tcp,port=2049    0 0 
David Foerster
  • 36,900
  • 56
  • 98
  • 152
Thomas
  • 6,463
  • 13
  • 34
  • 38
4

Edit /etc/fstab and append to the end:

192.168.0.216:/mnt/HDD1 /media/freenas/ nfs rw,bg,soft,intr,nosuid 0 0
zx485
  • 2,894
Heron
  • 41
  • 1
    .....soft and intr configure the same behavior and should not be used together. Also, soft can lead to data corruption and should not be used unless you understand the nuances deeply. – Ajax May 07 '21 at 00:43