Chapter 18. Persistently mounting file systems
As a system administrator, you can persistently mount file systems to configure non-removable storage.
18.1. The /etc/fstab file Copiar o linkLink copiado para a área de transferência!
Use the /etc/fstab configuration file to control persistent mount points of file systems. Each line in the /etc/fstab file defines a mount point of a file system.
It includes six fields separated by white space:
-
The block device identified by a persistent attribute or a path in the
/devdirectory. - The directory where the device will be mounted.
- The file system on the device.
-
Mount options for the file system, which includes the
defaultsoption to mount the partition at boot time with default options. The mount option field also recognizes thesystemdmount unit options in thex-systemd.optionformat. -
Backup option for the
dumputility. -
Check order for the
fsckutility.
The systemd-fstab-generator dynamically converts the entries from the /etc/fstab file to the systemd-mount units. The systemd auto mounts LVM volumes from /etc/fstab during manual activation unless the systemd-mount unit is masked.
Example 18.1. The /boot file system in /etc/fstab
| Block device | Mount point | File system | Options | Backup | Check |
|---|---|---|---|---|---|
|
|
|
|
|
|
|
The systemd service automatically generates mount units from entries in /etc/fstab.
18.2. Adding a file system to /etc/fstab Copiar o linkLink copiado para a área de transferência!
Configure persistent mount point for a file system in the /etc/fstab configuration file.
Procedure
Find out the UUID attribute of the file system:
lsblk --fs storage-device
$ lsblk --fs storage-deviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
Example 18.2. Viewing the UUID of a partition
lsblk --fs /dev/sda1
$ lsblk --fs /dev/sda1 NAME FSTYPE LABEL UUID MOUNTPOINT sda1 xfs Boot ea74bbec-536d-490c-b8d9-5b40bbd7545b /bootCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the mount point directory does not exist, create it:
mkdir --parents mount-point
# mkdir --parents mount-pointCopy to Clipboard Copied! Toggle word wrap Toggle overflow As root, edit the
/etc/fstabfile and add a line for the file system, identified by the UUID.For example:
Example 18.3. The /boot mount point in /etc/fstab
UUID=ea74bbec-536d-490c-b8d9-5b40bbd7545b /boot xfs defaults 0 0
UUID=ea74bbec-536d-490c-b8d9-5b40bbd7545b /boot xfs defaults 0 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Regenerate mount units so that your system registers the new configuration:
systemctl daemon-reload
# systemctl daemon-reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Try mounting the file system to verify that the configuration works:
mount mount-point
# mount mount-pointCopy to Clipboard Copied! Toggle word wrap Toggle overflow