Viewing or removing files that are currently overmounted?

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
1,210
Reaction score
2,240
Credits
3,485
So, I ran into an issue today where I believe some files exist under a directory that is currently used as a mountpoint for a running application. Meaning, prior to that mountpoint being used, files already existed under that directory and are now hidden by the system because that directory is now being used as a mountpoint.

Does anyone know, without unmounting, a way to list or remove files in the mountpoint directory without affecting files on the mounted filesystem?

Example:

/test1 is a mountpoint for /dev/sdc1

Prior to mounting sdc1, I create /test1/file1.txt
Then, I mount /dev/sdc1 on /test1

How can I list out the hidden file1.txt without unmounting sdc1? I've never even ever thought of this before lol.
 


No way I know of, without unmounting.
 
That’s an interesting one. I’ve never tried putting anything into a directory where I was going to mount another file-system. And never really considered what might happen if you mounted a filesystem on top of a directory that already contains files either….. Hmm….
 
  • Like
Reactions: Rob
I've done it sometime ago, what happens is the files there stay there and you only get to see the files of the filesystem mounted on that directory. When you unmount that filesystem again you are able to see the files and directories in the original directory again. The only way I can think of without having to unmount the filesystem on that directory is to clone the original partition of the mount point being used is to to clone it with dd and then clone it to another newly create partition and then mount that new partition else where so you can check what files and directories are there.
 
  • Like
Reactions: Rob
Well, here's the thing. In the above example, / is 15G .. and /test1 has about 13G of data written on it prior to mounting /dev/sdc1 on /test1. The application writing to /dev/sdc1 is a giant pita to stop, so I can't unmount it..

I could grow the disk which is /, but imo that'd be cheating.
 
Yeah that makes it different situation and then my suggestion won't work. Why is growing the root(/) volume cheating, that's what lvm is for?
 
  • Like
Reactions: Rob
Yeah that makes it different situation and then my suggestion won't work. Why is growing the root(/) volume cheating, that's what lvm is for?
Well, because then the files taking up the 13g get away with it and make me spend more on storage when I don't have to lol :)
 

Members online


Top