Disk mounting

This article is meant for those who want to learn in details about the mount command, out of need or interest. First, let’s consider the common concepts used when working with the mount command

../_images/linux_faq_diskmount.png

filesystem

dir

type

options

dump

pass

Your device

Mount point

filesystem

options

backup needed?

check filesystem?

/dev/sda3

/home

type xfs

rw,auto

0

2

This entry means that the device /dev/sda3 will be mounted to the /home directory, and the mounting will be performed automatically, for reading and writing.

The -XFS filesystem type, no backups, the filesystem will be checked for integrity at every mounting.

We could get the same result by manually running the following command:

mount -t xfs /dev/sda3 /home

Note

Thus, fstab can be seen as automation of necessary mountings.

Moreover, it’s not necessary to state filesystem type, except for som unusual filesystem type. The directory structure in Linux has a form of a tree, with root in /. Every new data source, be it a hard drive, DVD drive, USB drive or a network resource is connected by means of mounting and its file structure is displayed in a certain directory.

Mounting can be performed manually, with the command:

mount

Or automatically, for that the required disk/device must be written to a configuration file /etc/fstab

File /etc/fstab consists of columns, separated by the tabulation symbols (TAB key).

There are 6 fields there:

  • Device by path (/dev/sda /dev/hda /dev/sr0 /dev/sdb1 e.t.c) or by its unique identifier - UUID.

UUID is generated by mkfs tools when creating a filesystem. The tool blkid - shows UUIDs of devices and partitions: In this case the field looks like UUID=550e8400-e29b-41d4-a716-446655440000

  • Mount point - the directory where the filesystem of the connected device will be displayed.

  • Filesystem type - more often you deal with ext4 as this filesystem as the default one for Linux-based distributives, and sometimes you deal with ntfs and vfat - two filesystems created by Microsoft.

  • Options - includes additional options as: rw - read-write, ro - read only. More details you may find here.

  • Dump - is used by the dump tool to define if the data backup must be created in the filesystem. Possible values are 0 or 1. If 1 is stated, dump will create a backup. The majority of users doesn’t have the dump tool installed, so you should state 0 in this field.

  • Check disk - is used by fsck tool for defining whether the filesystem must be checked for integrity. Possible values here: 0, 1 or 2. 1 should be stated only for the root filesystem (with / as the mount point); for other filesystems that you want to check use 2 value, which has lower priority. Pay attention that in case of btrfs you should always state 0, even if this filesystem is used as the root one. Filesystems with 0 value won’t be checked.