Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Elegant solution required.

22 views
Skip to first unread message

The Natural Philosopher

unread,
Oct 27, 2012, 9:15:49 AM10/27/12
to

I have a remote server which I connect to using NFS over a hole punched
in the remote firewall. This works nicely.

I have a script to mount all the remote drives I want to mount. Thise
all mount on a subdirectory other on my home drive.

BUT if my internet connection (ADSL) or the remote machine is down, I
don't want to hang my boot process timing out half a dozen failed mount
processes.

I have never got the hang of automounting either..

Can anyone work out what is the simplest way to test if the drives CAN
be mounted, and then simply not mount them if they cant be?



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.

Jeremy Nicoll - news posts

unread,
Oct 27, 2012, 10:28:04 AM10/27/12
to
The Natural Philosopher <t...@invalid.invalid> wrote:

>Can anyone work out what is the simplest way to test if the drives CAN
>be mounted, and then simply not mount them if they cant be?

I think I'd start with a ping of the remote machine as that'll test both the
internet connection and whether the machine is up.

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to newsre...@wingsandbeaks.org.uk replacing "aaa" by "284".

Aragorn

unread,
Oct 27, 2012, 10:35:37 AM10/27/12
to
On Saturday 27 October 2012 15:15, The Natural Philosopher conveyed the
following to comp.os.linux.misc...

> I have a remote server which I connect to using NFS over a hole
> punched in the remote firewall. This works nicely.
>
> I have a script to mount all the remote drives I want to mount. Thise
> all mount on a subdirectory other on my home drive.
>
> BUT if my internet connection (ADSL) or the remote machine is down, I
> don't want to hang my boot process timing out half a dozen failed
> mount processes.
>
> I have never got the hang of automounting either..
>
> Can anyone work out what is the simplest way to test if the drives CAN
> be mounted, and then simply not mount them if they cant be?

The simplest solution would probably be to use NFS over UDP (which is
the old style) rather than over TCP (as is the new style as of NFSv4),
but this is of course less reliable with regard to data integrity.

Another possibility - just off the top of my head, so don't pin me down
on it - would be to run some heartbeat daemon on the remote server and
check that first from the local workstation at boot time, so that the
workstation doesn't try to mount the exported shares if there is no
heartbeat from the remote machine.

Just my two Eurocents worth. ;-)

--
= Aragorn =
(registered GNU/Linux user #223157)
Message has been deleted

Matthew of Boswell

unread,
Oct 27, 2012, 12:47:25 PM10/27/12
to
On Sat, 27 Oct 2012 14:15:49 +0100
The Natural Philosopher <t...@invalid.invalid> wrote:

> Can anyone work out what is the simplest way to test if the drives CAN
> be mounted, and then simply not mount them if they cant be?

Since someone already mentioned the ping method, and the bg mount
option, here's one more:

You could set the timeo nfs option shorter, then have a little startup
script that checks the result of the first mount command. If it fails,
don't try the rest. This will help when the server is ping-able but nfs
is down.

I'm also partial to the bg mount option :) .

Note that I haven't tried all this, just got interested and read nfs(5).

--
Matt Boswell

() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - and proprietary attachments

Chris Davies

unread,
Oct 27, 2012, 12:21:34 PM10/27/12
to
The Natural Philosopher <t...@invalid.invalid> wrote:
> I have a remote server which I connect to using NFS over a hole punched
> in the remote firewall. This works nicely.

> I have never got the hang of automounting either..

I'd still recommend the automounter. It's actually pretty easy...


1. Edit /etc/auto.master and make sure that you have (just) this line:

/var/autofs/net -hosts

This defines a host-and-share-based mapping underneath the root point
/var/autofs/net. You will probably need to create that directory.

2. Start the automounter
invoked-rc.d autofs start # Debian style
service autofs start # RedHat style

3. Edit the opts definition in the file /etc/auto.net according to
taste. My preference is this, but yours may vary:

opts="-fstype=nfs,hard,intr,nodev,nosuid"


OK so that's the automounter up and running. You can now reference
remote mounts by accessing appropriate host/path directories
underneath the automounter root, /var/autofs/net. For example, if
you have a remote host called gizmo.roaima.co.uk and a remote path of
/shares/myshare, the target directory on your local machine will be
/var/autofs/net/gizmo.roaima.co.uk/shares/myshare. I find it helpful to
symlink these up to a /net/ directory, like this, and then I can ignore
the long paths into the automounter:

mkdir /net
cd /net
ln -s /var/autofs/net/gizmo.roaima.co.uk/shares/myshare
ln -s /var/autofs/net/gizmo.roaima.co.uk/shares/myothershare
ln -s /var/autofs/net/another.example.com/home/yetanothershare


If you get really excited about the automounter, you can use the
auto.misc file to declare arbitrary mappings, and theoretically even
use the auto.smb script to build implicit SMB host-and-share-based
mappings. (These tend to be harder, though, as usually authentication
of some form is required for the mount to succeeed.)

/var/autofs/misc /etc/auto.misc
/var/autofs/net /etc/hosts.net --timeout=60
/var/autofs/smb /etc/hosts.smb --timeout=300

See http://greenfly.net/tips/autofs.html for lots more excitement

Chris

The Natural Philosopher

unread,
Oct 27, 2012, 2:04:50 PM10/27/12
to
On 27/10/12 17:26, David Hough wrote:
> The Natural Philosopher wrote:
>
>>
>> I have a remote server which I connect to using NFS over a hole punched
>> in the remote firewall. This works nicely.
>>
>> I have a script to mount all the remote drives I want to mount. Thise
>> all mount on a subdirectory other on my home drive.
>>
>> BUT if my internet connection (ADSL) or the remote machine is down, I
>> don't want to hang my boot process timing out half a dozen failed mount
>> processes.
>>
>> I have never got the hang of automounting either..
>>
>> Can anyone work out what is the simplest way to test if the drives CAN
>> be mounted, and then simply not mount them if they cant be?
>>
> I've got an nfs mount on one of my laptops, I think I've got the 'bg' option
> set on the mount so it doesn't hang the boot process (obviously if you rely
> on a remote file for boot then you've got a problem). It certainly boots OK
> away from the home network, although that might also be because the server
> name doesn't resolve unless it can get to the home DNS server.
>
> Dave
>
bg? that's a new one..I'll look into that

The Natural Philosopher

unread,
Oct 27, 2012, 2:19:49 PM10/27/12
to
Thanks for replies. It looks like bg is good enough top do what is
needed here.
0 new messages