How to Mount_Unmount Local and Network (Samba _ NFS) Filesystems in Linux?

Mounting and unmounting filesystems are essential operations in Linux that allow users to access and manage different storage devices and network resources. Whether it's local storage or network shares, properly mounting and unmounting filesystems ensures seamless data exchange and efficient utilization of resources.

This article explores the process of mounting and unmounting both local and network filesystems in Linux, covering configuration and mounting of network filesystems using Samba and NFS protocols.

Mounting Local Filesystems

Local filesystems refer to storage devices directly connected to your Linux machine, such as hard drives or solid-state drives. In Linux, these are represented by block devices identified using device files under the /dev directory (e.g., /dev/sda1, /dev/nvme0n1p1).

Using the mount Command

The mount command allows you to mount a filesystem to a specified mount point. Basic syntax

sudo mount <device-file> <mount-point>

For example, to mount partition /dev/sda1 to /mnt/data

sudo mount /dev/sda1 /mnt/data

Automatic Mounting with /etc/fstab

To automatically mount filesystems at boot, edit the /etc/fstab file

sudo nano /etc/fstab

Add an entry with the format: device mount-point filesystem options dump pass

/dev/sda1 /mnt/data ext4 defaults 0 0

Mounting Network Filesystems (Samba)

Samba is an open-source suite implementing the SMB/CIFS protocol, enabling Linux systems to access Windows shared files and resources seamlessly.

Installing Required Packages

Install Samba client packages on Ubuntu

sudo apt-get install cifs-utils

Mounting Samba Shares Temporarily

Use the mount command with CIFS filesystem type

sudo mount -t cifs //<server>/<share> <mount-point> -o username=<user>,password=<pass>

Example

sudo mount -t cifs //192.168.0.100/shared /mnt/samba -o username=myuser,password=mypass

Auto-mounting Samba Shares

Add an entry to /etc/fstab for automatic mounting

//192.168.0.100/shared /mnt/samba cifs username=myuser,password=mypass 0 0

Mounting Network Filesystems (NFS)

NFS (Network File System) enables file sharing between Unix-like systems, allowing remote directories to be mounted and accessed as if they were local.

Setting Up NFS Server

Configure the /etc/exports file to export directories

/shared 192.168.0.200(rw,sync,no_subtree_check)

Restart the NFS service after configuration changes

sudo systemctl restart nfs-server

Mounting NFS Shares

Mount NFS shares temporarily

sudo mount -t nfs <server>:<remote-directory> <mount-point>

Example

sudo mount -t nfs 192.168.0.100:/shared /mnt/nfs

For automatic mounting, add to /etc/fstab

192.168.0.100:/shared /mnt/nfs nfs defaults 0 0

Unmounting Filesystems

Unmounting ensures pending changes are written to disk and resources are released properly.

Unmounting Local Filesystems

sudo umount <mount-point>

Example

sudo umount /mnt/data

Unmounting Network Filesystems

For Samba shares

sudo umount /mnt/samba

For NFS shares

sudo umount /mnt/nfs

Comparison of Network Filesystem Protocols

Feature Samba (CIFS/SMB) NFS
Primary Use Windows-Linux interoperability Unix/Linux systems
Authentication Username/password based Host-based (IP/hostname)
Performance Good for mixed environments Optimized for Unix systems
Security Built-in encryption support Relies on network security

Conclusion

Mounting and unmounting filesystems are fundamental Linux operations for accessing local and network storage resources. Proper configuration of /etc/fstab enables automatic mounting at boot, while Samba and NFS protocols provide flexible options for network file sharing. Always unmount filesystems before disconnecting to prevent data loss.

Updated on: 2026-03-17T09:01:39+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements