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.
In Linux some of the directories that might have their own mount points are:
Directory | Description |
---|---|
/ | The root directory of the file system hierarchy. |
/boot | Contains boot loader files and the Linux kernel. |
/home | Contains the home directories for users. |
/mnt | A temporary mount point for mounting file systems temporarily. |
/media | Contains mount points for removable media devices such as CDs and DVDs. |
/srv | Contains data for services such as HTTP, FTP, and email. |
/tmp | A 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:
Option | Description |
---|---|
-t <file_system_type> | Specifies the file system type of the device to be mounted. |
-o <options> | Specifies mount options for the file system. |
-r | Mounts the file system in read-only mode. |
-w | Mounts the file system in read-write mode. |
-v | Runs the command in verbose mode, printing information about the mount process. |
-a | Mounts all file systems listed in the /etc/fstab file. |
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:
Option | Description |
---|---|
-l | Lazy unmount. Detaches the file system from its mount point, but keeps it mounted internally. |
-f | Forces the unmount, even if the file system is busy. |
-v | Runs the command in verbose mode, printing information about the unmount process. |
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:
Option | Description |
---|---|
-p, –priority | Specifies the priority of the swap area. Higher priority swap areas are used before lower priority areas. |
-s, –show | Displays the summary information about the swap areas. |
-h, –help | Displays help information for the command. |
Here are some commonly used options for the swapoff
command, which is used to disable swap space:
Option | Description |
---|---|
-a, –all | Disables all swap areas. |
-v, –verbose | Provides verbose output. |
-h, –help | Displays help information for the command. |
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:
Option | Description |
---|---|
-C | Enables compression. |
-o ssh_command | Specifies an alternate ssh command to use for the connection. |
-o reconnect | Enables automatic reconnection on network failure. |
-o password_stdin | Reads the password from standard input. |
References
- mount: mount file system – Linux man page
- umount: unmount file systems – Linux man page
- sshfs: filesystem client based on ssh – Linux man page
- Linux Directory Structure