LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2013, 11:41 AM   #1
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Rep: Reputation: Disabled
autofs configuration


I need to delay the mount of my NFS shares until after my wlan0 connects to the network. Exactly like this thread, http://ubuntuforums.org/showthread.php?t=1491137
I have searched and found many options I don't understand.

http://linux.about.com/library/cmd/b...uto.master.htm
http://linux.about.com/od/commands/l/blcmdl5_autofs.htm
https://help.ubuntu.com/community/Autofs
http://www.linuxtopia.org/online_boo...ig-autofs.html
http://linux.die.net/man/5/autofs

I have a NAS running Freenas 8.3.1 it has 2 pools and 2 NFS shares
share 1 is named 'media' path 192.168.2.xx:/mnt/media
share 2 is named 'music' path 192.168.2.xx:/mnt/music
I have created only 1 user (me) in Freenas.

I have installed autofs but can't figure out how to set it up.
My mount points are /home/travis/Videos/Movies and
/home/travis/Music
these are the paths I've mapped for xbmc and the folders I use to manage the content.
I know I need to add to the auto.master something like this
/home/travis/Videos/Movies /etc/auto.Movies
/home/travis/Videos/Music /etc/auto.Music
/mnt yp:mnt.map
so my auto.master looks like this
Code:
/home/travis/Videos/Movies     /etc/auto.nfs
/home/travis/Videos/Music      /etc/auto.nfs
/mnt      yp:mnt.map
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
#/misc	/etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#	"nosuid" and "nodev" options unless the "suid" and "dev"
#	options are explicitly given.
#
/home/travis	-hosts
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
/nfs   /etc/auto.nfs
what I don't get is what next.
I know I need the IP address and the mount points for the shares somewhere so autofs knows where the files are.
I am trying to follow this but I don't really want the root directory mounted.
https://help.ubuntu.com/community/Autofs
Code:
Now we will create the file which contains our automounter map:

    $ sudo nano /etc/auto.nfs

This file should contain a separate line for each NFS share. The format for a line is {mount point} [{mount options}] {location}.
 If you have previously configured static mounts in /etc/fstab, it may be helpful to refer to those. 
Remember, the mount points specified here will be relative to the mount point given in /etc/auto.master.

The following line is for shares using older versions of NFS (prior to version 4):

    server   server:/

This creates a new mount point at /nfs/server/ and mounts the NFS root directory exported by the machine whose host-name is server.

4.2.1. NFSv4

If your NFS shares use NFSv4, you need to tell autofs about that. In such a case, the above line would appear as follows:

    server   -fstype=nfs4   server:/

The client needs the same changes to /etc/default/nfs-common to connect to an NFSv4 server.

    In /etc/default/nfs-common we set:

    NEED_IDMAPD=yes
    NEED_GSSD=no # no is default
My auto.nfs only has 2 entries.

"192.168.2.xxx -fstype=nfs 192.168.2.69:/mnt/media/Movies
192.168.2.xxx -fstype=nfs 192.168.2.69:/mnt/media/Music

what am i missing?

Thanks to all.
 
Old 04-30-2013, 12:49 PM   #2
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
So after rebooting all the things I did corrupted something to the point where I could do nothing because ALL permissions for Casa(?) were changed. I kept getting the error message about needing read/write permissions. then Mint menu wouldn't come up. alt f1 poped it up on the desktop but anything I selected wouldn't open.
I couldnt even get to a terminal. I had to boot from my emergency thumb drive and rename my auto.master, auto.misc, and auto.nfs to get the box to boot.


OOOps.......
 
Old 04-30-2013, 01:15 PM   #3
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
yes your auto.nfs should read as follows:

Code:
mount_point     -fstype=nfs4,bg     IP:/full/path/to/share
so to be a bit more specific:

Code:
/nfs     -fstype=nfs4,bg     192.168.2.69:/mnt/media/
if you configured NFSv4 correctly you will only have a single entry for the share. your exports should look something like the following:

Code:
cat /etc/exports 
#
#	/etc/exports

#	NFS4
/exports *(rw,insecure,subtree_check,crossmnt,fsid=0)

#	NFSv3
/exports/centos/public *(rw,insecure,no_subtree_check,fsid=3010)
/exports/NFS_TV_Shows *(rw,insecure,no_subtree_check,fsid=3020)
note the use of fsid=#### and that all three shares are using different fsid's. for NFSv4 you only need the single mount point. in my case /exports from there everything else is mounted and accessed via fully qualified paths on the client side, or they can just mount /exports as their share and see all of the directories under /exports.
 
Old 05-01-2013, 09:59 AM   #4
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
lleb thank you for your quick response. I think I understand but, I have multiple shares. Do I need an entry for each share? Also I'm not quite sure about the exports part.

Quote:
cat /etc/exports
#
# /etc/exports

# NFS4
/exports *(rw,insecure,subtree_check,crossmnt,fsid=0)

