1

I have an encrypted container containing an ext4 filesystem with a subdirectory which is bind-mounted at a later point in time. If I take look at /proc/self/mountinfo, the root-directory for the mount has a value I do not know the reason for.

Steps to reproduce:

cd /tmp fallocate -l 1G container.luks cryptsetup luksFormat container.luks cryptsetup open --type=luks2 container.luks container mkfs.ext4 /dev/mapper/container mkdir /mnt/container mount /dev/mapper/container /mnt/container/ mkdir /mnt/container/subdir mkdir /tmp/abc mount -o bind /mnt/container/subdir/ /tmp/abc cat /proc/self/mountinfo ... 24 1 253:1 / / rw,noatime - ext4 /dev/dm-1 rw ... 56 24 253:5 / /mnt/container rw,relatime - ext4 /dev/mapper/container rw 57 24 253:5 /subdir /tmp/abc rw,relatime - ext4 /dev/mapper/container rw 

As per man 5 proc field #4 is

root: the pathname of the directory in the filesystem which forms the root of this mount.

Why is field #4 of the last line /subdir and not /mnt/container/subdir? Given the information for mount #57, how I am able to deduce, that mount #57 is a bind mount of a subdirectory of mount #56?

Sidenote: umount -R /mnt/container ignores mount #57.


Given the answer from Uncle Billy and several rereads of the relevant man-pages, my explanation is that /subdir is viewed from the root of a potential non-existent mount-point of device 253:5 somewhere in the system. I hope that makes some sense.

1 Answer 1

2
56 24 253:5 / /mnt/container 57 24 253:5 /subdir /tmp/abc 

Given the information for mount #57, how I am able to deduce, that mount #57 is a bind mount of a subdirectory of mount #56?

It's not. You don't deduce that.

The two mounts are only related by being mounts of the same filesystem/device (253:5); it's not that any of them is a "sub-mount" of the other or anything like that. They're independent of each other.

1
  • After reading your answer and the proc and mount manpage several times, I think I understand now and it slowly makes some kind of sense. Commented Jan 22, 2021 at 16:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.