Home/Engineer/OS / Systems/Mounting NFS and Disks on Li…
OS / SystemsIntermediateUbuntuDebianCentOSnfsmountfstab

Mounting NFS and Disks on Linux: Persistent /etc/fstab Entries with UUIDs, NFS Clients, and Bind Mounts

A practical guide to Linux filesystem mounting: NFS server and client setup, persistent mounts with /etc/fstab, UUID-based disk mounts, tmpfs, bind mounts, and more.

Contents
  1. mount Basics
  2. /etc/fstab — Persistent Mounts
  3. NFS Server Setup
  4. NFS Client Mount
  5. Special Mounts

mount Basics

Bash
# Check current mount status
mount | column -t
df -hT

# Manual mount
sudo mount /dev/sdb1 /mnt/data

# Specify filesystem type
sudo mount -t ext4 /dev/sdb1 /mnt/data
sudo mount -t xfs  /dev/sdb2 /mnt/data2

# Unmount
sudo umount /mnt/data

# Check if in use
sudo lsof +D /mnt/data
sudo fuser -m /mnt/data

/etc/fstab — Persistent Mounts

Bash
# fstab format
# <device>  <mount point>  <type>  <options>  <dump>  <pass>

# Check UUID (mount by UUID so device-name changes don't break the mount)
sudo blkid /dev/sdb1
lsblk -f
CODE
# /etc/fstab example
UUID=a1b2c3d4-e5f6-...  /mnt/data  ext4  defaults,noatime  0  2
UUID=b2c3d4e5-f6a7-...  /mnt/ssd   xfs   defaults          0  2

Common Mount Options

OptionMeaning
defaultsrw,suid,exec,auto,nouser,async
noatimeDo not record file access times (better performance)
roRead-only
noexecDisallow executing binaries (security)
nosuidIgnore SUID bits (security)
userAllow unprivileged users to mount
nofailContinue booting even if the mount fails
Bash
# Test fstab (actually mounts)
sudo mount -a

# A specific entry only
sudo mount /mnt/data

NFS Server Setup

Bash
# Install
sudo apt install -y nfs-kernel-server

# Set up the shared directory
sudo mkdir -p /srv/nfs/shared
sudo chown nobody:nogroup /srv/nfs/shared

# Configure /etc/exports
sudo nano /etc/exports
CODE
# /etc/exports
/srv/nfs/shared  192.168.1.0/24(rw,sync,no_subtree_check)
/srv/nfs/shared  10.0.0.5(ro,sync)          # Read-only for a specific IP
/srv/nfs/shared  *(ro)                       # Read-only for everyone (use with caution)
Bash
# Apply NFS server config
sudo exportfs -ra
sudo systemctl enable --now nfs-kernel-server

# List exports
sudo exportfs -v
showmount -e localhost

NFS Client Mount

Bash
sudo apt install -y nfs-common

# Manual mount
sudo mkdir -p /mnt/nfs/shared
sudo mount -t nfs 192.168.1.100:/srv/nfs/shared /mnt/nfs/shared

# Performance options
sudo mount -t nfs -o rsize=8192,wsize=8192,timeo=14,intr   192.168.1.100:/srv/nfs/shared /mnt/nfs/shared

# Persistent mount (fstab)
echo "192.168.1.100:/srv/nfs/shared  /mnt/nfs/shared  nfs  defaults,nofail,_netdev  0  0"   | sudo tee -a /etc/fstab

# Apply
sudo mount -a

Special Mounts

Bash
# tmpfs — RAM-backed temporary filesystem
sudo mount -t tmpfs -o size=512m tmpfs /mnt/tmpdir
# fstab: tmpfs /tmp tmpfs defaults,size=1g 0 0

# bind mount — remount a directory at another path
sudo mount --bind /var/www/html /mnt/webroot
# fstab: /var/www/html /mnt/webroot none bind 0 0

# read-only remount
sudo mount -o remount,ro /mnt/data

# Diagnose mount errors
dmesg | tail -20
journalctl -k | grep -i "nfs|mount|ext4"
#nfs#mount#fstab#linux
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗

Questions & answers

Ask a question about this guide. We'll review and reply.