This article is intended for those who, out of necessity or interest, want to understand the work of the mount command a little deeper. First, let’s introduce the general concepts that are used when working with mount.
filesystem |
dir |
type |
options |
dump |
pass |
|---|---|---|---|---|---|
Your device |
Mount point |
FS type |
options |
do we make a backup? |
check fs? |
/dev/sda3 |
/home |
xfs |
rw,auto |
0 |
2 |
This entry means that the device /dev/sda3 will be mounted in the /home directory, and will be mounted automatically, read and write.
The file system type is -XFS, no backups will be made, and the integrity of the file system will be checked every time it is mounted.
We could achieve the same result by entering the following command manually:
mount -t xfs /dev/sda3 /home
Note
In summary, fstab can be considered as automation of mandatory mounts.
Moreover, it is not necessary to indicate the file type, unless it is some kind of exotic file system. The directory structure in linux is tree-like, with the root at / Each new storage medium, be it a hard drive, dvd disk, usb flash drive or network share, is mounted by mounting, and its file structure is displayed in a specific folder.
Mounting can be done manually using the command:
mount
Or automatically, for this the required disk/device must be registered in the configuration file /etc/fstab
The /etc/fstab file consists of columns separated by tab characters (TAB key).
In general, there are 6 fields:
Device, along the path (/dev/sda /dev/hda /dev/sr0 /dev/sdb1, etc.) or by the so-called unique identifier - UUID.
UUID is generated by mkfs utilities. when creating a file system. Utility blkid - shows UUIDs devices and partitions: In this case, the field looks like UUID=«550e8400-e29b-41d4-a716-446655440000
Mount point is the folder in which the file system of the connected device will be visible.
File system type - Most often you you will have to deal with fs ext4, because This is the default file system for most Linux distributions, as well as ntfs and vfat, two file systems from Microsoft.
Options - Includes additional options, such as: rw - read-write, ro - read-only. For more details, see here or here.
Dump - Used by the dump utility to determine whether data needs to be backed up on the file system. Possible values are 0 or 1. If 1 is specified, dump will create a backup. Most users do not have the dump utility installed, so they should enter 0 in this field.
Check Disk - Used by fsck to determine whether the integrity of the file system needs to be checked. Possible values are 0, 1, or 2. A value of 1 should only be specified for the root file system (with mount point /); For other filesystems that you want to check, use the value 2, which has a lower priority. Note that in the case of btrfs you should always specify 0, even if this filesystem is used as the root filesystem. File systems with a field value of 0 will not be scanned by fsck.