[lug] mac NFS mounts with Linux exports

Rob Nagler nagler at bivio.biz
Sat Jan 31 13:49:36 MST 2009


>  Any mac experts know of any issues with the latest macos updates related
>  to NFS?

I'm no Mac expert, but I use one with an NFS mount for my iTunes library
and pictures in house.  Here's what I have:

/media 192.168.1.0/255.255.255.0(ro,insecure,all_squash)

I don't use no_root, because it is irrelevant.

I found NFS to be difficult until I wrote the appended program.  One of my
problems is that I like to listen to music at home and my office.  iTunes
caches way too much, and so I have to restart iTunes when I switch
locations.

Also, I always load the latest updates.  I'm running 10.4.11 (8S2167).

Rob
-------------------------------------------------------------------------------
#!/usr/bin/perl -w
# -*- cperl -*-
use strict;
use POSIX ();
my($hosts) = [qw(
    office.host.name
    home.host.name
)];
while (1) {
    my(@x) = glob('/media/*');
    next if @x;
    system('umount -f /media')
	if grep(m{:/media}, `mount`);
    my($net);
    next unless my($h) = grep(`ping -t 1 -c 1 $_` && $? == 0, @$hosts);
    my($pid) = fork;
    unless (defined($pid)) {
	_msg("fork: $!");
	next;
    }
    unless ($pid) {
	exec("mount_nfs -R 5 -o
ro,hard,intr,timeo=5,retrans=5,nolock,udp,dumbtimer,rsize=65536,wsize=8192
${h}:/media /media");
	die("exec failed: $!");
    }
    foreach my $x (1..3) {
	sleep(1);
	waitpid($pid, POSIX::WNOHANG());
    }
    if (kill(0, $pid)) {
	kill('KILL', $pid);
	sleep(1);
	waitpid($pid, POSIX::WNOHANG());
    }
    else {
	_msg("$h:/media mounted");
    }
}
continue {
    _msg('sleeping');
    sleep(30);
}

sub _msg {
    print(STDERR @_, "\n");
    return;
}



More information about the LUG mailing list