Mounting two partitions to the same dir, how programs can keep apart
Hi folks,
by accident I mounted a second partition to the same directory (/mnt). In the meanwhile a earlier started program wrote to this first mounted partition. After the second partition got mounted another program accessed this one. As far as I can tell both programs where happy and did their job but my restless brain could not find a hint how the programs knew which partition to actually use. Only one I could imagine was that they had this information at startup and did not ask again. Anyone around here who can shed some light or provide a link to dig into? |
First, note a fine point: You mount (connect) filesystems to mount points. You cannot mount a partition that is not formatted.
You can mount 2 different filesystems to the same mount point---the system will always use the last one mounted. Try some experiments to see. |
Quote:
I did some minor test to see how partitions overlap but did not went very far. I have some testing in my head. 1.) Mount first filesystem 2.) start an scp copy of some files say 100MB per file 3.) mount second filesystem 4.) look where the files get written to I post back on the outcome tomorrow. (in first draft I wrote "mount first partition" again. *oh brain* ;)) |
Did some experiments today. Also I did not get any understanding of the reason why the output is illuminating
The route I went 1.) mounted /dev/sdb10 /tmp/holy 2.) Used this little script Code:
for i in $(seq 1 10); do touch /tmp/holy/$i; sleep 2; done 4.) waited some; umounted /dev/sdb11 Outcome was that some of the files where on /dev/sdb10 and some on /dev/sdb11... While trying this with an scp download the big file just remained on the first mounted filesystem... So the conclusion to this is as soon as a program is run the mounts are fixed. Now to find out why and where this information is stored in the system. |
I'm missing something....
If you omit the part about the scp download, then the conclusion is that the mounting can be changed while a program is running. Note that "can" does not equal "good idea".......:) In this case, I would think that your example would eventually give unpredictable results. But I thought the point was just to illustrate how overlapping mounts work. If you just do the mounts alternated with copying (or touching) files, I think you'll find very predictable behavior. |
Quote:
Quote:
(sign here) Quote:
It just another amazing thing I found out by accident. It sure allows for some fun |
All times are GMT -5. The time now is 09:36 AM. |