NFS - Automate attaching / detaching of shares
From Blue-IT.org Wiki
Contents
Prerequisites and what this article is NOT about
The Prerequisites to understand and handle this article are:
- Administrative privileges to the system
- Profound knowledge of
- user administration,
- bash editing,
- nfs administration
This article does not cover the nfs administration of a linux/unix system.
Mainly the intention of this HowTo was the problem, that in case you are removing an exported - and mounted - nfs file system from a network this will have severe side effects:
- All applications depending on the file system will fail/hang
- The Desktop Manager which will be left in an unusable state for minutes
- Drives will not be synced, data loss can occur
The solution: Publisher/Subscriber Pattern
If a nfs exported filesystem is removed from the nfs server, it must also be removed on all computers that are connected to the nfs server. This machine therefore has to have a list of these computers. In the view of the publisher/subscriber pattern it is the publisher.
The nfs clients are the subscribers. That's the way nfs is used. They provide the mechanisms to add or remove files from the server.
Therefore they must connect to the server - and that's the problem of most of the current nfs client implementations: Mostly, they connect in certain time intervals to the nfs servers in the network. The publisher pattern however wants the subscribers (clients) to be reported immediately, when the system state changed, e.g. a drive is unmounted.
All informations in the /etc/exports
The one and only file on the nfs server to handle
- nfs shares
- possibly connected clients
is the /etc/exports.
It is easy to extract all shares