mount command to mount a NFS disk is a good test practice. Sure, but on the next system reboot, the disk will “magically disappear”. That’s why we need to write the mount configuration to the so-called
/etc/fstab file. This configuration file is responsible for storing all information regarding disks, disk partitions and their related options. In today’s cloud age, often and mostly used for mounting swap partitions.
- NFS disk setup
Step 1. Install the NFS tools.
apt-get -y install nfs-common
Step 2. In order to mount a NFS disk, we need to prepare a local directory. For instance:
mkdir -p /mnt/data
Step 3. Now, open the
/etc/fstab file and insert the following default configuration:
<NFS_IP_ADDRESS>:/data /mnt/data nfs defaults 0 0
Using default options is a good starting point. Optimize as required.
Step 4. Verify.
nfsstat -m will list the current NFS default options, also known as (flags).
/data from <NFS_IP_ADDRESS>:/mnt/data Flags: rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=3,sec=sys,mountaddr=<NFS_IP_ADDRESS>,mountvers=3,mountport=2050,mountproto=tcp,local_lock=none,addr=<NFS_IP_ADDRESS>
Additionally, you could run:
df -h --type=nfs too.
Filesystem Size Used Avail Use% Mounted on <NFS_IP_ADDRESS>:/data 100G 8G 92G 8% /data
Step 5. To be 100% sure, reboot the instance and run the verification steps above again.
If you have any other great solutions on this topic, issue, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.