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 -fCODE
# /etc/fstab example
UUID=a1b2c3d4-e5f6-... /mnt/data ext4 defaults,noatime 0 2
UUID=b2c3d4e5-f6a7-... /mnt/ssd xfs defaults 0 2Common Mount Options
| Option | Meaning |
|---|---|
| defaults | rw,suid,exec,auto,nouser,async |
| noatime | Do not record file access times (better performance) |
| ro | Read-only |
| noexec | Disallow executing binaries (security) |
| nosuid | Ignore SUID bits (security) |
| user | Allow unprivileged users to mount |
| nofail | Continue booting even if the mount fails |
Bash
# Test fstab (actually mounts)
sudo mount -a
# A specific entry only
sudo mount /mnt/dataNFS 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/exportsCODE
# /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 localhostNFS 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 -aSpecial 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"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.