Setting Up An NFS Server And Client On Debian Lenny
Setting Up An NFS Server And Client On Debian LennyVersion 1.0 This guide explains how to set up an NFS server and an NFS client on Debian Lenny. 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 Debian systems here:
2 Installing NFSserver: On the NFS server we run: apt-get install nfs-kernel-server nfs-common portmap client: On the client we can install NFS as follows: apt-get install nfs-common portmap
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 to nobody and nogroup: 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 client:~# df -h and mount 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/ server:~# ls -l /home/ ls -l /var/nfs 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, therefore /var/nfs/test.txt is owned by nobody.)
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 client:~# df -h and mount client:~# mount
7 Links
|



Recent comments
1 day 5 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 15 hours ago
2 days 7 hours ago
2 days 8 hours ago
2 days 11 hours ago