2 TEST_DESCRIPTION
="root filesystem on NFS"
4 KVERSION
=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rdinitdebug rdnetdebug"
11 echo "NFS TEST SETUP: Starting DHCP/NFS server"
13 $testdir/run-qemu
-hda server.ext2
-m 512M
-nographic \
14 -net nic
,macaddr
=52:54:00:12:34:56,model
=e1000 \
15 -net socket
,mcast
=230.0.0.1:1234 \
16 -serial udp
:127.0.0.1:9999 \
17 -kernel /boot
/vmlinuz-
$KVERSION \
18 -append "root=/dev/sda rw quiet console=ttyS0,115200n81" \
19 -initrd initramfs.server
-pidfile server.pid
-daemonize ||
return 1
20 sudo
chmod 644 server.pid ||
return 1
22 # Cleanup the terminal if we have one
25 echo Sleeping
10 seconds to give the server a
head start
35 local nfsinfo opts found expected
37 echo "CLIENT TEST START: $test_name"
39 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
40 if ! dd if=/dev
/zero of
=client.img bs
=1M count
=1; then
41 echo "Unable to make client sda image" 1>&2
45 $testdir/run-qemu
-hda client.img
-m 512M
-nographic \
46 -net nic
,macaddr
=$mac,model
=e1000 \
47 -net socket
,mcast
=230.0.0.1:1234 \
48 -kernel /boot
/vmlinuz-
$KVERSION \
49 -append "$cmdline $DEBUGFAIL ro quiet console=ttyS0,115200n81" \
50 -initrd initramfs.testing
52 if [[ $?
-ne 0 ]] ||
! grep -m 1 -q nfs-OK client.img
; then
53 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
57 # nfsinfo=( server:/path nfs{,4} options )
58 nfsinfo
=($
(awk '{print $2, $3, $4; exit}' client.img
))
60 if [[ "${nfsinfo[0]%%:*}" != "$server" ]]; then
61 echo "CLIENT TEST INFO: got server: ${nfsinfo[0]%%:*}"
62 echo "CLIENT TEST INFO: expected server: $server"
63 echo "CLIENT TEST END: $test_name [FAILED - WRONG SERVER]"
69 if [[ ${check_opt:0:1} == '-' ]]; then
71 check_opt
=${check_opt:1}
76 if [[ ${opts%%,*} == $check_opt ]]; then
83 if [[ $found -ne $expected ]]; then
84 echo "CLIENT TEST INFO: got options: ${nfsinfo[2]%%:*}"
85 if [[ $expected -eq 0 ]]; then
86 echo "CLIENT TEST INFO: did not expect: $check_opt"
87 echo "CLIENT TEST END: $test_name [FAILED - UNEXPECTED OPTION]"
89 echo "CLIENT TEST INFO: missing: $check_opt"
90 echo "CLIENT TEST END: $test_name [FAILED - MISSING OPTION]"
95 echo "CLIENT TEST END: $test_name [OK]"
100 # MAC numbering scheme:
101 # NFSv3: last octect starts at 0x00 and works up
102 # NFSv4: last octect starts at 0x80 and works up
104 client_test
"NFSv3 netroot=dhcp DHCP path only" 52:54:00:12:34:00 \
105 "netroot=dhcp" 192.168.50.1 -wsize=4096 ||
return 1
107 client_test
"NFSv3 root=dhcp DHCP path only" 52:54:00:12:34:00 \
108 "root=dhcp" 192.168.50.1 -wsize=4096 ||
return 1
110 client_test
"NFSv3 root=nfs DHCP path only" 52:54:00:12:34:00 \
111 "root=nfs" 192.168.50.1 -wsize=4096 ||
return 1
113 client_test
"NFSv3 root=/dev/nfs DHCP path only" 52:54:00:12:34:00 \
114 "root=/dev/nfs" 192.168.50.1 -wsize=4096 ||
return 1
116 client_test
"NFSv3 netroot=dhcp DHCP IP:path" 52:54:00:12:34:01 \
117 "netroot=dhcp" 192.168.50.2 -wsize=4096 ||
return 1
119 client_test
"NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
120 "root=dhcp" 192.168.50.2 -wsize=4096 ||
return 1
122 client_test
"NFSv3 root=nfs DHCP IP:path" 52:54:00:12:34:01 \
123 "root=nfs" 192.168.50.2 -wsize=4096 ||
return 1
125 client_test
"NFSv3 root=/dev/nfs DHCP IP:path" 52:54:00:12:34:01 \
126 "root=/dev/nfs" 192.168.50.2 -wsize=4096 ||
return 1
128 client_test
"NFSv3 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:02 \
129 "root=dhcp" 192.168.50.3 -wsize=4096 ||
return 1
131 client_test
"NFSv3 netroot=dhcp DHCP proto:IP:path:options" \
132 52:54:00:12:34:03 "netroot=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
134 client_test
"NFSv3 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:03 \
135 "root=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
137 client_test
"NFSv3 netroot=nfs:..." 52:54:00:12:34:04 \
138 "netroot=nfs:192.168.50.1:/nfs/client" 192.168.50.1 \
139 -wsize=4096 ||
return 1
141 client_test
"NFSv3 root=nfs:..." 52:54:00:12:34:04 \
142 "root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 ||
return 1
144 client_test
"NFSv3 nfsroot=/nfs/client" 52:54:00:12:34:04 \
145 "nfsroot=/nfs/client" 192.168.50.1 -wsize=4096 ||
return 1
147 client_test
"NFSv3 nfsroot=192.168.50.2:/nfs/client" 52:54:00:12:34:04 \
148 "nfsroot=192.168.50.2:/nfs/client" 192.168.50.2 -wsize=4096 ||
return 1
150 client_test
"NFSv3 root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
151 "root=dhcp nfsroot=/nfs/client" 192.168.50.1 -wsize=4096 ||
return 1
153 client_test
"NFSv3 root=nfs nfsroot=/nfs/client" 52:54:00:12:34:04 \
154 "root=nfs nfsroot=/nfs/client" 192.168.50.1 -wsize=4096 ||
return 1
156 client_test
"NFSv3 root=nfs nfsroot=/nfs/%s" 52:54:00:12:34:04 \
157 "root=nfs nfsroot=/nfs/%s" 192.168.50.1 -wsize=4096 ||
return 1
159 client_test
"NFSv3 root=nfs nfsroot=/nfs/ip/%s no host name (use IP)" \
161 "root=nfs nfsroot=/nfs/ip/%s \
162 ip=192.168.50.101:192.168.50.1::255.255.255.0::eth0:static" \
163 192.168.50.1 -wsize=4096 ||
return 1
165 client_test
"NFSv3 root=nfs nfsroot=/nfs/client,wsize=4096" \
166 52:54:00:12:34:04 "root=nfs nfsroot=/nfs/client,wsize=4096" \
167 192.168.50.1 wsize
=4096 ||
return 1
169 client_test
"NFSv3 root=nfs DHCP path,options" \
170 52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize
=4096 ||
return 1
172 client_test
"NFSv3 root=dhcp DHCP IP:path,options" \
173 52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize
=4096 ||
return 1
175 client_test
"NFSv3 root=dhcp DHCP proto:IP:path,options" \
176 52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
180 # There is a mandatory 90 second recovery when starting the NFSv4
181 # server, so put these later in the list to avoid a pause when doing
184 client_test
"NFSv4 netroot=nfs4 DHCP path only" 52:54:00:12:34:80 \
185 "netroot=nfs4" 192.168.50.1 -wsize=4096 ||
return 1
187 client_test
"NFSv4 root=nfs4 DHCP path only" 52:54:00:12:34:80 \
188 "root=nfs4" 192.168.50.1 -wsize=4096 ||
return 1
190 client_test
"NFSv4 root=/dev/nfs4 DHCP path only" 52:54:00:12:34:80 \
191 "root=/dev/nfs4" 192.168.50.1 -wsize=4096 ||
return 1
193 client_test
"NFSv4 netroot=nfs4 DHCP IP:path" 52:54:00:12:34:81 \
194 "netroot=nfs4" 192.168.50.2 -wsize=4096 ||
return 1
196 client_test
"NFSv4 root=nfs4 DHCP IP:path" 52:54:00:12:34:81 \
197 "root=nfs4" 192.168.50.2 -wsize=4096 ||
return 1
199 client_test
"NFSv4 root=/dev/nfs4 DHCP IP:path" 52:54:00:12:34:81 \
200 "root=/dev/nfs4" 192.168.50.2 -wsize=4096 ||
return 1
202 client_test
"NFSv4 netroot=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
203 "netroot=dhcp" 192.168.50.3 -wsize=4096 ||
return 1
205 client_test
"NFSv4 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
206 "root=dhcp" 192.168.50.3 -wsize=4096 ||
return 1
208 client_test
"NFSv4 netroot=dhcp DHCP proto:IP:path:options" \
209 52:54:00:12:34:83 "netroot=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
211 client_test
"NFSv4 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:83 \
212 "root=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
214 client_test
"NFSv4 netroot=nfs4:..." 52:54:00:12:34:84 \
215 "netroot=nfs4:192.168.50.1:/client" 192.168.50.1 \
216 -wsize=4096 ||
return 1
218 client_test
"NFSv4 root=nfs4:..." 52:54:00:12:34:84 \
219 "root=nfs4:192.168.50.1:/client" 192.168.50.1 \
220 -wsize=4096 ||
return 1
222 client_test
"NFSv4 root=nfs4 nfsroot=/client" 52:54:00:12:34:84 \
223 "root=nfs4 nfsroot=/client" 192.168.50.1 -wsize=4096 ||
return 1
225 client_test
"NFSv4 root=nfs4 nfsroot=192.168.50.2:/client" \
226 52:54:00:12:34:84 "root=nfs4 nfsroot=192.168.50.2:/client" \
227 192.168.50.2 -wsize=4096 ||
return 1
229 client_test
"NFSv4 root=nfs4 nfsroot=path,opts" \
230 52:54:00:12:34:84 "root=nfs4 nfsroot=/client,wsize=4096" \
231 192.168.50.1 wsize
=4096 ||
return 1
233 # These two only work with NFSv4 in the test suite -- NFSv3 needs
234 # a /nfs prefix due to our server configuration
236 client_test
"NFSv4 netroot=nfs4" 52:54:00:12:34:84 \
237 "netroot=nfs4" 192.168.50.1 -wsize=4096 ||
return 1
239 client_test
"NFSv4 root=nfs4" 52:54:00:12:34:84 \
240 "root=nfs4" 192.168.50.1 -wsize=4096 ||
return 1
242 client_test
"NFSv4 root=nfs4 DHCP path,options" \
243 52:54:00:12:34:85 "root=nfs4" 192.168.50.1 wsize
=4096 ||
return 1
245 client_test
"NFSv4 root=nfs4 DHCP IP:path,options" \
246 52:54:00:12:34:86 "root=nfs4" 192.168.50.2 wsize
=4096 ||
return 1
248 client_test
"NFSv4 root=dhcp DHCP proto:IP:path,options" \
249 52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize
=4096 ||
return 1
253 if ! run_server
; then
254 echo "Failed to start server" 1>&2
258 test_nfsv3 ||
return 1
264 dd if=/dev
/zero of
=server.ext2 bs
=1M count
=60
265 mke2fs
-F server.ext2
267 sudo mount
-o loop server.ext2 mnt
272 .
$basedir/dracut-functions
273 dracut_install sh
ls shutdown poweroff stty
cat ps
ln ip \
274 /lib
/terminfo
/l
/linux dmesg mkdir
cp ping exportfs \
275 rpcbind modprobe rpc.nfsd rpc.mountd dhcpd showmount tcpdump \
276 /etc
/netconfig
/etc
/services
sleep mount
277 instmods nfsd sunrpc ipv6
278 inst .
/server-init
/sbin
/init
279 inst .
/hosts
/etc
/hosts
280 inst .
/exports
/etc
/exports
281 inst .
/dhcpd.conf
/etc
/dhcpd.conf
282 dracut_install
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
283 dracut_install rpc.idmapd
/etc
/idmapd.conf
284 if ldd $
(which rpc.idmapd
) |
grep -q lib64
; then
290 dracut_install $
(ls {/usr
,}$LIBDIR/libnfsidmap
*.so
* 2>/dev
/null
)
291 dracut_install $
(ls {/usr
,}$LIBDIR/libnss
*.so
2>/dev
/null
)
294 mkdir
-p dev sys proc etc var
/run tmp var
/lib
/{dhcpd
,rpcbind
}
295 mkdir
-p var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
296 chmod 777 var
/lib
/rpcbind var
/lib
/nfs
298 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
299 inst
/etc
/passwd
/etc
/passwd
300 inst
/etc
/group
/etc
/group
301 for i
in /lib
*/libnss_files
**;do
305 /sbin
/depmod
-a -b "$initdir" $kernel
306 ldconfig
-n -r "$initdir" /lib
* /usr
/lib
*
309 # Make client root inside server root
310 initdir
=mnt
/nfs
/client
314 .
$basedir/dracut-functions
315 dracut_install sh shutdown poweroff stty
cat ps
ln ip \
316 /lib
/terminfo
/l
/linux mount dmesg mkdir \
318 inst .
/client-init
/sbin
/init
321 mkdir
-p dev sys proc etc
322 mkdir
-p var
/lib
/nfs
/rpc_pipefs
324 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
325 inst
/etc
/passwd
/etc
/passwd
326 inst
/etc
/group
/etc
/group
327 for i
in /lib
*/libnss_files
*;do
331 ldconfig
-n -r "$initdir" /lib
* /usr
/lib
*
334 mkdir
-p mnt
/nfs
/nfs3-5
335 mkdir
-p mnt
/nfs
/ip
/192.168.50.101
336 mkdir
-p mnt
/nfs
/tftpboot
/nfs4-5
341 # Make an overlay with needed tools for the test harness
345 .
$basedir/dracut-functions
346 dracut_install poweroff shutdown
347 inst_simple .
/hard-off.sh
/emergency
/01hard-off.sh
350 # Make server's dracut image
351 $basedir/dracut
-l -i overlay
/ \
352 -m "dash udev-rules base rootfs-block debug" \
353 -d "ata_piix ext2 sd_mod e1000" \
354 -f initramfs.server
$KVERSION ||
return 1
356 # Make client's dracut image
357 $basedir/dracut
-l -i overlay
/ \
358 -m "dash udev-rules base network nfs debug" \
359 -d "e1000 nfs sunrpc" \
360 -f initramfs.testing
$KVERSION ||
return 1
364 if [[ -s server.pid
]]; then
365 sudo
kill -TERM $
(cat server.pid
)
369 rm -f server.ext2 client.img initramfs.server initramfs.testing
372 .
$testdir/test-functions