Articles & Snippets

How to Mount a QNAP NFS Share on a cPanel Server (Persistent After Reboot)

This guide shows how to mount a folder from a QNAP NAS on a cPanel/WHM server (AlmaLinux, CloudLinux or CentOS) from the terminal, so the mount survives restarts and can be used as a backup destination.

Example values used in this guide

QNAP IP address192.168.100.100
QNAP NFS share/bkp
Folder inside the shareservers/my-cpanel-server
Local mount point on cPanel/media/QNAP

Step 1: Enable NFS on the QNAP

  1. Log into QTS and go to Control Panel → Network & File Services → NFS Service.
  2. Enable the NFS service (NFSv3 is the safest choice for older and mixed environments).
  3. Go to Control Panel → Privilege → Shared Folders and click Edit Shared Folder Permissions for your share.
  4. Select NFS host access, enable it, and add the IP of your cPanel server with:
    • Permission: Read/Write
    • Squash option: No root squash
    • Sync: Sync

Step 2: Install the NFS client on the cPanel server

dnf install -y nfs-utils    # use yum on CentOS 7

Step 3: Check what the QNAP exports

showmount -e 192.168.100.100

Example output:

Export list for 192.168.100.100:
/bkp (everyone)

The export path (/bkp) is the name you will use in the mount command.

Step 4: Create the subfolder on the QNAP (one time only)

If you want to mount a subfolder such as servers/my-cpanel-server instead of the whole share, create it first. Mount the full share temporarily, create the folder, then unmount:

mount -t nfs -o vers=3 192.168.100.100:/bkp /mnt
mkdir -p /mnt/servers/my-cpanel-server
umount /mnt

You can also create the folder from QNAP File Station.

Step 5: Create the local mount point and test the mount

mkdir -p /media/QNAP
mount -t nfs -o vers=3 192.168.100.100:/backups/servers/my-cpanel-server /media/QNAP
df -h /media/QNAP
ls -la /media/QNAP

If df -h shows the QNAP size (for example 8.5T) and ls lists the files, the mount works.

Step 6: Make the mount permanent in /etc/fstab

Remove any old QNAP lines, then add the new one:

sed -i '\|QNAP|d' /etc/fstab
echo "192.168.100.100:/backups/servers/my-cpanel-server /media/QNAP nfs vers=3,_netdev,nofail,x-systemd.automount,x-systemd.mount-timeout=30 0 0" >> /etc/fstab
systemctl daemon-reload
umount /media/QNAP
mount -a
ls /media/QNAP
grep QNAP /etc/fstab

What the mount options do

OptionPurpose
vers=3Forces NFS version 3, which works reliably with QNAP.
_netdevWaits for the network to be up before mounting.
nofailThe server still boots if the QNAP is offline.
x-systemd.automountMounts the share on first access, avoiding boot-order problems.
x-systemd.mount-timeout=30Stops the mount attempt after 30 seconds.

Step 7: Test writing to the share

touch /media/QNAP/test.txt && rm -f /media/QNAP/test.txt && echo "write OK"

Use rm -f, because on AlmaLinux and CentOS root's rm is aliased to rm -i and will ask for confirmation. If you see Permission denied, go back to Step 1 and check the NFS host access settings.

Step 8: Reboot test

reboot

After the server comes back, run:

ls /media/QNAP && df -h /media/QNAP

If you see your files and the QNAP size, the mount is permanent.

Optional: protect against backups filling the local disk

If the QNAP is offline at boot, nofail lets the server start without the mount, and cPanel backups could write to the local disk under /media/QNAP. To prevent this, make the empty mount point immutable while it is unmounted:

umount /media/QNAP
chattr +i /media/QNAP
mount -a

To undo it, unmount the share and run chattr -i /media/QNAP.

Use it for cPanel backups

In WHM, go to Backup → Backup Configuration and set the backup directory (or add an Additional Destination) to /media/QNAP. Make sure the share is mounted before backups run.

Troubleshooting

The mount worked, but the QNAP is squashing root. Set No root squash and Read/Write for the server IP under NFS host access, then unmount and mount again.

Something is using the mount, often your own shell. Leave the folder and retry:

cd /
umount /media/QNAP
fuser -vm /media/QNAP     # shows what is still using it
umount -l /media/QNAP     # lazy unmount, last resort

Some QNAP setups only allow the exact export path. Mount the full share elsewhere and use a bind mount:

mkdir -p /mnt/qnap-bkp
mount -t nfs -o vers=3 192.168.100.100:/bkp /mnt/qnap-bkp
mount --bind /mnt/qnap-backups/servers/my-cpanel-server /media/QNAP

With x-systemd.automount the share mounts on first access. Run ls /media/QNAP and check again. For errors, use:

dmesg | tail
journalctl -xe

Quick summary

dnf install -y nfs-utils
mkdir -p /media/QNAP
echo "192.168.100.100:/backups/servers/my-cpanel-server /media/QNAP nfs vers=3,_netdev,nofail,x-systemd.automount,x-systemd.mount-timeout=30 0 0" >> /etc/fstab
systemctl daemon-reload
mount -a
df -h /media/QNAP

Designer Edmonton