• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 7 : How to follow the mount order in /etc/fstab

By admin

What has changed with respect to mount order in RHEL 7

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.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. How Files/Directories in /tmp gets Removed Automatically in CentOS/RHEL 5,6
  2. SSH Login Stuck At : “debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP” CentOS/RHEL 7
  3. 5 Useful Examples of firewall-cmd command
  4. CentOS / RHEL : anacron basics (What is anacron and how to configure it)
  5. How to Schedule Tasks Using at in Linux
  6. Understanding RPM Versions and Naming Schemes
  7. Examples of creating command alias in different shells
  8. Unmounting a Windows Share Fails in Linux
  9. How to Replace a Failed Btrfs Device
  10. A File Is Claimed to Be Disappearing – How to monitor a file for deletion in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Oracle Database – Configuring Secure Application Roles
  • Extend rule sets by using factors in Oracle Database Vault
  • What are Command Rules in oracle Database
  • Using Rule Sets in Oracle Database Vault
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary