How to mount NFS as a service?

How to mount NFS as a service?. This guide will show you how to mount NFS as a service

cd ~
sudo vi mountnfs.sh

Take a sample script in here

Edit the setting with your setting. View the example below:

# settings
target_ip=10.10.10.10
target_folder=/nfs-shared
mount_folder=/mnt/client-shared
10.10.10.10 : NFS Server IP
/nfs-shared : NFS Shared Folder
/mnt/client-shared : Linux VM Mounted Folder
sudo vi /etc/systemd/system/nfs-mount.service
[Unit]
Description=My custom startup script
# After=network.target
# After=systemd-user-sessions.service
# After=network-online.target
[Service]
# User=spark
# Type=simple
# PIDFile=/run/my-service.pid
ExecStart=/home/jackson/mountnfs.sh start
# ExecReload=/home/transang/startup.sh reload
# ExecStop=/home/transang/startup.sh stop
# TimeoutSec=30
# Restart=on-failure
# RestartSec=30
# StartLimitInterval=350
# StartLimitBurst=10
[Install]
WantedBy=multi-user.target
systemctl nfs-mount start
systemctl start nfs-mount

Leave a Reply

Your email address will not be published. Required fields are marked *