Setting Up An NFS Server And Client On Scientific Linux 6.3
Setting Up An NFS Server And Client On Scientific Linux 6.3Version 1.0 This guide explains how to set up an NFS server and an NFS client on Scientific Linux 6.3. NFS stands for Network File System; through NFS, a client can access (read, write) a remote share on an NFS server as if it was on the local hard disk. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm using two Scientific Linux systems here:
2 Installing NFSserver: On the NFS server we run: yum install nfs-utils nfs-utils-lib Then we create the system startup links for the NFS server and start it: chkconfig --levels 235 nfs on client: On the client we can install NFS as follows (this is actually the same as on the server): yum install nfs-utils nfs-utils-lib
3 Exporting Directories On The Serverserver: 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 Scientific Linux 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 Now we must modify /etc/exports where we "export" our NFS shares. We specify /home and /var/nfs as NFS shares and tell NFS to make accesses to /home as root (to learn more about /etc/exports, its format and available options, take a look at man 5 exports ) vi /etc/exports
(The no_root_squash option makes that /home will be accessed as root.) Whenever we modify /etc/exports, we must run exportfs -a afterwards to make the changes effective.
4 Mounting The NFS Shares On The Clientclient: First we create the directories where we want to mount the NFS shares, e.g.: mkdir -p /mnt/nfs/home Afterwards, we can mount them as follows: mount 192.168.0.100:/home /mnt/nfs/home You should now see the two NFS shares in the outputs of df -h [root@client ~]# df -h and mount [root@client ~]# mount
5 TestingOn the client, you can now try to create test files on the NFS shares: client: touch /mnt/nfs/home/test.txt Now go to the server and check if you can see both test files: server: ls -l /home/ [root@server ~]# ls -l /home/ ls -l /var/nfs [root@server ~]# ls -l /var/nfs (Please note the different ownerships of the test files: the /home NFS share gets accessed as root, therefore /home/test.txt is owned by root; the /var/nfs share gets accessed as nobody/65534, therefore /var/nfs/test.txt is owned by 65534.)
6 Mounting NFS Shares At Boot TimeInstead of mounting the NFS shares manually on the client, you could modify /etc/fstab so that the NFS shares get mounted automatically when the client boots. client: Open /etc/fstab and append the following lines: vi /etc/fstab
Instead of rw,sync,hard,intr you can use different mount options. To learn more about available options, take a look at man nfs To test if your modified /etc/fstab is working, reboot the client: reboot After the reboot, you should find the two NFS shares in the outputs of df -h [root@client ~]# df -h and mount [root@client ~]# mount
7 Links
|




Recent comments
1 day 11 hours ago
1 day 14 hours ago
1 day 16 hours ago
1 day 17 hours ago
1 day 19 hours ago
1 day 20 hours ago
1 day 21 hours ago
2 days 13 hours ago
2 days 14 hours ago
2 days 18 hours ago