Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just accidentally mounted a new drive to a folder that already contained files. I don't care about them and have them somewhere else, but that folder appears empty now. I'm curious what happened to the files. Are they simply deleted by Linux?

share|improve this question
    
They don't "go" anywhere. You just can't see them. –  Shadur Jun 22 '12 at 4:42
6  
They go to the same place where characters from books go when you're not reading them. –  Andrew Beals Jun 22 '12 at 21:26
3  
This is one of the amusing functions/features of mounting that I use/abuse sometimes to know the state of some things. Some mount points (the directory), I will leave an empty file not mounted in so that if I browse into it, I'll know immediately that it wasn't mounted for whatever reason. –  killermist Jun 23 '12 at 4:46

2 Answers 2

up vote 26 down vote accepted

Just shadowed. Will be there again when unmounted. :) Though, if you're curious, you can reach them right now using mount --bind /Original/FS/Mount/Point /Somewhere/Else.

It's also worth noting Aufs, just in case. ;)

share|improve this answer

The newly mounted filesystem is like an overlay which hides part of the initial filesystem. There are trick to access the files, like the bind mount as described by poige. On Linux I personally like the fact that you can mount a filesystem more than once on different mount points. So you can perfectly well mount the root filesystem on / aswell as on /mnt. This comes in handy while debugging lost space / lost files / counting disk usage / ...

Gotcha's:

  • The old files are still there and using up space. It is a common mistake to have 'missing' disk space in files hidden by a mount. Eg. when you accidentally wrote large files in a directory and at some time decided to mount a filesystem on it. Eg. accidentally starting a large database before the logging filesystem was properly mounted ...
  • When a program has a file open which is subsequently hidden by a newly mounted filesystem, the program won't care about it and succesfully keeps using the 'hidden' file until it closes it. From that moment the file comes invisible to the process until the new filesystem is unmounted and the underlying directory shows up again.
share|improve this answer
    
Very interesting that you can mount a filesystem more than once. This feels like it will come in handy. –  T. Brian Jones Jun 22 '12 at 7:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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