LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How does mount work? (https://www.linuxquestions.org/questions/linux-newbie-8/how-does-mount-work-670375/)

silverbird 09-16-2008 08:56 PM

How does mount work?
 
I have created a data partition which I wish to share with other users. To achieve this I create a 'dummy' directory and then mount the partition directories to the newly created directory.

For example I have /home/shared/serverA directory and I then mount directories in another partition into that directory.

What happens to the directory I created? Suppose before I mount the new partition there are files in the serverA directory. These files are not overwritten, so are they just hidden somehow? Does mounting change a pointer in the linux file system to point to the new partition?

I am curious. It seems that you almost need to be able to create virtual directories that can then be used as mount points for other resources.

BrianK 09-16-2008 09:10 PM

To be honest, I don't know the exact details on how mount works, but the files that you speak of - the ones that are present in a directory before you mount... they still exist, their parent directory just points somewhere new now, so there's no way to get to them. As soon as you unmount, their parent directory no longer points elsewhere, therefore, you can get to them again. Remember, directories are just special files, so mounting to a directory is kinda like modifying a file so that it does *something else* when you ask for its data.

anecdote: At one company for which I did some work, I had a RAID array that mounted to /job. If the array didn't mount, /job just pointed to the system disk, so I put some files on the system disk in /job that contained instructions on how to remount the array. /job was an nfs export, so if someone went looking for raid data via /job & the raid wasn't mounted, they would have instructions on how to get the RAID back. Once the RAID was remounted, the instructions would magically disappear.


All times are GMT -5. The time now is 06:49 PM.