# NFSv3
/exports/centos/public *(rw,insecure,no_subtree_check,fsid=3010)
/exports/NFS_TV_Shows *(rw,insecure,no_subtree_check,fsid=3020)
I don't recall reading anything about this. I don't have an 'exports' in etc though it's easy enough to make.
I googled but couldn't find out what version of NFS freenas uses I was assuming for now it is v4. As far as configuring it correctly i found nfs4-acl-tools but have no idea how to use them. I do know I can mount the shares with sudo mount though.

Thanks again
 
Old 05-01-2013, 10:26 AM   #5
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
I found this presentation that along with you lleb and the links in my 1st post really helps.

http://www.greenfly.org/talks/autofs/autofs.html

and here is an excerp from another discovery that answered a gnawing question.

"Configuration"
The configuration is done with the help of 2 files. The auto.master file, holding the mount points, and a mount point file providing the system options for this specific mount point.

Last edited by travalon; 05-01-2013 at 10:40 AM.
 
Old 05-01-2013, 10:27 AM   #6
diex
LQ Newbie
 
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
Assuming your main purpose to delay services, what about considering systemd? Migration might be painful at the beginning but the mechanism will give you the power that you need.
I have lots of services that requires internet connection, by using systemd I can easily execute them with reference to other services.
 
1 members found this post helpful.
Old 05-01-2013, 10:37 AM   #7
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
Thx diex. I'll have to google that. And, I will but, right now I am learning something new and enjoying linux like I never enjoyed windoze.
 
Old 05-01-2013, 12:41 PM   #8
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by travalon View Post
lleb thank you for your quick response. I think I understand but, I have multiple shares. Do I need an entry for each share? Also I'm not quite sure about the exports part.



I don't recall reading anything about this. I don't have an 'exports' in etc though it's easy enough to make.
I googled but couldn't find out what version of NFS freenas uses I was assuming for now it is v4. As far as configuring it correctly i found nfs4-acl-tools but have no idea how to use them. I do know I can mount the shares with sudo mount though.

Thanks again
get into the FreeNAS system and look around as root. without /etc/exports there is no NFS being provided by the server. You have to know that information before you can mount the share on the workstations.

the version the server is running is as important as how it is exported with permissions and fsid (file system ID)

the only reason for using the bg option on the workstation side is if there is an issue with mounting the share it will not stall the boot cycle or cause the workstation to have "lag" issues from time to time. I mainly use that as I have several laptops in my LAN. the bg is great for them as when autofs tries to kick in and load the shares if they are not home, it has zero effect on their performance.
 
Old 05-02-2013, 10:27 AM   #9
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
I had to use the web GUI to root around be cause of this warning.
http://img5.imageshack.us/img5/9526/sshwarning.png
I am pretty sure it because of all the changes (including a complete new install of freenas) I've been doing.
I do not have an exports file in etc/. I went through all directories and couldn't find it. I did find 3 other etc/'s as sub directories though.
The version (of what?) of freenas I am running is 8.3.1 and I haven't been able to figure out what version of NFS it has.
I definitly want the bg option.

OOOPs...... So, I went back and ran ssh-keygen -f so I could get in and look around and it turns out the shell through the web GUI wasn't showing me all the contents of the directories. This means that there might have been a properly configured exports file present. I however just nano'd one and added a comment to be able to save the file. (I guess I erased whatever it said before) so again OOOPs.......
I guess I'll delete the shares and make them again and see if it fixes the problem.

Last edited by travalon; 05-02-2013 at 10:51 AM.
 
Old 05-02-2013, 10:49 AM   #10
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
After deleting the shares and recreating them my exports now has these entries:

/mnt/Music -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xx
/mnt/Music -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx

Whew.......
 
Old 05-02-2013, 11:53 AM   #11
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
Quote:
Originally Posted by travalon View Post
After deleting the shares and recreating them my exports now has these entries:

/mnt/Music -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xx
/mnt/Music -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx

Whew.......
if that is your /etc/exports you have them exported as read only, you will never be able to write any changes to those shares.
 
Old 05-10-2013, 10:48 AM   #12
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
Sorry it's taken so long to get back but life happens. Yes I know they're read only. I did it on purpose for now. I'd hate to accidently delete my data while messing with the machines.

This is what I have as per this tutorial: https://help.ubuntu.com/community/Autofs

Auto.master
Code:
#
# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
#/misc	/etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#	"nosuid" and "nodev" options unless the "suid" and "dev"
#	options are explicitly given.
#
#/net	-hosts
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#/mnt      yp:mnt.map
#/home/travis/Videos/Movies     /etc/auto.nfs
#/home/travis/Videos/Music      /etc/auto.nfs
/nfs   /etc/auto.nfs
+auto.master
Auto.nfs
Code:
#format   mount options       Share location
/nfs     -fstype=nfs4,bg     192.168.xxx.xxx:/mnt/media/
/nfs     -fstype=nfs4,bg     192.168.xxx.xxx:/mnt/Music/
A question about these entries.

These are just the main locations of the shares. There are sub directories (i.e. mnt/media/Movies and mnt/Music/Tunes) do I need to add the full path to the shares?

in etc/default nfs-common
Code:
#NEED_IDMAPD=yes
#NEED_GSSD=no # no is default
and here is my exports on my NAS:
Code:
/mnt/Music -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xx
/mnt/Music -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup -network 192.168.xxx.xxx/xxx
/mnt/media -alldirs -ro -mapall=nobody:nogroup 192.168.xxx.xxx
I'm still not sure about this next part. Mainly where the entry goes.

part 4.2.1. NFSv4 of the tutorial above

"If your NFS shares use NFSv4, you need to tell autofs about that. In such a case, the above line would appear as follows:

server -fstype=nfs4 server:/"

Also here is my fstab that can't mount because of the wlan0 issue.
Code:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda5 during installation
UUID=5d2a547b-f5e5-478e-83bf-eac5bb5e8e0d /               ext4    errors=remount-ro 0       1
# swap was on /dev/sdb1 during installation
UUID=f017573b-6b14-4b5e-924c-c27fb978158f none            swap    sw              0       0
#mount 192.168.xxx.xxx:/mnt/media/Movies /home/travis/Videos/Movies nfs auto rw,hard,intr 0 0
#mount 192.168.xxx.xxx:/mnt/media/Series /home/travis/Videos/TV nfs auto rw,hard,intr 0 0
#mount 192.168.xxx.xxx:/mnt/Music /home/travis/Music nfs auto rw,hard,intr 0 0
#mount 192.168.xxx.xxx:/mnt/media/storage /home/travis/Nas nfs auto rw,hard,intr 0 0
Mind you at the moment all the pertinant entries are commented out so I don't destroy my 4th install from trying to get autofs working.
My last step was to run:
Code:
travis@XBMCenter ~ $ ls /nfs/server
and the result was:
Code:
ls: cannot access /nfs/server: No such file or directory
It's based on where this entry goes and how it's formatted.
"server -fstype=nfs4 server:/"

Is anyone willing to share their auto.master, any auto.xxx, exports, and etc/default nfs-common entries as an example of a working autofs set up?

Thanks to all.
 
Old 05-11-2013, 11:50 AM   #13
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
travalon try dropping the bg option from your auto.nfs to see if that helps.
 
Old 05-12-2013, 09:44 AM   #14
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
It's kinda working. I was afraid I would corrupt my installation again but I did eventually try with and without the bg option. I get the directories generated or if they already exist they are used. There is an icon of a lock on each folder and when I open the folder, it's empty. I can sudo mount and I have changed the permissions to my shares so I can write to them as well and they are ok. Google here i come!!!

Last edited by travalon; 05-12-2013 at 09:49 AM.
 
Old 05-12-2013, 10:02 AM   #15
travalon
Member
 
Registered: Jun 2012
Location: AZ
Distribution: Mint 13, Ubuntu
Posts: 78

Original Poster
Rep: Reputation: Disabled
Do I need to add my HTPC to the hosts file on my server?
Here it is:
Code:
                                                                               
# $FreeBSD: src/etc/hosts,v 1.16.34.1.2.1 2009/10/25 01:10:29 kensmith Exp $    
#                                                                               
# Host Database                                                                 
#                                                                               
# This file should contain the addresses and aliases for local hosts that       
# share this file.  Replace 'my.domain' below with the domainname of your       
# machine.                                                                      
#                                                                               
# In the presence of the domain name service or NIS, this file may              
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.     
#                                                                               
#                                                                               
::1                     localhost localhost.my.domain freenas freenas.local     
127.0.0.1               localhost localhost.my.domain freenas freenas.local     
#                                                                               
# Imaginary network.                                                            
#10.0.0.2               myname.my.domain myname                                 
#10.0.0.3               myfriend.my.domain myfriend                             
#                                                                               
                               [ Read 33 lines ]                                
^G Get Help  ^O WriteOut  ^R Read File ^Y Prev Page ^K Cut Text  ^C Cur Pos     
^X Exit      ^J Justify   ^W Where Is  ^V Next Page ^U UnCut Text^T To Spell
 
  


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
RHEL 6 autofs configuration aalinare Linux - General 6 02-14-2013 02:23 AM
autofs configuration ramadas88 Linux - Server 8 09-21-2010 05:50 AM
Autofs/Automount configuration problems Ccielogs Linux - Server 2 09-11-2009 03:21 AM
Is there a way to include winbind/ntp/autofs configuration in redhat kickstart file? wirelessgirl21 Linux - Newbie 1 06-14-2009 08:58 AM
autofs kemkem42 Linux - Software 1 09-22-2005 02:22 PM


All times are GMT -5. The time now is 03:29 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration