Linux – Access filesystem underneath another mounted filesystem

filesfilesystemslinuxmount

The case I have is a directory that stores phone call recordings throughout the day. The root filesystem is running out of space so we added an external hard drive. This server may not be taken out of production for any reason, so what I would like to do is mount the new disk over the same recordings directory, and then after all of the calls in progress have finished I would copy them from the old filesystem into the new one.

I will be able to determine when the calls in progress during this transition have been finished up.

My question is how can I access the files beneath /var/x/y/recordings/ after I mount a new disk onto /var/x/y/recordings/?

I believe an open file should be able to finish being written to and eventually closed after a new FS is mounted over its parent directory. Is this incorrect?

Best Answer

My question is how can I access the files beneath /var/x/y/recordings/ after I mount a new disk onto /var/x/y/recordings/?

If you know that you are going to be doing this ahead of time, then you can do a mount --bind /var/x/y/recordings /foo before you mount something else into that location. The folder you did the bind mount too should still be show you the underlying filesystem instead of the one you mounted.

I believe an open file should be able to finish being written to and eventually closed after a new FS is mounted over its parent directory.

I am sorry, I am not sure about that. You may need to test on a spare box.

Related Topic