SUSE Support

Here When You Need Us

mount filesystem in certain order one after the other

This document (000021169) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15 SPx
SUSE Linux Enterprise Server 12 SPx
SUSE Linux Enterprise Server for SAP Applications 15 SPx
SUSE Linux Enterprise Server for SAP Applications 12 SPx
 

Situation

With the introduction of systemd in SLE12 (and later), 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. 

For example, the expected result is to mount /opt/data2 first, then mount /opt/data1
# grep vdb /etc/fstab
/dev/vdb2       /opt/data2      xfs     defaults        0 0
/dev/vdb1       /opt/data1      xfs     defaults        0 0

But the actual result is to mount /opt/data1 first, then mount /opt/data2
# dmesg -T |grep vdb
[Mon Aug 14 14:51:34 2023] virtio_blk virtio6: [vdb] 41943040 512-byte logical blocks (21.5 GB/20.0 GiB)
[Mon Aug 14 14:51:34 2023]  vdb: vdb1 vdb2
[Mon Aug 14 14:51:38 2023] XFS (vdb1): Mounting V5 Filesystem
[Mon Aug 14 14:51:38 2023] XFS (vdb2): Mounting V5 Filesystem
[Mon Aug 14 14:51:38 2023] XFS (vdb1): Ending clean mount
[Mon Aug 14 14:51:38 2023] XFS (vdb2): Ending clean mount

# df -Th |grep vdb
/dev/vdb1      xfs       5.0G   38M  5.0G   1% /opt/data1
/dev/vdb2      xfs        15G   48M   15G   1% /opt/data2

Resolution

You can mount filesystem in certain order using "x-systemd.requires-mounts-for=" option in /etc/fstab file
# grep vdb /etc/fstab
/dev/vdb2       /opt/data2      xfs     defaults        0 0
/dev/vdb1       /opt/data1      xfs     defaults,x-systemd.requires-mounts-for=/opt/data2       0 0
# reboot
After reboot to verify
# dmesg -T |grep vdb
[Mon Aug 14 14:58:53 2023] virtio_blk virtio6: [vdb] 41943040 512-byte logical blocks (21.5 GB/20.0 GiB)
[Mon Aug 14 14:58:53 2023]  vdb: vdb1 vdb2
[Mon Aug 14 14:58:57 2023] XFS (vdb2): Mounting V5 Filesystem
[Mon Aug 14 14:58:57 2023] XFS (vdb2): Ending clean mount
[Mon Aug 14 14:58:57 2023] XFS (vdb1): Mounting V5 Filesystem
[Mon Aug 14 14:58:57 2023] XFS (vdb1): Ending clean mount

# df -Th |grep vdb
/dev/vdb2      xfs        15G   48M   15G   1% /opt/data2
/dev/vdb1      xfs       5.0G   38M  5.0G   1% /opt/data1

Since we are using fstab to perform these changes, systemd will create a service unit file for individual fstab entries inside /run/systemd/generator/
# ls -lt /run/systemd/generator/
total 56
-rw-r--r-- 1 root root 343 Aug 14 14:58 -.mount
-rw-r--r-- 1 root root 382 Aug 14 14:58 \x2esnapshots.mount
-rw-r--r-- 1 root root 398 Aug 14 14:58 boot-grub2-i386\x2dpc.mount
-rw-r--r-- 1 root root 404 Aug 14 14:58 boot-grub2-x86_64\x2defi.mount
-rw-r--r-- 1 root root 300 Aug 14 14:58 dev-disk-by\x2duuid-b929613f\x2d4f4c\x2d40e4\x2da392\x2d2ab9cf82eb32.swap
-rw-r--r-- 1 root root 370 Aug 14 14:58 home.mount
drwxr-xr-x 2 root root 300 Aug 14 14:58 local-fs.target.requires
drwxr-xr-x 2 root root  60 Aug 14 14:58 local-fs.target.wants
-rw-r--r-- 1 root root 332 Aug 14 14:58 opt-data1.mount
-rw-r--r-- 1 root root 245 Aug 14 14:58 opt-data2.mount
-rw-r--r-- 1 root root 368 Aug 14 14:58 opt.mount
-rw-r--r-- 1 root root 370 Aug 14 14:58 root.mount
-rw-r--r-- 1 root root 368 Aug 14 14:58 srv.mount
drwxr-xr-x 2 root root  60 Aug 14 14:58 swap.target.requires
-rw-r--r-- 1 root root 368 Aug 14 14:58 tmp.mount
-rw-r--r-- 1 root root 380 Aug 14 14:58 usr-local.mount
-rw-r--r-- 1 root root 368 Aug 14 14:58 var.mount

The systemd generated mount unit file as below
# cat /run/systemd/generator/opt-data1.mount
# Automatically generated by systemd-fstab-generator

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
RequiresMountsFor=/opt/data2
Before=local-fs.target
After=blockdev@dev-vdb1.target

[Mount]
Where=/opt/data1
What=/dev/vdb1
Type=xfs
Options=defaults,x-systemd.requires-mounts-for=/opt/data2

Cause

Filesystems are now just another systemd unit. Because systemd defaults to parallel units execution process startup, specific target units startup order is not consistent.

Status

Top Issue

Additional Information

# man systemd.mount
       x-systemd.requires-mounts-for=
           Configures a RequiresMountsFor= dependency between the created mount unit and other mount units. The argument must be an absolute path. This option may be specified more than once. See RequiresMountsFor= in systemd.unit(5) for details.
 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021169
  • Creation Date: 15-Aug-2023
  • Modified Date:15-Aug-2023
    • SUSE Linux Enterprise Server
    • SUSE Linux Enterprise Server for SAP Applications

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.