Skip to content

Instantly share code, notes, and snippets.

@SecurityPhoton
Last active December 19, 2024 20:06
Show Gist options
  • Select an option

  • Save SecurityPhoton/6a33110557e14c5f037c1fcedff27023 to your computer and use it in GitHub Desktop.

Select an option

Save SecurityPhoton/6a33110557e14c5f037c1fcedff27023 to your computer and use it in GitHub Desktop.
Mount NFS disk in linux

Mount NFS disk in Debian \ Ubuntu

Asume the share is created on NFS server.

Run in bash:

sudo apt update
sudo apt install nfs-common
sudo mkdir -p /mnt/nfs_data_folder
sudo mount nfs_server_ip:/export/nfs_storage /mnt/nfs_data_folder

Then edit the fstab file for persistent mount:

nano /etc/fstab

add a line at the end (change the IP):

192.168.1.100:/export/nfs_storage /mnt/nfs_data_folder nfs _netdev,rw,bg,soft,noatime,nodiratime 0 0

_netdev:

Indicates that the filesystem is a network device.
Ensures the system waits for network services to be available before attempting to mount the filesystem.
Useful for preventing boot failures if the network is not yet up.

rw:

Mount the filesystem as read-write (allows both reading and writing).

bg:

Background retry for mounting: If the first mount attempt fails, it retries in the background.
Prevents blocking the boot process if the remote system is unreachable.

soft:

A soft mount option means that the system will time out and return an error if the server becomes unresponsive.
Safer for clients but may result in data loss if operations are interrupted.

noatime:

Disables updates to file access timestamps on reads.
Improves performance by reducing unnecessary disk writes.

nodiratime:

Similar to noatime, but specifically for directory access timestamps.
Further boosts performance by avoiding updates to directory metadata on access.

defaults:

The defaults option is a shorthand that includes a set of commonly used mount options. These are:
    rw: Read-write access.
    suid: Allow programs to run with the setuid bit.
    dev: Allow device files (e.g., /dev/null) to be interpreted on the filesystem.
    exec: Allow execution of binaries.
    auto: Automatically mount the filesystem at boot.
    nouser: Only the root user can mount the filesystem.
    async: Perform file operations asynchronously (better performance).

The defaults option is a convenience for typical mounts. You can override any of its individual components by specifying other options explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment