Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Dynamic automounting of NFS volumes Network
I wanted to mount two AFP volumes that I have shared from my Redhat box to my home directory. There is a utility called Sharepoints Autmount, but it lacks a way to pass passwords during the mounting process. then I thought about exporting the volumes as NFS shares.

On the Linux side it was very simple, I used the Webmin Server configurator that comes with Redhat. I simply exported the volumes to my IP address and added myself as a read/write user. I tested it with this command:
% sudo mount server:/path/to/export /home/username/server/
This worked fine, but was only temporary. It needed to be performed at every boot.

[Editor's note: The following information deals with modifying the NetInfo database. Proceed at your own risk, and make sure you know what you're doing -- I have not tested this hint myself!]

Next I looked at Netinfo on an OS X 1.2 server, which I installed onto a 9600/200. It is not very user freindly, but it does have buttons for easily adding NFS mounts to netinfo. I used that to get the basic Netinfo settings I would need. This machine is invaluable for hacking Netinfo on OS X 10.1.x or 10.2.

In Netinfo, add a new Directory at the root level named "mounts". You need a new directory inside of mounts for each mountpoint. You will need three new properties inside of these directories. The first is "name", and it has a value that is the same as the path to the NFS export you want to mount. The next is "dir", and it has a value that is the same as the directory path to where you want to mount it locally. Now we need a "type" property. This lets OS X know what kind of filesystem to mount. In this case it is "nfs". So the final settings look like this:
  • name:
  • dir: /Users/yourname/mount
  • type: nfs
There is another entry on the OS X server called "opts" (it was empty), so I added an empty property for it. This could conceivably be for a read-only option, or some other option like handling resource forks in Mac files.

Now to the fun part. If you reboot, your mounts should work, but then you are locked in to a directory or path until you reboot again. I hate to reboot my machine, so i looked for a solution.Here it is:
 % sudo kill -1 `cat/var/run/`
This kills and restarts the automount process. This is also useful if you decide you want to change the icon on your automount directory. You must do it before the system takes hold of it. Plus if you want to add more mounts it is simple, and makes experimenting with the placement of the directories less of a chore.

This method of mounting is better than adding the NFS mounts to fstab, because they are dynamic instead of static. This means that they are only called on by the system when a user or process tries to access them. Static mounts can cause the system to hang at startup if the server is not available. Dynamic mounts do not. This makes them excellent for use on laptops as well, since you may not always have access to the sever when you boot.
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Dynamic automounting of NFS volumes | 13 comments | Create New Account
Click here to return to the 'Dynamic automounting of NFS volumes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Authored by: pwestbro on Oct 10, '02 12:31:03PM
You can do the same thing with NFSManager. This tool will make the same modifications, but with a nice user interface.

