Exercise: NFS client configuration
Install the NFS related packages by using apt-get
on n01 VM:
apt-get install rpcbind nfs-common
Run command rpcinfo pointing at the server
If you see the same output as on the NFS server, it means the server
allows you to access the rpcbind and the rpc services.
Check what directories are exported to you from the server:
It should show
Now you are ready to mount its directory on n01.
Create a new mounting point and mount the exported directory onto it
/sbin/showmount -e master
To make sure the directory has been mounted, run command
The mounted directory shows up in the bottom of the file
mkdir -p /NFS/home
mount -t nfs -o vers=3 master:/NFS/home /NFS/home
To see who is the owner of the files
in the directory, run command
Since there is no user with UID=666 and GID=666
on the node,
the mounted directory would belong to a non-existent user:
master:/NFS/home 494M 78M 390M 17% /NFS/home
Create user edward with UID=GID=667:
-rw-r--r-- 1 666 666 104 Feb 10 19:32 hosts
-rw-r--r-- 1 666 666 1750 Feb 10 19:32 nsswitch.conf
-rw------- 1 root root 114 Feb 10 2003 securetty
Assign password to the user:
Now try to change the ownership of the directory on the node:
/usr/sbin/groupadd -g 667 edward
/usr/sbin/useradd -m -s /bin/bash -u 667 -g 667 -d /NFS/home/edward edward
It doesn't work:
chown edward:edward /NFS/home/edward
chown: changing ownership of `/NFS/home/edward': Operation not permitted
Change the UID and GID of edward to be consistent with those on the NFS server:
Become user edward then step into directory /NFS/home:
/usr/sbin/groupmod -g 666 edward
/usr/sbin/usermod -u 666 -g 666 edward
and see if you can create files in
Exit from user edward account:
Unmount the directory,
Mount the directory as NFSv4:
Run command below to verify that the directory has been mounted:
mount -t nfs -o vers=4 master:/NFS/home /NFS/home
Reboot n01 by executing command reboot and check if the NFS directory is no longer mounted after reboot:
Modify file /etc/fstab by including a new entry with
Check if it is mounted
master:/NFS/home /NFS/home nfs rw,vers=4 0 0
Unmounting busy directories.
Open another terminal on your desktop and ssh to n01 as user
edward. You can figure out the IP address of n01 by
running command ifconfig in the 'root' console of n01.
For example, if n01 has IP address 192.168.122.64, the ssh command on the desktop looks as follows:
Note, in your KVM environment the IP address of n01 may be different.
In the 'root' console of n01 try to unmount the directory:
If the directory can not get unmounted and you receive error message
"device is busy", check what processes hold the directory by executing
command lsof +D on the file system.
Specifically, in our case:
Kill the process, for example with PID 1367, and try to unmount the directory again.
kill -9 1367
Remove the NFS entry from /etc/fstab
Try to avoid NFS mounting through /etc/fstab. Use either
manual mount or automount.