blob: 26a969bd8e762f52a0e64039eb21500f5070c002 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# NFS filesystem mounting -*- shell-script -*-
# FIXME This needs error checking
nfs_top()
{
if [ "${nfs_top_used}" != "yes" ]; then
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/nfs-top"
run_scripts /scripts/nfs-top
[ "$quiet" != "y" ] && log_end_msg
fi
nfs_top_used=yes
}
nfs_premount()
{
if [ "${nfs_premount_used}" != "yes" ]; then
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/nfs-premount"
run_scripts /scripts/nfs-premount
[ "$quiet" != "y" ] && log_end_msg
fi
nfs_premount_used=yes
}
nfs_bottom()
{
if [ "${nfs_premount_used}" = "yes" ] || [ "${nfs_top_used}" = "yes" ]; then
[ "${quiet?}" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"
run_scripts /scripts/nfs-bottom
[ "$quiet" != "y" ] && log_end_msg
fi
nfs_premount_used=no
nfs_top_used=no
}
# parse nfs bootargs and mount nfs
nfs_mount_root_impl()
{
configure_networking
# get nfs root from dhcp
if [ "${NFSROOT}" = "auto" ]; then
# check if server ip is part of dhcp root-path
if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
else
NFSROOT=${ROOTPATH}
fi
# nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
elif [ -n "${NFSROOT}" ]; then
# nfs options are an optional arg
if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
NFSOPTS="-o ${NFSROOT#*,}"
fi
NFSROOT=${NFSROOT%%,*}
if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
NFSROOT=${ROOTSERVER}:${NFSROOT}
fi
fi
if [ -z "${NFSOPTS}" ]; then
NFSOPTS="-o retrans=10"
fi
nfs_premount
if [ "${readonly?}" = y ]; then
roflag="-o ro"
else
roflag="-o rw"
fi
# shellcheck disable=SC2086
nfsmount -o nolock ${roflag} ${NFSOPTS} "${NFSROOT}" "${rootmnt?}"
}
# NFS root mounting
nfs_mount_root()
{
nfs_top
# For DHCP
/sbin/modprobe af_packet
wait_for_udev 10
# Default delay is around 180s
delay=${ROOTDELAY:-180}
# loop until nfsmount succeeds
nfs_mount_root_impl
ret=$?
nfs_retry_count=0
while [ ${nfs_retry_count} -lt "${delay}" ] \
&& [ $ret -ne 0 ] ; do
[ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
sleep 1
nfs_mount_root_impl
ret=$?
nfs_retry_count=$(( nfs_retry_count + 1 ))
[ "$quiet" != "y" ] && log_end_msg
done
}
nfs_mount_fs_impl()
{
configure_networking
if [ -z "${NFSOPTS}" ]; then
NFSOPTS="-o retrans=10"
fi
nfs_premount
if [ "${readonly}" = y ]; then
roflag="-o ro"
else
roflag="-o rw"
fi
read_fstab_entry "$1"
# shellcheck disable=SC2086
nfsmount ${roflag} ${NFSOPTS} -o "${MNT_OPTS}" "$MNT_FSNAME" "${rootmnt}${MNT_DIR}"
}
nfs_mount_fs()
{
nfs_top
# For DHCP
/sbin/modprobe af_packet
wait_for_udev 10
# Default delay is around 180s
delay=${ROOTDELAY:-180}
# Don't loop here; we can't sanely check if it worked like for
# the rootfs or /etc.
nfs_mount_fs_impl "$1"
}
mountroot()
{
nfs_mount_root
}
mount_top()
{
# Note, also called directly in case it's overridden.
nfs_top
}
mount_premount()
{
# Note, also called directly in case it's overridden.
nfs_premount
}
mount_bottom()
{
# Note, also called directly in case it's overridden.
nfs_bottom
}
|