With the introduction of systemd in RHEL 7 the boot process has become a lot faster because many services and processes are now started in parallel. One of those consequences is the lack of consistent order in which filesystems are mounted. Their order for mounting is no longer guaranteed based on the entries in /etc/fstab. Filesystems are now just another systemd “unit”. Because of the parallel nature of process startup, specific target units startup order is not consistent.

 

In RHEL7 systemd handles the mount order and not the order of mount entries in /etc/fstab. Hence, the order of entries in /etc/fstab need not be the same in which they are mounted in RHEL 7. In RHEL 6 it was a relatively simple matter of configuring your filesystems within the /etc/fstab file, specifying the order in which you would like things mounted.

 

Here is an excerpt from the man page of systemd :

Mount units may either be configured via unit files, or via /etc/fstab
(see fstab(5) for details). Mounts listed in /etc/fstab will be
converted into native units dynamically at boot and when the
configuration of the system manager is reloaded. In general,
configuring mount points through /etc/fstab is the preferred approach.

 

How to fix mount order

 

In RHEL 7 filesystems are now just another systemd “unit” type. If you happen to configure your filesystems within the /etc/fstab file, the system will simply convert these entries into dynamic “mount” unit types for the life of the running environment. You can see these dynamically created system mount unit types in /run/systemd/generator/

 

The correct location to place user-defined units is in /etc/systemd/system/. Copy each mount unit here, making any necessary adjustments to the file.

 

Note : Remove the corresponding entry for mount point from /etc/fstab when you add the entry in the /etc/systemd/system directory.

 

To fix mount order use a combination of the Requires and After unit options. This user-defined unit needs to be added for each mount point.

 

For e.g., for a ‘data’ mount point create a file /etc/systemd/system/test.mount.

[Unit]
Description= data mount
Requires=tmp.mount
After=tmp.mount

[Mount]
What=/dev/datavg/datalv
Where=/data
Type=ext4

[Install]
WantedBy=multi-user.target

 

The Requires option means this filesystem will not be mounted unless the /tmp filesystem exists. The After option means the /test filesystem will only be mounted after the /tmp filesystem is mounted.

 

Note: that if a mount point is beneath another mount point in the file system hierarchy, a dependency between both units is created automatically so you need not create a requires and after entry for /test/test1 to mount only after /test exists and is mounted.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)