[ Reply to This | # ]
Authored by: babbage on Oct 10, '02 07:29:10PM
As effective as this strategy is -- very, I'm sure -- wouldn't it be easier to just throw a one line shell script under /Library/StartupItems and be done with it? The script doesn't have to be much more than a wrapper around the command mount -t nfs -o defaults server:/remote /local/mount/point See other files & directories for how exactly to set this up, but basically under the StartupItems directory you have a directory with the name of the service, and in that directory you have two files. One of the files is a brief script that launches the program (which has the same name as the directory) and the other is a startupparameters.plist file that sets a couple of simple variables. It's very easy to just copy one of the existing directories, change around a few lines, add an appropriate version of the mount command above, and go. It only takes a few seconds to set up once you figure it out.

[ Reply to This | # ]
RE: Sledgehammer?
Authored by: jhowk on Oct 11, '02 12:56:40AM

An old UN*X tip: Not necessarily easier per say, but since automount is installed and the daemon running by default, you could just put in your NFS mounts into the /etc/fstab.hd(?) Then once you actually attempt to visit that mount point, automount, well mounts it. man on automount for more info.

[ Reply to This | # ]
RE: Sledgehammer?
Authored by: Lone Macster on Oct 11, '02 12:56:37PM

The fstab option afforded me a serious hang during boot time if the server was down, or if NFS was not running. This seemed to be the best way to get teh results I wanted with the flexibility I required. the startup script idea seems doable, but I would have to run a umount, and then edit the script, and then run the script again to move a mountpoint.

[ Reply to This | # ]
Authored by: Lone Macster on Oct 11, '02 12:52:02PM

This is true, but the idea I had was to be able to Dynamically mount the volumes. The startup script still requires a reboot to see the changes if I decide to move the mount point. I could run the script again, but I would have to change it anyway just like the Netinfo DB.

[ Reply to This | # ]
Or an even easier way...
Authored by: nigel.megitt on Oct 11, '02 05:13:31AM

is to use the Finder's Go To Server feature to connect to your server once. Then make a shortcut to the place you want to mount. I like to put mine in the dock, but it doesn't make any difference where it is.

Next time you log in the server won't be mounted but when you open the shortcut the Finder automatically mounts it and presents it.

One proviso: if your connection disappears (e.g. if it was a dialup and you disconnected) then when you log out the system hangs while it tries to unmount the server. The way to get round this is to make sure that you manually dismount the servers before disconnecting, by dragging them to the Eject button in the Dock. This is really annoying, and something I wish Apple would sort out, but is edging off topic...

[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: robleach on Feb 18, '03 03:58:25PM


For a while now, I've been wanting to connect my local user account on my machine up with my network user account (NFS) so that I wouldn't be dealing with ownership and permission issues every time I want to edit a file on our public sites (which I do ALL the time). So as a first step, I've been trying to figure out how to automount the remote disk that contains my home directory on the network so that I can create a user with the same uid and home directory location. [My linux system is set up this way.] I first tried adding entries to /etc/fstab, a file I created due to other advice. However, no mount occurred upon restart. So I just tried this procedure you've reccommended, still to no avail.

What I've been doing in the meantime is I added the mount commands to my .login file wrapped in a conditional to check if the mounts pre-exist. However, the mount command didn't always work for some reason and I discovered that mount_nfs provided a retry feature and that seemed to alleviate the problem by setting it to 10. So I know that I *can* mount these locations. I don't understand why none of these automount strategies are working for me. I presume that I can't use the login items strategy because those would be stored in my home directory... Another thing I'm dealing with is the mounts I DO have aren't permanent. They occassionally get lost like for example when the server goes down for a minute and comes back up (a problem my linux system handles fine).

When I tried your procedure, I didn't get any default properties in the window below in NetInfo. Could that be the problem? I would prefer the fstab solution since that's what our sysadmins here are familiar with in terms of other unix systems and they might be able to help if they can figure out the quirks of this sytem. But if I can get any solution that will work, I'll settle.

Any advice would be appreciated.


[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: artgeek on Feb 19, '03 05:09:12PM

Darwin mounts things weirdly. I think you are on the right track with fstab, though, you just need to load it into NetInfo before it will stick, with ->

niload fstab . < 'your.fstabfile'

Backup NetInfo first!

Sounds like your 'lost' mounts are static, and can't be automounted again when Darwin occasionaly lets the NFS links go -> dynamic mounts should solve this problem. Probably a good idea to just load your NFS info into NetInfo /mounts by hand (NI Manager), and not include that info in the /etc/fstab flat file. As I understand /etc/fstab will cause those mounts to be static, NetInfo uses automounter -> though i'm still learning this stuff. So please test this for your desired results. Please post your findings, too :)

You can name the file you are loading into NetInfo anything you like. Use a '/dev/disk' format with /etc/fstab -> 'LABEL' appears broken (last i checked). This solved getting swap and Users to mount consistantly on a separate internal disk. I'm still working on my NFS too!

good luck.

Check these links for a start:

[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: artgeek on Feb 21, '03 01:33:06AM

I need to retract my last comment, after my experience last night. Apparently, the only thing that successfully mounts my Users and swap partitions is a custom 'Disks' startupitem. As I was testing my setup, I discovered the rc errors mentioned above, and realized fstab wasn't being read. This startupitem is a holdover from 10.1, but is still working perfectly with Jaguar. Now I get to work out fstab, too. Can't say for sure what part NetInfo is playing now??? I'll post back as I find more.

Sorry for the mis-information :(

The links may still be informative, though. I 'd like to hear what your solution eventually is.

Have a good...


[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: robleach on Jun 30, '03 01:03:14PM

Incidentally, this solved my trouble with doing the mount. I haven't reread my post, but I remember that the procedure recommended here worked once I had my sysadmin do the following on the remote machine... Apparently, the system the remote disk was on needed to "allow" my machine to mount it. Here's the summary my sysadmin gave me for doing that:

To allow a machine to mount remote disks, on the remote system:
Add machine name to /etc/netgroup
root@remote_machine [46] / % ypmake
update netgroup
push netgroup
update netid
push netid
root@remote_machine [47] /var/yp % shareall

[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: SCID on Feb 19, '03 02:46:45PM

How would one accomplish something similar with a smb volume. Ie I have a windows xp home machine on my lan and I want it's share point to show up in my servers. How do I set up the info in the netinfo mounts?

[ Reply to This | # ]
Dynamic automounting of NFS volumes
Authored by: robleach on Jun 30, '03 01:11:25PM

OK, so this hint is great. I've used it a good bit. However, now I have a new laptop and when I log in to my remote account via an nfs mount, I end up with a lot of questionmarks in my dock. This is because they are links to locally stored applications on my original computer. So I tried to apply the same procedure listed here to mount the disks on my other G4. I don't get the same permission denied error I ran into when mounting the nfs disks. Instead, I get port mapper failures when I try to mount on the command line. I've tried specifying the type as nfs, hfs, and hfs+ all with the same result.

First of all, there's got to be an easier way to mount a remote mac disk in the same manner I have the nfs disks mounted. Second, if this should work, what do I need to do?

[ Reply to This | # ]
What about AFP?
Authored by: robleach on Oct 17, '03 07:17:20PM
This was such a great tip for mounting remote NFS volumes. I have half a dozen mounts set up at work. However, now at home, I have 3 computers and just got an airport base station and I'd like to mount disks in various directions and have one home directory on one of the disks.

I tried setting it up in the same manner I did those NFS ones, but of course it didn't work. I hadn't expected it would. I tried making type=AFP instead of NFS in netinfo.

The obvious impediment is that I don't know how to allow a remote machine to mount local disks. i was able to figure that out on the remote NFS machines, but on my Mac, I'm at a loss. is that all I need to make this work - just figure out how to allow remote machines to mount local disks?

I assume that that's what also prevents me from being able to mount manually:
[dsl###-###-###:/home] robleach% sudo mount -t afp afp://robleach@###.###.###.###:/Volumes/disk2 /home/disk2
kextload: /System/Library/Filesystems/AppleShare/asp_tcp.kext loaded successfully
kextload: /System/Library/Filesystems/AppleShare/asp_atp.kext loaded successfully
kextload: /System/Library/Filesystems/AppleShare/afpfs.kext loaded successfully
mount_afp: AFPMountURL returned error -1, errno is -50
[dsl###-###-###:/home] robleach% sudo mount -t afp afp://robleach:mypassword@###.###.###.###:/Volumes/disk2 /home/disk2
kextload: extension /System/Library/Filesystems/AppleShare/asp_tcp.kext is already loaded
kextload: extension /System/Library/Filesystems/AppleShare/asp_atp.kext is already loaded
kextload: extension /System/Library/Filesystems/AppleShare/afpfs.kext is already loaded
mount_afp: AFPMountURL returned error -5019, errno is 2
Any suggestions?


[ Reply to This | # ]