The mount point refers to the location in the file system hierarchy where a file system is attached to. In Linux, each file system is represented as a separate entity and can be mounted at a specific mount point in the file system hierarchy. This allows different file systems to be used and managed separately, even though they are all part of the same file system.

image 2
Linux Mount Points

In Linux some of the directories that might have their own mount points are:

DirectoryDescription
/The root directory of the file system hierarchy.
/bootContains boot loader files and the Linux kernel.
/homeContains the home directories for users.
/mntA temporary mount point for mounting file systems temporarily.
/mediaContains mount points for removable media devices such as CDs and DVDs.
/srvContains data for services such as HTTP, FTP, and email.
/tmpA temporary directory for storing files that are needed only temporarily.

These directories are the default directories in Linux, but you can create your own mount points and mount file systems at any directory you choose. The mount command is used to attach a file system to a specified mount point in the file system hierarchy, and the unmount command is used to detach a file system from its mount point. Lets these commands them in detail.

mount

The mount command is used to attach a file system to a specified mount point in the file system hierarchy. Here are some of the most commonly used option flags for the mount command:

OptionDescription
-t <file_system_type>Specifies the file system type of the device to be mounted.
-o <options>Specifies mount options for the file system.
-rMounts the file system in read-only mode.
-wMounts the file system in read-write mode.
-vRuns the command in verbose mode, printing information about the mount process.
-aMounts all file systems listed in the /etc/fstab file.
mount: most commonly used options

Here is an example of how to use the mount command:

mount -t ext4 /dev/sda1 /mnt/data

In this example, the mount command is being used to mount the /dev/sda1 partition as an ext4 file system at the /mnt/data mount point. The -t option is used to specify the file system type, and the /dev/sda1 and /mnt/data arguments specify the device and mount point, respectively.

unmount

The unmount command is used to detach a file system from its mount point. Here are some of the most commonly used option flags for the unmount command:

OptionDescription
-lLazy unmount. Detaches the file system from its mount point, but keeps it mounted internally.
-fForces the unmount, even if the file system is busy.
-vRuns the command in verbose mode, printing information about the unmount process.
unmount: most commonly used options

Here is an example of how to use the unmount command:

unmount /mnt/data

In this example, the unmount command is being used to detach the file system mounted at /mnt/data. The argument /mnt/data specifies the mount point of the file system that is to be unmounted.

/etc/fstab

The file /etc/fstab is a configuration file that contains information about file systems that are to be mounted automatically at boot time. This file lists all the file systems that are to be mounted, along with the mount options and other information such as the mount point, file system type, and device name.

Each line in /etc/fstab represents a file system and its associated information, separated by whitespace. Here is an example of a line in /etc/fstab:

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

In this example, the file system located at /dev/sda1 is to be mounted at the mount point /mnt/data, using the file system type ext4 and with the default mount options. The last two fields, 0 0, represent the dump and pass fields, respectively. These fields are used by the dump command, which is a backup utility that is not commonly used.

The /etc/fstab file is read by the mount command when the system boots. The mount command uses the information in /etc/fstab to mount all file systems listed in the file automatically, without the need for manual intervention. This makes it convenient for users, as all required file systems are automatically mounted and ready for use when the system boots up.

swap

Swap is a special type of file system that provides virtual memory for the system. Virtual memory is a feature that allows the system to temporarily use disk space as an extension of physical memory (RAM) to accommodate large amounts of data.

Swap can be created as either a separate partition or as a swap file. The most common way to create a swap partition is during the installation of the operating system.

Here are some commonly used options for the swapon command, which is used to enable swap space:

OptionDescription
-p, –prioritySpecifies the priority of the swap area. Higher priority swap areas are used before lower priority areas.
-s, –showDisplays the summary information about the swap areas.
-h, –helpDisplays help information for the command.
most commonly used options for enabling swap

Here are some commonly used options for the swapoff command, which is used to disable swap space:

OptionDescription
-a, –allDisables all swap areas.
-v, –verboseProvides verbose output.
-h, –helpDisplays help information for the command.
most commonly used options for disabling swap

sshfs

sshfs is a file system client for mounting remote file systems over an SSH connection. It allows you to access files on a remote file system as if they were stored locally on your own file system. This can be useful for accessing remote file systems for backup, collaboration, or other purposes. Here’s an example of how you can use sshfs to mount a remote file system:

sshfs user@remote:/path/to/remote/dir /path/to/local/mountpoint

In this example, user@remote is the remote user and host, and /path/to/remote/dir is the path to the remote directory you want to mount. The /path/to/local/mountpoint is the local directory where the remote file system will be mounted.

Here are some commonly used options for the sshfs command:

OptionDescription
-CEnables compression.
-o ssh_commandSpecifies an alternate ssh command to use for the connection.
-o reconnectEnables automatic reconnection on network failure.
-o password_stdinReads the password from standard input.
sshfs: most commonly used options

References