• We did not send an email asking for donations - please read this post.

Viewing or removing files that are currently overmounted?

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
925
Reaction score
1,778
Credits
1,201
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.
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,567
Reaction score
2,230
Credits
11,586
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

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,962
Reaction score
3,606
Credits
36,165
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
OP
Rob

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
925
Reaction score
1,778
Credits
1,201
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.
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,962
Reaction score
3,606
Credits
36,165
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
OP
Rob

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
925
Reaction score
1,778
Credits
1,201
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 :)
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top