Bind Mounting a tmpfs doesn't show source folder [SOLVED]

Hi all,

I could have sworn that years ago when looking at your list of mounted filesystems it would tell you the source folder for bind mounts, eg ‘/abc/123 on /mnt…’. After googling my issue I found this which is the exact issue I’m having, confirming that’s the way it used to work.

I’m just wondering if anyone knows of a way I can find out the source folder of a bind mount after it’s mounted? findmnt doesn’t help, it pretty much just says the exact same thing as the results of running mount without arguments.

Any help anyone can provide would be greatly appreciated.

Can I know more about your system?

findmnt works for me on Arch

$ pwd
/home/red
$ findmnt mnt
TARGET        SOURCE               FSTYPE OPTIONS
/home/red/mnt /dev/sda3[/red/test] ext4   rw,relatime,data=ordered
$ mount --version
mount from util-linux 2.32 (libmount 2.32.0: btrfs, assert, debug)
$ uname -a
Linux redarch 4.17.2-1-ARCH #1 SMP PREEMPT Sat Jun 16 11:08:59 UTC 2018 x86_64 GNU/Linux

What you could do tho is try to grep the /proc/self/moutinfo:

$ less /proc/self/mountinfo | grep /home/red/mnt
221 84 8:3 /red/test /home/red/mnt rw,relatime shared:32 - ext4 /dev/sda3 rw,data=ordered

Just out of curiosity would lsblk work for you? I’m not too familiar with bind mounts, but I know it shows my mount source when the command is run.

lsblk only lists block devices. So it won’t show bind mount.

What bind mount does is:

Remount part of the file hierarchy somewhere else.

from man mount.

So it’s not necessarily a block device, could be any part of FS tree.

1 Like

I’m at work atm so I’ll post info when I get home. Using mountinfo looks like it would work though, I’ll try when I’m home.

1 Like

Ok, So after trying out what you’ve suggested it looks like it shows the source for bind mounting regular folders.

fish@Loken: ~ $ findmnt ~/test2
TARGET           SOURCE                      FSTYPE OPTIONS
/home/fish/test2 /dev/sdb2[/@home/fish/test] btrfs  rw,noatime,compress=lzo,ssd,discard,space_cache,autodefrag,subvolid=258,subvol=/@home/fish/test

but apparently doesn’t work for binding a folder that’s mounted as tmpfs, which is what I’m trying to accomplish. I didn’t realise that was the specific problem.

fish@Loken: ~ $ findmnt /mnt/HDD_NTFS/Linux/Heroes\ of\ the\ Storm/
TARGET                                  SOURCE                      FSTYPE OPTIONS
/mnt/HDD_NTFS/Linux/Heroes of the Storm tmpfs[/Heroes of the Storm] tmpfs  rw,relatime,size=23068672k

Ok so what I was originally trying to do was make a bash script that would create a Ramdisk at /mnt/RAMDISK as tmpfs, then copy whatever folder I specified into the ramdisk, then mount it over the original folder. I wanted this because it would make the contents of that folder read and write incredibly quickly, greatly reducing loading times and stuttering of whatever game I put in there. This part works fine.

Then when I was done with the Ramdisk, I wanted it to unbind the mount from the original folder, copy everything back and remove the tmpfs. However because it doesn’t show the source folder in the list of mounts, it’s not straightforward for the script to know which mount is the correct one in the list.

The entry in mountinfo is similar to the results of using findmnt:

fish@Loken: ~ $ less /proc/self/mountinfo |grep Heroes
183 98 0:54 /Heroes\040of\040the\040Storm /mnt/HDD_NTFS/Linux/Heroes\040of\040the\040Storm rw,relatime shared:229 - tmpfs tmpfs rw,size=23068672k

hmmm…

Don’t get the problem. It shows the source:

/Heroes of the Storm

Am I missing something?


I created a ramdisk and bound it over a dir like you did. I see the problem, it shows the pass relative to the mounted fs. Am at loss here too.

df will list all the FSs present.

$ df
Filesystem      1K-blocks      Used  Available Use% Mounted on
...
tmpfs              524288         4     524284   1% /mnt/ramdisk

Maybe this will help you? Probably not.

Maybe this will help you? Probably not.

Unfortunately not… But I did just have an idea. Because it still shows the path of what’s inside the tmpfs I can probably circumvent this issue by putting a folder with a unique name in there, then just grep for that.

eg: creating the ramdisk on /mnt/RAMDISK and putting the directory contents_of_ramdisk inside that, then mounting that would show as:
/contents_of_ramdisk /mnt/HDD_NTFS/Linux/Heroes of the Storm

Not ideal but it would probably work, I’ll give it a go when I get home from work. Thanks for your help. Very strange that bind mounts with a tmpfs function this way…

1 Like