Setting UP nFS Server and Client..

I'm using two CentOS systems here:
  • NFS Server: server.example.com, IP address: 192.168.0.100
  • NFS Client: client.example.com, IP address: 192.168.0.101
  • 2 Installing NFS

    Server side  :

    #yum install nfs-utils nfs-utils-lib

    #chkconfig --levels 235 nfs on
    #/etc/init.d/nfs start 

    Client Side:

    # yum install nfs-utils nfs-utils-lib

    Creating NFS Share : I'd like to make the directories /home and /var/nfs accessible to the client; therefore we must "export" them on the server.
    When a client accesses an NFS share, this normally happens as the user nobody. Usually the /home directory isn't owned by nobody (and I don't recommend to change its ownership to nobody!), and because we want to read and write on /home, we tell NFS that accesses should be made as root (if our /home share was read-only, this wouldn't be necessary). The /var/nfs directory doesn't exist, so we can create it and change its ownership; in my tests the user and group nobody both had the ID 99 on both my CentOS test systems (server and client); when I tried to write to /var/nfs from the NFS client, I got a Permission denied error, so I did a chmod 777 /var/nfs so that everyone could write to that directory; writing to /var/nfs from the client worked then, and on the client the files written to /var/nfs appeared to be owned by the user and group nobody, but on the server they were owned by the (nonexistant) user and group with the ID 65534; so I changed ownership of /var/nfs to the user/group 65534 on the server and changed permissions of /var/nfs back to 755, and voilĂ , the client was allowed to write to /var/nfs:

    #mkdir /var/nfs
    #chown 65534:65534 /var/nfs
    #chmod 755 /var/nfs

    #vi /etc/exports
    Entry should made as bellow :
    /home           192.168.0.101(rw,sync,no_root_squash,no_subtree_check)
    /var/nfs        192.168.0.101(rw,sync,no_subtree_check)
     
    Whenever we modify /etc/exports, we must run
    #exportfs -a

    Mounting The NFS Shares On The Client

     

    First we create the directories where we want to mount the NFS shares, e.g.:
    #mkdir -p /mnt/nfs/home
    #mkdir -p /mnt/nfs/var/nfs
    Afterwards, we can mount them as follows:
    #mount 192.168.0.100:/home /mnt/nfs/home
    #mount 192.168.0.100:/var/nfs /mnt/nfs/var/nfs
    You should now see the two NFS shares in the outputs of
    #df -h
    [root@client ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           28G  2.2G   25G   8% /
    /dev/sda1              99M   13M   82M  14% /boot
    tmpfs                 250M     0  250M   0% /dev/shm
    192.168.0.100:/home    28G  2.6G   25G  10% /mnt/nfs/home
    192.168.0.100:/var/nfs
                           28G  2.6G   25G  10% /mnt/nfs/var/nfs
    [root@client ~]#

    Mounting NFS Shares At Boot Time


    Open /etc/fstab and append the following lines:
    #vi /etc/fstab

    make changes as bellow :
    [...]
    192.168.0.100:/home  /mnt/nfs/home   nfs      rw,sync,hard,intr  0     0
    192.168.0.100:/var/nfs  /mnt/nfs/var/nfs   nfs      rw
     
    save and exit!
    restart the nfs service 
    #service nfs restart
     












Comments

Popular posts from this blog

Running web ssh client on port 443 /80 with nginx as reverse proxy

Running cockpit behind nginx reverse proxy with nginx ssl and cockpit non ssl

Setup VOD streaming server with nginx using RTMP on Ubuntu 18.04