How to make a filesystem available to other servers via NFS in linux?



  • To make /data (mounted on server1) available to server2 (10.20.30.40) via NFS:

    On server1:

    # vi /etc/exports
    /data 10.20.30.40(rw)
    
    # /sbin/service nfs reload
    

    Instead of listing server2's IP address, you can also list:
    its hostname i.e. server2
    its fully qualified domain name i.e. server2.domain.com
    a network i.e. 10.20.30.0/24 or 10.20.30.0/255.255.255.0

    The default option is ro (read-only). Note that there is no space between server2's IP address and the options. This means that all users on server2 can access /data on server1.
    If you do leave a space i.e.
    /data 10.20.30.40 (rw)
    it means that all users on server2 have the default of ro (read-only) access to /data on server1 but the rest of the world has rw (read-write) access to /data on server 1.

    Instead of stopping and starting NFS (or reloading), you can use the /usr/sbin/exportfs command with the following switches:

    -r re-exports all directories listed in /etc/exports.
    -a exports or unexports all file systems specified in /etc/exports.
    -i ignores /etc/exports so that only options specified on the command line are taken into account.
    -u unexports one or more directories.
    -v to see a verbose output.

    If no options are specified after the /usr/sbin/exportfs command, it simply displays a list of currently exported filesystems.


Log in to reply
 

© Lightnetics 2024