Automatically Mount NFS with Systemd

Follow this step:

  1. create network share for NFS
[[email protected] ~]# exportfs -v
/data           (sync,wdelay,hide,no_subtree_check,sec=sys,rw,no_root_squash,no_all_squash)

try those NFS mounting, with mount command:

mount 192.168.168.10:/data /share

and check:

df -h /share

if you’re successfully to mount those NFS, then unmount.

umount /share

  1. Create Systemd Unit to mount NFS

with nano/vim, create a new file /etc/systemd/system/mount-nfs

[Unit]
Description=NFS Share from nfs-server.example.com(192.168.43.10)
DefaultDependencies=no
Conflicts=umount.target
After=network-online.target remote-fs.target
Before=umount.target

[Mount]
What=192.168.43.10:/data
Where=/share
Type=nfs
Options=defaults

[Install]
WantedBy=multi-user.target

reload systemd daemon,

systemctl daemon-reload

then start it:

systemctl start mount-nfs

and check the mounting directory.

Wagiman Wiryosukiro

Petani Sistem Informasi, tukang las plugin & themes Wordpress. Co-Founder SistemInformasi.biz. Saat ini aktif sebagai Developer & kontributor di OpenMandriva Linux.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: