LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-08-2008, 09:11 AM   #1
mr.neil
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Rep: Reputation: 0
nfs and bind-mount order in /etc/fstab


How can I bind-mount local directories into part of the tree delivered via nfs at boot time? For example, if /var/chroot/etch-ia32 is on another machine and mounted via nfs how can I bind-mount the local /tmp directory at var/chroot/etch-ia32/tmp at boot time?

/etc/fstab:
137.xxx.xxx.xxx:/var/chroot/etch-ia32 /var/chroot/etch-ia32 nfs defaults,ro 0 0
/tmp /var/chroot/etch-ia32/tmp none bind 0 0

The problem is that at boot time the second entry for /tmp is mounted before the first entry for /var/chroot/etch-ia32, so that the contents of /var/chroot/etch-ia32/tmp end up being masked. Mounting these manually in the right order works, so how can I force the order in /etc/fstab to be honored at boot time? All comments extremely welcome.
 
Old 05-09-2008, 12:03 PM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 475

Rep: Reputation: 73
add _netdev to your bind mount to postpone it being mounted.

Code:
/tmp/  /var/chroot/etc-ia32/tmp  none  _netdev,bind 0 0
since the fs-type is nfs for the nfs mount it waits for networking to be available before attempting to mount.

Hope this helps.
 
Old 05-09-2008, 05:03 PM   #3
mr.neil
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you very much for this suggestion---hugely appreciated. Adding _netdev does indeed prevent /var/chroot/etch-ia32/tmp from mounting. So this is almost a complete solution. The remaining problem is that /var/chroot/etch-ia32/tmp does not get mounted at all during boot. (I can't find any errors or reports in the log files either.) While this is obviously better than having it mounted in the wrong order and thus masked by the nfs mount of /var/chroot/etch-ia32, is there any way to have /var/chroot/etch-ia32/tmp mounted _after_ the nfs mounts during boot? I could, for example, add mount commands to rc.local, but maybe there is a better way?
 
Old 05-09-2008, 05:08 PM   #4
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 475

Rep: Reputation: 73
hmmm, not sure off-hand. rc.local (like you note) could do the trick. just toss a 'mount -a' or call the bind mount from within rc.local. If you wanted to get "fancier" you could write a script around it that would check to see if it is mounted and, if not, mount it for you.
 
Old 05-12-2008, 07:00 AM   #5
mr.neil
LQ Newbie
 
Registered: Jun 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Your suggestion in fact worked perfectly. I'd accidentally included a noauto in the options for /var/chroot/etch-ia32/tmp which messed things up by preventing it from being automatically mounted at boot. But with these entries in /etc/fstab

/etc/fstab:
137.xxx.xxx.xxx:/var/chroot/etch-ia32 /var/chroot/etch-ia32 nfs defaults,ro 0 0
/tmp /var/chroot/etch-ia32/tmp none _netdev,bind 0 0

everything gets mounted at boot, with the nfs partition mounted first and then the bind-mount of /tmp.

Thanks again for your help.
 
Old 05-12-2008, 08:55 AM   #6
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 475

Rep: Reputation: 73
Thanks for the followup response. I thought it odd to not have worked but I didnt have access to the system where I'd configured something similar to check my exact configuration(s) for comparison.

Good to hear it is working for you.
 
Old 06-16-2008, 02:41 AM   #7
jononeuk
LQ Newbie
 
Registered: Feb 2007
Location: London, UK
Distribution: Ubuntu 8.04
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by rayfordj View Post
rc.local (like you note) could do the trick. just toss a 'mount -a' or call the bind mount from within rc.local. If you wanted to get "fancier" you could write a script around it that would check to see if it is mounted and, if not, mount it for you.
Perhaps because my NFS server is an old SunBlade, the _netdev trick + 'mount -a' in rc.local didn't work for me - it seems like there's a delay of about 5-10 seconds before the NFS mount is ready. Here's a "fancier" script that does the job

Code:
#!/bin/bash

(( "$#" == 0 )) && exit 

declare -i count

for mountpoint in "$@" ; do
    count=0
    while ! mount | grep "$mountpoint" > /dev/null ; do
        if mount "$mountpoint" 2>&1 | grep '/etc/fstab' > /dev/null ; then # not in fstab
            break
        fi
        if mount | grep "$mountpoint" > /dev/null ; then # successful mount
            echo "Mounting of $mountpoint SUCCESSFUL after $count tries"
            break
        fi
        count=count+1
        if (( "$count" >= 5 )) ; then # too many retries
            echo "Mounting of $mountpoint UNSUCCESSFUL after $count tries"
            break
        fi
        sleep 5
    done
done
call this script, followed by a list of mount points, from /etc/rc.local
 
  


Reply

Tags
fstab, nfs


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
NFS mount in /etc/fstab ? cozye Linux - General 3 09-12-2014 03:48 PM
Can't mount nfs share from fstab but can mount it manually - help Mountain Linux - Networking 1 03-30-2008 08:34 PM
mount --bind (fstab problem) renski Linux - General 2 11-17-2005 03:50 PM
nfs mount with fstab vs autofs rrich100 Linux - Networking 2 11-13-2003 10:21 PM
how do I mount with nfs in fstab? Falafel Linux - Networking 1 11-13-2003 12:56 PM


All times are GMT -5. The time now is 11:22 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration