Question: PART 1: File sharing in Linux with NFS (Network File System) Boot into the Fedora Linux server VM first and follow the procedure outlined below
PART 1: File sharing in Linux with NFS (Network File System) Boot into the Fedora Linux server VM first and follow the procedure outlined below to share files between Linux machines using NFS. You will share files between the two F24 VMs on your Host OS (remember to use the Fedora server VM as the NFS server). On the Linux server VM, open a terminal window and switch user to root. Change to the /media directory and create a empty file using the command touch testfileN (N is your unique number, as explained in lab 1). Verify that the file has been created using the ls -l command. Now issue the command dnf install system-config-nfs to install the NFS graphical configuration tool, and run the utility by issuing the command systemconfig-nfs (or click Activities, type nfs in the search box, then click the system configuration icon that appears below the search box). This will open the NFS Server Configuration window. Click the Add button to add an NFS share. In the Directory field enter /media (the local directory that we will export) and in the Host(s) field enter 192.168.80.0/24 (the entire class C network will be allowed to mount this share*). Leave the basic permissions as Read-only. Click OK to add the share. To verify that this has been done, type cat /etc/exports. The share should be listed in the file. *NOTE: The number 80 given here may be different for your system. Type the command ifconfig and look at the IP address for the ens33 interface to obtain this number its the third decimal number of the IP address. Configure NFS to start automatically when the system boots by typing systemctl enable rpcbind.service followed by systemctl enable nfsserver.service. Then type the command typing systemctl start rpcbind.service followed by systemctl start nfs-server.service to start the NFS service. NOTE: Adding an NFS share using the NFS Server Configuration utility, as was done in the previous step, will cause the NFS service to start automatically. In this case, it is not required to explicitly start the NFS service. To mount the exported directory, log in on the Fedora Linux client VM, open a terminal and switch user to root. To mount the exported directory, create a mount point by typing mkdir /mnt/nfs1 and then issue the command mount - o ro 192.168.80.X:/media /mnt/nfs1 (X represents the last decimal number of the IP address of the Linux server VM to determine this, type /sbin/ifconfig at the terminal prompt and look for the IP address of the ens33 interface in the VM). Change directory to /mnt/nfs1. Type ls -l. You should see the contents of the /media directory from the other machine. Try creating a file under this directory using the touch command. Why can you not do this? (Ans: the directory is exported as read-only). On the first Linux server machine, go back to the NFS Server Configuration window. Select the share and click the Properties button. Change the basic permissions to Read/Write and click OK. Note again that, when you use the NFS Server Configuration utility, the NFS service is automatically restarted to allow the change to take effect; in a case where you need to restart the NFS service manually, use the command systemctl restart nfs-server.service. Unmount the previously mounted directory (you have to exit the current directory to do this type cd .. to go up one directory) by typing umount /mnt/nfs1 and remount it again as read-write (same command as before but without the -o ro option since the default mode is read-write). As before, change directory to /mnt/nfs1 and try to create a file inside this directory. Are you successful this time? Why? (Ans: although the directory is exported and mounted as read-write, you are accessing it as root and this causes the server to map root to a user (nfsnobody) with lower permissions for security reasons. This user obviously does not have write permissions for the /media directory (see ls -l /). Now lets try something else. On the Linux server system, export the directory /home/student with read-write access. Back on the client system, create a new mount point /mnt/nfs2 and mount the exported directory under this mount point by using the command mount 192.168.80.X:/home/student /mnt/nfs2 (as before, X represents the last decimal number of the IP address of the Linux server station). Type su student to switch the current user to student (notice the prompt change to reflect the new user) and change directory to /mnt/nfs2. Try creating a new file as before. You should now be successful. Finally, let us see how we can configure the client system so that it mounts the exported /home/student directory from the server automatically when it boots. To do this we need to add the following line at the end of the /etc/fstab file (using the gedit editor as user root): 192.168.80.X:/home/student /mnt/nfs2 nfs intr 0 0 IMPORTANT: Before you edit the /etc/fstab file make a backup copy (i.e. cp /etc/fstab /etc/fstab.bak) in case something goes wrong. Reboot your client system and verify that the remote directory is automatically mounted upon startup by typing df -h.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
