How to Mount and Unmount File Systems in Linux.

The mount is a linux command that provides mount a filesystem or storage, it allow accessible and attaching to an existing directory structure.

The umount command “unmount” an existing mounted filesystem & informing the system to complete any pending read or write operations and detaching it.

List Mounted File Systems.

mount

Here is the command output.

Fig 1

To List only certain file systems.

mount -t device-name

Here is the command output.

Fig 2

Mounting a File System.

mount /dev/sdb1 /mnt/example

Check Mounted Drives.

lsblk -f

Mounting a File System Permanently using /etc/fstab.

Open /fstab file.Provide the following lines.

[File System] [Mount Point] [File System Type] [Options] [Dump] [Pass]

Example:

<file system> <mount point> <type>  <options>  <dump>  <pass>
UUID=b9df59e6-c806     /mnt/example   xfs   defaults    0       0

Mounting NFS.

Install NFS client.

yum install nfs-utils

Create a directory to provide as the mount point for the remote filesystem.

mkdir /media/nfs

Open /etc/fstab file using vim editor.Provide the following code.

# <file system>    <dir>       <type>   <options>   <dump>	<pass>
remote.server:/dir /media/nfs  nfs      defaults    0       0

Mount the NFS.

mount /media/nfs

Unmounting a File System.

umount DIRECTORY
umount DEVICE_NAME

Example:

umount /dev/sdc1

Force drive unmounting.

umount --force <device|directory>

Lazy unmount.

umount -l device-name|directory

 

Leave a Reply

Your email address will not be published.