3

I have a system with following /etc/mtab:

/dev/disk/by-label/foobar /etc/somefile ext4 rw,relatime,data=ordered 0 0
/dev/disk/by-label/foobar /var/lib/somedir ext4 rw,relatime,data=ordered 0 0
/dev/disk/by-label/foobar /mnt/foobar ext4 rw,relatime,data=ordered 0 0
/dev/disk/by-label/foobar /mnt/foobar/somedir ext4 rw,relatime,data=ordered 0 0

i.e. the same device mounted in different mount points. What's more:

  1. Those directories have different contents (this precludes mount --bind case)
  2. Some of those mount points are regular files

Strangely enough, df -h shows only one of those mount points:

/dev/disk/by-label/foobar    2.8G   70M  2.6G   3% /mnt/foobar

How is this possible? What's going on?

  • 3
    The most authoritative place you can view your mounts is in /proc/self/mountinfo I would suggest you look there for your answers. – Matthew Ife Mar 15 '17 at 14:56
2

/etc/mtab is showing the result of using bind mounts, is my guess. You can bind mount any directory, and I suspect you are seeing the result of that.

$ mkdir test/ /tmp/test
$ sudo mount --bind test/ /tmp/test
$ cat /proc/mounts
<..snip...>
/dev/root /tmp/test ext4 rw,noatime,data=ordered 0 0

This question provides a more in-depth explanation/example: https://unix.stackexchange.com/questions/128471/determine-what-device-a-directory-is-located-on

df -h is not showing these because bind mounts are 'dummy' filesystems, and df requires -a to show those.

|improve this answer|||||
  • 1
    Yes, that seems to be the case. What was new to me, "One can also remount a single file (on a single file). It's also possible to use the bind mount to create a mountpoint from a regular directory" (man mount) – el.pescado Mar 16 '17 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.