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?
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 am sorry, I am not sure about that. You may need to test on a spare box.
Instead of replacing the
/var/x/y/recordings
directory with a new filesystem, mount the new drive as/var/x/y/recordings/archive
and move older recordings from/var/x/y/recordings
to/var/x/y/recordings/archive
to free up space. Then once you are able to schedule some downtime you can move the new disk to/var/x/y/recordings
full time. You might want to look into using LVM or a similar technology to be able to expand filesystems on the fly.Tangentially related: have you considered the disk I/O performance impact of the phone calls on the external drive versus what you have internally? If you're exceeding ~40 IOPS on your current disk, you might find that it's not fast enough and it might result in hanging, choppiness and dropped calls on your PBX if you're logging synchronously.
While you can access files from both drives using (e.g.) unionfs - its not the right way to solve the problem. Mount the new drive somewhere else (or move the original files).