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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. Rpm: Error While Loading Shared Libraries: Libz.so.1: Cannot Open Shared Object File: No Such File
  2. CentOS/RHEL: How to find the package with a missing file using YUM
  3. Beginners Guide to Tuning Profiles in CentOS/RHEL
  4. Hostname change not reflecting in sar report for CentOS/RHEL
  5. How to Mount Guest Qcow2 Virtual disk Image containing LVM on KVM Host Machine
  6. How to take mailbox backup of Zimbra Account from CLI
  7. How to add or delete a samba user under Linux
  8. ifrename: command not found
  9. How to enable SFTP Logging without chroot in CentOS/RHEL
  10. lolcat: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright