util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mount -a inconsistency: mapper vs block device.
@ 2025-05-15  8:16 Anand Jain
  0 siblings, 0 replies; only message in thread
From: Anand Jain @ 2025-05-15  8:16 UTC (permalink / raw)
  To: util-linux; +Cc: Btrfs BTRFS, asj



Here is a simple test case that reproduces a scenario where mount -a
gets confused when an LVM non-mapper device path is used.

When the mapper path is used, verbose output reports "already mounted",
but when the actual device path is used, it reports "successfully
mounted". Since the mapper path is just a symlink to the actual dm
device, shouldn't mount -a resolve them to the same major:minor and
behave consistently?

util-linux 2.40.2 (libmount 2.40.2)


$ file /dev/dm-0
/dev/dm-0: block special (252/0)

$ file /dev/mapper/vg_fstests-lv1
/dev/mapper/vg_fstests-lv1: symbolic link to ../dm-0


------------
Create a Btrfs filesystem using an LVM device and a block device in the
same order (or using two LVM devices). We need two devices; otherwise,
the kernel doesn't go through the volume assembly path in memory.


$ mkfs.btrfs -fq /dev/dm-0 /dev/sdb > /dev/null

Udev creates the by-uuid symlink using the mapper path.

$ blkid --uuid 6e80077f-0e0d-49a6-bcb5-a9aebd4fd113
/dev/mapper/vg_fstests-lv1

mount also follows the mapper symlink.

$ mount --verbose /dev/dm-0 /mnt/scratch
mount: /dev/mapper/vg_fstests-lv1 mounted on /mnt/scratch.

However, since mkfs.btrfs used the actual device dm-0, and the mapper is
just a symlink to it, the path won't change. (I will fix mkfs.btrfs to
use the mapper path, but that will hide the subtle mount -a issue.)

$ cat /proc/self/mounts | grep scratch
/dev/dm-0 /mnt/scratch btrfs 
rw,relatime,space_cache=v2,subvolid=5,subvol=/ 0 0


$ echo UUID=c48751d4-0b34-4480-a51b-2877474c17b7 /mnt/scratch btrfs 
defaults 0 0 >> /etc/fstab

$ udevadm settle

$ mount --verbose -a
/                        : ignored
/boot                    : already mounted
/boot/efi                : already mounted
/mnt/scratch             : successfully mounted <---

$ echo $?
0
------------

Now use the device-mapper path, mount -a --verbose appears to
be correct.

------------
$ mkfs.btrfs -fq /dev/mapper/vg_fstests-lv1 /dev/sdb > /dev/null

$ blkid --uuid 3e6036f0-0187-487d-962f-9573b68e9468
/dev/mapper/vg_fstests-lv1

$ mount --verbose /dev/mapper/vg_fstests-lv1 /mnt/scratch
mount: /dev/mapper/vg_fstests-lv1 mounted on /mnt/scratch.

$ cat /proc/self/mounts | grep scratch
/dev/mapper/vg_fstests-lv1 /mnt/scratch btrfs 
rw,relatime,space_cache=v2,subvolid=5,subvol=/ 0 0

$ echo UUID=3e6036f0-0187-487d-962f-9573b68e9468 /mnt/scratch btrfs 
defaults 0 0 >> /etc/fstab

$ udevadm settle

$ mount --verbose -a
/                        : ignored
/boot                    : already mounted
/boot/efi                : already mounted
/mnt/scratch             : already mounted <--

$ echo $?
0
------------

When the mapper path is used, mount recognizes it as already mounted.
But when the block device path is used, it doesn't recognize that
it's already mounted.

Also, in the older mount version 2.37.4, mount -a fails. Any idea which
patch or patchset fixed this?

---------
mount from util-linux 2.37.4 (libmount 2.37.4:

$ mount --verbose -a :32
/                        : ignored
/boot                    : already mounted
/boot/efi                : already mounted
/Volumes/work            : already mounted

STDERR:
mount: /mnt/scratch: /dev/mapper/vg_fstests-lv1 already mounted or mount 
point busy.
--------


Thanks, Anand


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-05-15  8:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15  8:16 mount -a inconsistency: mapper vs block device Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).