LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-12-2009, 07:40 AM   #1
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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?
 
Old 10-12-2009, 08:41 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,808

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
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.
 
Old 10-12-2009, 09:42 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by pixellany View Post
First, note a fine point: You mount (connect) filesystems to mount points. You cannot mount a partition that is not formatted.
Thanks for the hint I hope I'll remember.

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* )
 
Old 10-13-2009, 03:14 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
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
3.) waited some secs and mounted /dev/sdb11 /tmp/holy
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.
 
Old 10-13-2009, 03:33 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,808

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
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.
 
Old 10-13-2009, 06:19 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748

Original Poster
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by pixellany View Post
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.
But thats just the question: when does the program get notice about the change. What I found out is not while it already has an open file(handle). So every time a new handle is aquired the filesysteam is read.. I'm not seeing the woods for the trees. Gotta dig on some more filesystem and kernel internals

Quote:
Originally Posted by pixellany View Post
Note that "can" does not equal "good idea"....... In this case, I would think that your example would eventually give unpredictable results.
x x x
(sign here)


Quote:
Originally Posted by pixellany View Post
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.
Hm actually I dont know what I wanted to show
It just another amazing thing I found out by accident. It sure allows for some fun
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting dir takes 2 mins leupi Ubuntu 6 03-17-2007 07:59 AM
mounting smb or nfs dir to existing windows path zerovice Linux - Enterprise 2 11-02-2006 03:16 AM
Host:Dir error when mounting windows share DarkNemesis618 Linux - Networking 9 03-26-2006 02:24 AM
Mounting home dir trouble rael_kid Linux - Newbie 4 03-25-2005 12:24 AM
Mounting NFS User Dir On Login WeNdeL Linux - General 2 07-19-2004 02:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration