LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-29-2015, 08:37 AM   #1
intmail01
Member
 
Registered: May 2013
Posts: 99

Rep: Reputation: Disabled
File disappear after 2nd level of mount using "bind" filesystem


Hello,

I mount several directory structure and use "bind" option.
The problem is that files disapears at certain level.
Follow the simplified example bellow.

The source file:
Code:
/home/john/file.txt
** First bind
Code:
command: mount --bind /home/john /share/john
command: ls /share/*
result: john
command: ls /share/john/*
result: file.txt
** The next bind
Code:
command: mount --bind /share /share2
command: ls /share2/*
result: john
command ls /share2/john/*
result: nothing !
Please tell me how to acces file.txt in /share2/john/
I do this example as root user.

Thank you

Last edited by intmail01; 04-29-2015 at 08:40 AM.
 
Old 04-29-2015, 09:28 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
From "man mount"

Quote:
This call attaches only (part of) a single filesystem, not possible submounts.
Your first bind mount IS a submount so your second bind mount can't see that submount.
It may be possible to do another bind mount on top of your second bind mount to add the same subdirectory.

This is similar to the way NFS mounts work. If you export an NFS filesystem from one system to another only the filesystem itself is exported not any submounts that were mounted on top of the filesystem on the exporting server. You can export the subdirectories then NFS mount them on top of the first NFS mount on the client.

However, rather than doing bind mounts why not just make symbolic links?
 
Old 04-29-2015, 10:24 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
Quote:
Originally Posted by MensaWater View Post
From "man mount"
This call attaches only (part of) a single filesystem, not possible submounts.
And goes on to say,
The entire file hierarchy including submounts is attached a second place using
mount --rbind olddir newdir
or shortoption
mount -R olddir newdir
So, you would need
Code:
mount --rbind /share /share2
        ^
to pick up the /share/john submount.
 
1 members found this post helpful.
Old 04-30-2015, 02:00 AM   #4
intmail01
Member
 
Registered: May 2013
Posts: 99

Original Poster
Rep: Reputation: Disabled
--rbind is the solution. Thanks for all.
 
Old 04-30-2015, 02:27 AM   #5
intmail01
Member
 
Registered: May 2013
Posts: 99

Original Poster
Rep: Reputation: Disabled
Thread not really solved because the main goal is to export /share with NFS.
If I export /share through NFS the problem remains. I can't see the file.txt

** On the server /etc/exports contains line:

Code:
/share *(rw,fsid=0,sync,insecure,no_root_squash,no_subtree_check)
** On client:
Code:
command: mount -t nfs -o vers=4 server:/ /foo
command: tree /foo
result: john
There is no file.txt !
 
Old 04-30-2015, 08:25 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
Quote:
Originally Posted by intmail01 View Post
Thread not really solved because the main goal is to export /share with NFS.
If I export /share through NFS the problem remains. I can't see the file.txt
Indeed, that just isn't going to work well for an NFS export. Take a look at `man 5 exports` and note the warnings and limitations for the nohide option.
 
Old 04-30-2015, 08:50 AM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by rknichols View Post
And goes on to say,
The entire file hierarchy including submounts is attached a second place using
mount --rbind olddir newdir
or shortoption
mount -R olddir newdir
So, you would need
Code:
mount --rbind /share /share2
        ^
to pick up the /share/john submount.
D'oh! It certainly does say that and I don't know how I missed it. Thanks for the correction.

Last edited by MensaWater; 04-30-2015 at 08:51 AM.
 
Old 05-04-2015, 02:12 AM   #8
intmail01
Member
 
Registered: May 2013
Posts: 99

Original Poster
Rep: Reputation: Disabled
I tried "nohide" option in /etc/exports but no change.
 
Old 05-04-2015, 08:48 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
Quote:
Originally Posted by intmail01 View Post
I tried "nohide" option in /etc/exports but no change.
No great surprise there. The manpage does state the the option is only effective on exports to a single host, not to "*", and points out other potential problems with that option.
 
  


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
[SOLVED] Do I choose a "Journaling level" when using Ext4 filesystem? rivercat Linux - Software 1 09-27-2014 06:27 AM
XFS - can you pass "nobarriers" mount option to live filesystem? Thaidog Linux - Server 0 10-24-2011 05:07 PM
Ubuntu installed on G3 iMac, but now says "Mount of Filesystem Failed" MissKris Ubuntu 1 04-29-2010 05:25 PM
* KipBond "rescue" mode can't mount filesystem w/ LABEL=/ in fstab KipBond Red Hat 0 02-06-2008 07:09 PM
"fc5" mount does not recognize "smbfs" file system? bdplays Linux - Networking 6 06-28-2006 11:21 AM

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

All times are GMT -5. The time now is 01:28 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