How to mount the filesystem when the mount point is a symlink?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 8,9,10
    • EXT4
    • XFS

Issue

Resolution

  • Systemd generates .mount units based on real paths, not symbolic
    links.
  • Avoid using symbolic links as mount points in /etc/fstab across all
    RHEL versions.
  • Use real, canonical directories as mount points

Root Cause

Mounting a filesystem where the target directory is a symlink is not a supported or reliable method. The behavior varies slightly between RHEL versions due to changes in how systemd and mount units handle symlink resolution and canonical paths.

Diagnostic Steps

  • Mount EXT4 and XFS filesystems:
# cat /proc/self/mounts | grep -i /test
/dev/mapper/vg1-lv1 /test1 ext4 rw,seclabel,relatime 0 0
/dev/mapper/vg1-lv2 /test2 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
  • Create a symlink of EXT4 & XFS mount-point:
# ln -s /test1   /test3
# ln -s /test2 /test4
# ls -l /test3 /test4

lrwxrwxrwx. 1 root root 6 May 28 12:06 /test3 -> /test1
lrwxrwxrwx. 1 root root 6 May 28 12:07 /test4 -> /test2
  • Add entries in fstab.
/dev/mapper/vg1-lv1 /test3 xfs defaults 0 0
/dev/mapper/vg1-lv2 /test4 ext4 defaults 0 0
  • Reboot the system.
  • The filesystem is mounted on the canonical path (/test1 & /test2)
# cat /proc/self/mounts | grep -i /test

/dev/mapper/vg1-lv2 /test2 xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
/dev/mapper/vg1-lv1 /test1 ext4 rw,seclabel,relatime 0 0

RHEL 8:

May 28 03:04:57 rhel8 systemd[1]: Mounted /test1.
-- Subject: Unit test1.mount has finished start-up
-- Unit test1.mount has finished starting up.
May 28 03:04:57 rhel8 systemd[1]: Mounting /test2...
-- Subject: Unit test2.mount has begun start-up
-- Defined-By: systemd
-- Unit test2.mount has begun starting up.
May 28 03:04:57 rhel8 kernel: XFS (dm-3): Ending clean mount
May 28 03:04:57 rhel8 kernel: XFS (dm-2): Ending clean mount
May 28 03:04:57 rhel8 systemd[1]: Mounted /test1.
-- Subject: Unit test1.mount has finished start-up
-- Unit test1.mount has finished starting up.
May 28 03:04:57 rhel8 kernel: EXT4-fs (dm-4): mounted filesystem with ordered data mode. Opts: (null)
May 28 03:04:57 rhel8 systemd[1]: Mounted /test2.
-- Subject: Unit test2.mount has finished start-up
  • In RHEL 8, mounting a filesystem using a symlink as the mount point in /etc/fstab generally works, but the
    symlink is internally resolved to its real path

  • The mount operation succeeds on the canonical path, and systemd generates the .mount unit based on the actual
    directory, not the symlink

RHEL 9:

May 28 12:52:52 ansihost systemd[1]: Mounting /test1...
░░ Subject: A start job for unit test1.mount has begun execution
░░ A start job for unit test1.mount has begun execution.
May 28 12:52:52 ansihost kernel: XFS (dm-3): Mounting V5 Filesystem 770071cb-c2a1-4361-8cf0-4e2ef15b3ccb

May 28 12:52:52 ansihost systemd[1]: Mounting /test2...
░ Subject: A start job for unit test2.mount has begun execution
May 28 12:52:52 ansihost systemd[1]: Starting File System Check on /dev/disk/by-uuid/07D5-760B...
░░ Subject: A start job for unit systemd-fsck@dev-disk-by\x2duuid-07D5\x2d760B.service has begun execution
May 28 12:52:52 ansihost kernel: XFS (dm-3): Ending clean mount
May 28 12:52:52 ansihost systemd[1]: Mounted /test1.
░░ Subject: A start job for unit test1.mount has finished successfully
░░ A start job for unit test1.mount has finished successfully.

  • Resolves symlink paths to their canonical targets and generates .mount units based on real paths (not symlinks)

RHEL 10:

May 28 12:11:31 RH10 systemd[1]: Mounting test1.mount - /test1...
░░ Subject: A start job for unit test1.mount has begun execution
A start job for unit test1.mount has begun execution.
May 28 12:11:31 RH10 systemd[1]: Mounting test2.mount - /test2...
░░ Subject: A start job for unit test2.mount has begun execution
░░ A start job for unit test2.mount has begun execution.
May 28 12:11:31 RH10 kernel: XFS (dm-2): Mounting V5 Filesystem e5813c74-a288-4bb0-b632-a82bfb99e3de
May 28 12:11:31 RH10 kernel: XFS (vda2): Mounting V5 Filesystem ff7547c1-0c8c-4e31-baa6-9d6a9fd75404
May 28 12:11:31 RH10 kernel: XFS (dm-2): Ending clean mount
May 28 12:11:31 RH10 systemd[1]: Mounted test1.mount - /test1.
░░ Subject: A start job for unit test1.mount has finished successfully
░░ A start job for unit test1.mount has finished successfully.

May 28 12:11:31 RH10 systemd[1]: Mounting test2.mount - /test2...
░░ Subject: A start job for unit test2.mount has begun execution
░░ 
░░ A start job for unit test2.mount has begun execution.
May 28 12:11:31 RH10 kernel: XFS (dm-2): Mounting V5 Filesystem e5813c74-a288-4bb0-b632-a82bfb99e3de
May 28 12:11:31 RH10 kernel: XFS (vda2): Mounting V5 Filesystem ff7547c1-0c8c-4e31-baa6-9d6a9fd75404
May 28 12:11:31 RH10 kernel: XFS (dm-2): Ending clean mount
  • RHEL 10 is more strict with canonical path resolution

  • Systemd mount units are tightly bound to the UUID + real directory path.

  • Even if /test3 & /test4 is specified in /etc/fstab, systemd will mount at /test1 and /test2, based on UUID
    resolution.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments