You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/labs/networking/lab5-nfs.md
+63-66Lines changed: 63 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
author: Wale Soyinka
3
-
contributors:
3
+
contributors:Steven Spencer, Ganna Zhyrnova
4
4
tested on: All Versions
5
5
tags:
6
6
- network file system
@@ -14,33 +14,33 @@ tags:
14
14
15
15
## Objectives
16
16
17
-
After completing this lab, you will be able to
17
+
After completing this lab, you will be able to
18
18
19
-
- install and configure NFS
19
+
- install and configure NFS
20
20
- share files and directories between Linux systems using NFS
21
-
- use common NFS utilities to query or troubleshoot NFS issues
21
+
- use common NFS utilities to query or troubleshoot NFS issues
22
22
23
-
Estimated time to complete this lab: 40 minutes
23
+
Estimated time to complete this lab: 40 minutes
24
24
25
-
## NFS
25
+
## NFS
26
26
27
27
NFS is an acronym for Network File System. It allows the sharing of files and folders over a network with other systems. NFS provides a simple way for making the contents of the local file system available to multiple users (or systems) on a network.
28
28
29
-
This sharing is traditionally between UNIX/Linux like systems, but systems running MS Windows operating systems can also access NFS shares as long as they have the proper software installed to do this.
29
+
This sharing is traditionally between UNIX/Linux like systems, but systems running Microsoft Windows operating systems can also access NFS shares if they have the proper software installed to do this.
30
30
31
-
Support for NFS must be enabled or compiled into the Kernel.
31
+
Support for NFS must be enabled or compiled into the kernel.
32
32
33
33
As with most networking concepts, there is a client side and a server side to NFS. The server side consists of the system that exports (shares) file systems to other systems. The client side consists of the systems that needs access to file system exported by the server.
34
34
35
35
NFSv4 requires the services of the following programs (daemons):
36
36
37
37
- portmap - maps RPC programs to regular network ports
38
-
- mountd - handles incoming mount requests
39
-
- nfsd - this is the main NFS program that handles the actual file transfers.
38
+
- mountd - handles incoming mount requests
39
+
- nfsd - this is the main NFS program that handles the actual file transfers
40
40
41
-
## /etc/exports
41
+
## /etc/exports
42
42
43
-
The `/etc/exports` configuration file serves as a form of access control list for specifying file systems which may be exported via NFS to authorized clients. It provides information to mountd and to the kernel based NFS file server daemon nfsd.
43
+
The `/etc/exports` configuration file serves as a form of access control list for specifying file systems which may be exported via NFS to authorized clients. It provides information to `mountd` and to the kernel based NFS file server daemon `nfsd`.
44
44
45
45
The directives in `/etc/exports` uses the following syntax:
In this exercise you will share (export) a local directory to be shared with your partner system, but first you will learn how to manage the NFS service.
56
56
57
-
NFS is a Remote Procedure Call (RPC) based client and server application. It is therefore useful to have RPC utilities handy that can be used for querying, debugging and making RPC calls to RPC servers (like NFS servers). `rpcinfo` is one such useful utility. Its usage syntax and options are shown here:
58
-
57
+
NFS is a Remote Procedure Call (RPC) based client and server application. It is therefore useful to have RPC utilities handy that can be used for querying, debugging, and making RPC calls to RPC servers (like NFS servers). `rpcinfo` is one such useful utility. Its usage syntax and options are shown here:
59
58
60
59
```bash
61
60
SYNOPSIS
@@ -79,9 +78,8 @@ SYNOPSIS
79
78
```bash
80
79
dnf -y install nfs-utils
81
80
```
82
-
3. Amongst things, the newly installed nfs-utils package also provides the systemd service unit
83
-
(nfs-server.service) needed for managing the NFS daemon on the system.
84
-
Use systemctl to view some of the ancilliary services that the nfs-server unit "Wants". Type:
81
+
82
+
3. Amongst things, the newly installed nfs-utils package also provides the systemd service unit (`nfs-server.service`) needed for managing the NFS daemon on the system. Use `systemctl` to view some of the ancillary services that the nfs-server unit "Wants". Type:
Some important and notable services that nfs-server needs are nfs-idmapd, nfsdcld, rpcbind, rpc-statd-notify, rpc-statd, auth-rpcgss-module.
91
+
92
+
Some important and notable services that nfs-server needs are `nfs-idmapd`, `nfsdcld`, `rpcbind`, `rpc-statd-notify`, `rpc-statd`, `auth-rpcgss-module`.
94
93
95
-
4. The `rpcinfo`command is used for making RPC calls to an RPC server and then reporting on its
96
-
findings. `rpcinfo` lists all the RPC services registered with rpcbind.
97
-
Use `rpcinfo` to query your local server for a list of all registered RPC services. Type:
94
+
4. The `rpcinfo`command is used for making RPC calls to an RPC server and then reporting on its findings. `rpcinfo` lists all the RPC services registered with `rpcbind`. Use `rpcinfo` to query your local server for a list of all registered RPC services. Type:
98
95
99
96
```bash
100
97
rpcinfo -p localhost
@@ -112,11 +109,12 @@ SYNOPSIS
112
109
From the sample output above, we can tell a service called portmapper is registered on the RPC server running localhost.
113
110
114
111
!!! Question
115
-
A) What is portmapper ?
116
-
B) Find out the meaning of the different fields (column heading) of the rpcinfo command?
117
-
Program, Vers, proto and service.
118
112
119
-
5. Check the status of nfs-server.service. Type:
113
+
A) What is portmapper?
114
+
B) Find out the meaning of the different fields (column heading) of the `rpcinfo` command?
115
+
Program, Vers, proto, and service.
116
+
117
+
5. Check the status of `nfs-server.service`. Type:
120
118
121
119
```bash
122
120
systemctl status nfs-server
@@ -129,41 +127,39 @@ SYNOPSIS
129
127
```
130
128
nfs-server.service is currently not running according to the output on our demo system.
131
129
132
-
133
-
7. Use systemctl to start the nfs-server daemon. Type:
130
+
6. Use systemctl to start the nfs-server daemon. Type:
134
131
135
132
```bash
136
133
systemctl start nfs-server
137
134
```
138
135
139
-
8. Check the status of the nfs-server service again.
136
+
7. Check the status of the nfs-server service again.
140
137
141
-
9. Run the `rpcinfo`command again to check if anything has changed.
138
+
8. Run the `rpcinfo`command again to check if anything has changed.
142
139
143
140
!!! Question
144
-
What new services do you see listed in the rpcinfo output after starting nfs-server?
141
+
142
+
What new services do you see listed in the `rpcinfo` output after starting nfs-server?
145
143
146
-
10. Verify that `nfs-server.service` is set to automatically start every time the system reboots.
147
-
Type:
148
-
144
+
9. Verify that `nfs-server.service` is set to automatically start every time the system reboots. Type:
145
+
149
146
```bash
150
147
systemctl is-enabled nfs-server
151
148
```
152
-
11. If the nfs-server is disabled on your system, run the command to configure it for automatic
153
-
starts with the system.
154
149
155
-
12. If the firewall sub-system is running on your server, you'll need to allow/permit NFS traffic through the firewall for remote NFS clients. This can be done by running:
150
+
10. If the nfs-server is disabled on your system, run the command to configure it for automatic starts with the system.
151
+
152
+
11. If the firewall sub-system is running on your server, you'll need to allow/permit NFS traffic through the firewall for remote NFS clients. This can be done by running:
Creating a share is as simple as creating a directory or sharing an already existing directory on the local file system.
162
+
Creating a share is done by creating a directory or sharing an already existing directory on the local file system.
167
163
168
164
The `exportfs` utility is used for viewing and maintaining the table of exported NFS file systems. Its usage syntax and options are:
169
165
@@ -175,31 +171,31 @@ SYNOPSIS
175
171
/usr/sbin/exportfs [-v]
176
172
/usr/sbin/exportfs -f
177
173
/usr/sbin/exportfs -s
178
-
179
174
```
180
175
181
-
!!! NOTE
176
+
!!! note
177
+
182
178
Don't forget to replace all references to server<PR> with your partners actual hostname.
183
179
184
180
#### To create and export a share
185
181
186
182
You will create and share a directory called `/mnt/nfs`. This directory will serve as the source file-system that will be exported from the NFS server.
187
183
188
-
1. Make sure you are logged on to your system as a user with Administrative privileges.
184
+
1. Ensure you are logged on to your system as a user with administrative privileges.
189
185
190
186
2. Create a directory under `/mnt` called `nfs` and change to that directory.
191
187
192
188
```bash
193
189
mkdir /mnt/nfs &&cd /mnt/nfs
194
190
```
191
+
195
192
3. Create 5 sample files under the new directory you created. Type:
196
193
197
194
```bash
198
195
touch {1..5}nfs
199
196
```
200
197
201
-
4. Use the HEREDOC shell feature to create a new NFS export entry in`/etc/exports`.
202
-
The single line entry you want is - `/mnt/nfs foocentos2(rw) localhost(rw)`. Type:
198
+
4. Use the HEREDOC shell feature to create a new NFS export entry in`/etc/exports`. The single line entry you want is - `/mnt/nfs foocentos2(rw) localhost(rw)`. Type:
203
199
204
200
```bash
205
201
cat <<EOF > /etc/exports
@@ -210,22 +206,20 @@ You will create and share a directory called `/mnt/nfs`. This directory will ser
210
206
211
207
5. Verify the contents of `/etc/exports` to make sure there were no mistakes.
212
208
213
-
6. After making any change to the `/etc/exports` file you should run the “exportfs” command. Type:
209
+
6. After making any change to the `/etc/exports` file you should run the `exportfs` command. Type:
214
210
215
211
```bash
216
212
exportfs -r
217
213
```
218
214
219
-
7. Use the `-s` flag with the exportfs command to display the current export list suitable for
220
-
`/etc/exports`. i.e. View the list of directories, allowed hosts and options. Type:
215
+
7. Use the `-s` flag with the `exportfs`command to display the current export list suitable for`/etc/exports`. i.e. View the list of directories, allowed hosts and options. Type:
221
216
222
217
```bash
223
218
exportfs -s
224
219
```
225
220
226
221
List your output below.
227
222
228
-
229
223
## Exercise 3
230
224
231
225
### Mounting NFS shares
@@ -269,7 +263,7 @@ You will test the NFS server's configuration from *Exercise 1* by trying to acce
269
263
Export list for localhost:
270
264
/mnt/nfs 172.16.99.0/24,localhost
271
265
```
272
-
266
+
273
267
You should see whatever NFS exports that are configured on the server.
274
268
275
269
3. You are now ready to mount the NFS share at the test mount point. Type:
@@ -278,7 +272,7 @@ You will test the NFS server's configuration from *Exercise 1* by trying to acce
278
272
mount -t nfs localhost:/mnt/nfs /mnt/nfs-local
279
273
```
280
274
281
-
4. Change your PWD to the `/mnt/nfs-local` directory and list its contents?
275
+
4. Change your PWD to the `/mnt/nfs-local` directory and list its contents.
282
276
283
277
5. While still in the `/mnt/nfs-local` directory, attempt to delete some of the files. Type:
284
278
@@ -290,8 +284,9 @@ You will test the NFS server's configuration from *Exercise 1* by trying to acce
290
284
rm: cannot remove '1nfs': Permission denied
291
285
rm: cannot remove '2nfs': Permission denied
292
286
```
293
-
287
+
294
288
!!! Question
289
+
295
290
Was your file deletion attempt successful?
296
291
297
292
7. Now try to create some additional files (6nfs, 7nfs, 8nfs) on the NFS share. Type:
@@ -300,16 +295,18 @@ You will test the NFS server's configuration from *Exercise 1* by trying to acce
300
295
touch {6..8}nfs
301
296
```
302
297
303
-
!!! Question:
298
+
!!! Question
299
+
304
300
Was your file creation attempt successful? Why do you think this failed?
305
301
302
+
306
303
PERFORM THIS EXERCISE FROM YOUR PARTNER-SYSTEM
307
304
308
305
#### To access an NFS share remotely
309
306
310
-
1. While logged into serverPR as the superuser, install the nfs-utils package if it isn't already installed.
311
-
2. Create a directory called “`/mnt/nfs-remote`” that will serve as the mount point for the
312
-
remote NFS share. Type:
307
+
1. While logged into serverPR as the superuser, install the `nfs-utils` package if it isn't already installed.
308
+
309
+
2. Create a directory called “`/mnt/nfs-remote`” that will serve as the mount point for the remote NFS share. Type:
313
310
314
311
```bash
315
312
mkdir /mnt/nfs-remote
@@ -321,8 +318,7 @@ PERFORM THIS EXERCISE FROM YOUR PARTNER-SYSTEM
321
318
mount -t nfs 172.16.99.100:/mnt/nfs /mnt/nfs-remote
322
319
```
323
320
324
-
4. Use the `mount` command to display some extra information about the NFS share that you just
325
-
mounted. Type:
321
+
4. Use the `mount` command to display some extra information about the NFS share that you just mounted. Type:
326
322
327
323
```bash
328
324
mount -t nfs4
@@ -333,12 +329,12 @@ PERFORM THIS EXERCISE FROM YOUR PARTNER-SYSTEM
333
329
...<SNIP>...
334
330
```
335
331
336
-
5. cd to the NFS mount point and try to delete its contents. Type:
332
+
5. `cd` to the NFS mount point and try to delete its contents. Type:
337
333
338
334
```bash
339
335
cd /mnt/nfs-remote ; rm -f
340
336
```
341
-
337
+
342
338
Was your attempt successful?
343
339
344
340
6. Logout of serverPR as the superuser and log back in as the unprivileged user “ying”
@@ -349,14 +345,15 @@ PERFORM THIS EXERCISE FROM YOUR PARTNER-SYSTEM
349
345
cd /mnt/nfs-remote/
350
346
```
351
347
352
-
8. Make a note of the contents of the directory. If you are able to see the expected files, you have successfully completed the NFS lab :-)!
348
+
8. Make a note of the contents of the directory. If you are able to see the expected files, you have successfully completed the NFS lab!
349
+
350
+
!!! question "Questions"
351
+
352
+
1. Configure the NFS setup on your local server (serverXY), such that the superuser at the H.Q. (hq.example.org) will be able to mount your nfs share (/mnt/nfsXY) for use on the hq machine.
353
353
354
-
!!! Question "Questions"
355
-
1. Configure the NFS setup on your local server (serverXY), such that the superuser at the H.Q.
356
-
(hq.example.org) will be able to mount your nfs share (/mnt/nfsXY) for use on the hq machine
357
-
2. The superuser at HQ should be able to write (create) new files and delete the files on your NFS share.
354
+
2. The superuser at HQ should be able to write (create) new files and delete the files on your NFS share.
358
355
359
-
!!! Tip
360
-
You need to disable NFS’s special treatment of root-owned files.
361
-
This is done by specifying a certain option that will “un-squash” the superuser in the “/etc/exports” file
356
+
!!! Tip
357
+
358
+
You need to disable NFS’s special treatment of root-owned files. This is done by specifying a certain option that will “un-squash” the superuser in the “/etc/exports” file.
0 commit comments