]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man8/diskless.8
This commit was generated by cvs2svn to compensate for changes in r151497,
[FreeBSD/FreeBSD.git] / share / man / man8 / diskless.8
1 .\" Copyright (c) 1994 Gordon W. Ross, Theo de Raadt
2 .\" Updated by Luigi Rizzo, Robert Watson
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. The name of the author may not be used to endorse or promote products
14 .\"    derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd September 28, 2004
30 .Dt DISKLESS 8
31 .Os
32 .Sh NAME
33 .Nm diskless
34 .Nd booting a system over the network
35 .Sh DESCRIPTION
36 The ability to boot a machine over the network is useful for
37 .Em diskless
38 or
39 .Em dataless
40 machines, or as a temporary measure while repairing or
41 re-installing file systems on a local disk.
42 This file provides a general description of the interactions between
43 a client and its server when a client is booting over the network.
44 .Sh OPERATION
45 When booting a system over the network, there are three
46 phases of interaction between client and server:
47 .Bl -enum
48 .It
49 The stage-1 bootstrap, typically PXE built into your Ethernet
50 card, loads a second-stage boot program.
51 .It
52 The second-stage boot program, typically
53 .Xr pxeboot 8 ,
54 loads modules and
55 the kernel, and boots the kernel.
56 .It
57 The kernel
58 .Tn NFS
59 mounts the root directory and continues from there.
60 .El
61 .Pp
62 Each of these phases are described in further detail below.
63 .Pp
64 First, the stage-1 bootstrap loads the stage-2 boot program over
65 the network.
66 The stage-1 bootstrap typically uses
67 .Tn BOOTP
68 or
69 .Tn DHCP
70 to obtain the filename to load, then uses
71 .Tn TFTP
72 to load the file.
73 This file is typically called
74 .Pa pxeboot ,
75 and should be copied from
76 .Pa /boot/pxeboot
77 into the
78 .Tn TFTP
79 directory on the server, which is typically
80 .Pa /tftpdir .
81 .Pp
82 The stage-2 boot program then loads additional modules and the kernel.
83 These files may not exist on the
84 .Tn DHCP
85 or
86 .Tn BOOTP
87 server.
88 You can use the
89 .Ic next-server
90 option available in
91 .Tn DHCP
92 configurations to specify the server holding
93 the second stage boot files and kernel.
94 The stage-2 program uses
95 .Tn NFS
96 or
97 .Tn TFTP
98 to obtain these files.
99 By default,
100 .Tn NFS
101 is used.
102 If you are using
103 .Xr pxeboot 8 ,
104 you can install a version that uses
105 .Tn TFTP
106 by setting
107 .Li LOADER_TFTP_SUPPORT=YES
108 in your
109 .Xr make.conf 5 ,
110 then recompiling and reinstalling
111 .Xr pxeboot 8
112 via the command listed below.
113 It is often necessary to use
114 .Tn TFTP
115 here so you can place a custom kernel
116 in
117 .Pa /tftpdir/ .
118 If you use
119 .Tn NFS
120 and do not have a custom root file system for the
121 .Nm
122 client, the stage-2 boot will load your server's kernel as the kernel for
123 the
124 .Nm
125 machine, which may not be what you want to have happen.
126 .Bd -literal -offset indent
127 cd /usr/src/sys/boot/i386
128 make clean; make; make install
129 cp /boot/pxeboot /tftpdir/
130 .Ed
131 .Pp
132 In phase 3, the kernel acquires IP networking configuration in one
133 of two ways, and then proceeds to mount the root file system and start
134 operation.
135 If the phase 2 loader supports passing network configuration to the
136 kernel using the kernel environment, then the kernel will configure
137 the network interface using that information.
138 Otherwise, it must use
139 .Tn DHCP
140 or
141 .Tn BOOTP
142 to acquire
143 configuration information.
144 The boot
145 scripts recognize a
146 .Nm
147 startup and perform
148 the actions found in
149 .Pa /etc/rc.d/initdiskless ,
150 .Pa /etc/rc.d/resolv ,
151 .Pa /etc/rc.d/tmp ,
152 and
153 .Pa /etc/rc.d/var .
154 On early 5.x releases, the functions of latter three scripts where
155 implemented in
156 .Pa /etc/rc.d/diskless .
157 On older systems, the scripts are located in
158 .Pa /etc/rc.diskless1
159 and
160 .Pa /etc/rc.diskless2 .
161 .Sh CONFIGURATION
162 In order to run a
163 .Nm
164 client, you need the following:
165 .Bl -bullet
166 .It
167 An
168 .Tn NFS
169 server which exports a root and
170 .Pa /usr
171 partitions with appropriate permissions.
172 The
173 .Nm
174 scripts work with read-only partitions, as long as root is exported with
175 .Fl maproot Ns =0
176 so that some system files can be accessed.
177 As an example,
178 .Pa /etc/exports
179 can contain the following lines:
180 .Bd -literal -offset indent
181 <ROOT> -ro -maproot=0 -alldirs <list of diskless clients>
182 /usr -ro -alldirs <list of diskless clients>
183 .Ed
184 .Pp
185 where
186 .Aq ROOT
187 is the mount point on the server of the root partition.
188 The script
189 .Pa /usr/share/examples/diskless/clone_root
190 can be used to create a shared read-only root partition,
191 but in many cases you may decide to export
192 (again as read-only) the root directory used by
193 the server itself.
194 .It
195 A
196 .Tn BOOTP
197 or
198 .Tn DHCP
199 server.
200 .Xr bootpd 8
201 can be enabled by
202 uncommenting the
203 .Dq Li bootps
204 line in
205 .Pa /etc/inetd.conf .
206 A sample
207 .Pa /etc/bootptab
208 can be the following:
209 .Bd -literal -offset indent
210  .default:\\
211     hn:ht=1:vm=rfc1048:\\
212     :sm=255.255.255.0:\\
213     :sa=<SERVER>:\\
214     :gw=<GATEWAY>:\\
215     :rp="<SERVER>:<ROOT>":
216
217 <CLIENT>:ha=0123456789ab:tc=.default
218 .Ed
219 .Pp
220 where
221 .Aq SERVER ,
222 .Aq GATEWAY
223 and
224 .Aq ROOT
225 have the obvious meanings.
226 .It
227 A properly initialized root partition.
228 The script
229 .Pa /usr/share/examples/diskless/clone_root
230 can help in creating it, using the server's root partition
231 as a reference.
232 If you are just starting out, you should
233 simply use the server's own root directory,
234 .Pa / ,
235 and not try to clone it.
236 .Pp
237 You often do not want to use the same
238 .Pa rc.conf
239 or
240 .Pa rc.local
241 files for the
242 .Nm
243 boot as you do on the server.
244 The
245 .Nm
246 boot
247 scripts provide a mechanism through which you can override various files
248 in
249 .Pa /etc
250 (as well as other subdirectories of root).
251 The scripts provide four
252 overriding directories situated in
253 .Pa /conf/base ,
254 .Pa /conf/default ,
255 .Pa /conf/<broadcast-ip> ,
256 and
257 .Pa /conf/<machine-ip> .
258 You should always create
259 .Pa /conf/base/etc ,
260 which will entirely replace the server's
261 .Pa /etc
262 on the
263 .Nm
264 machine.
265 You can clone the server's
266 .Pa /etc
267 here or you can create a special file which tells the
268 .Nm
269 boot scripts
270 to remount the server's
271 .Pa /etc
272 onto
273 .Pa /conf/base/etc .
274 You do this by creating the file
275 .Pa /conf/base/etc/diskless_remount
276 containing the mount point to use as a basis of the
277 .Nm
278 machine's
279 .Pa /etc .
280 For example, the file might contain:
281 .Pp
282 .Dl 10.0.0.1:/etc
283 .Pp
284 Alternatively, if the server contains several independent roots, the file
285 might contain:
286 .Pp
287 .Dl 10.0.0.1:/usr/diskless/4.7-RELEASE/etc
288 .Pp
289 This would work, but if you copied
290 .Pa /usr/diskless/4.7-RELEASE
291 to
292 .Pa /usr/diskless/4.8-RELEASE
293 and upgraded the installation, you would need to modify the
294 .Pa diskless_remount
295 files to reflect that move.
296 To avoid that, paths in
297 .Pa diskless_remount
298 files beginning with
299 .Pa /
300 have the actual path of the client's root prepended to them so the file
301 could instead contain:
302 .Pp
303 .Dl /etc
304 .Pp
305 The
306 .Nm
307 scripts create memory file systems to hold the overridden
308 directories.
309 Only a 2MB partition is created by default, which may not
310 be sufficient for your purposes.
311 To override this, you can create the
312 file
313 .Pa /conf/base/etc/md_size
314 containing the size, in 512 byte sectors, of the memory disk to create
315 for that directory.
316 .Pp
317 You then typically provide file-by-file overrides in the
318 .Pa /conf/default/etc
319 directory.
320 At a minimum, you must provide overrides for
321 .Pa /etc/fstab , /etc/rc.conf ,
322 and
323 .Pa /etc/rc.local
324 via
325 .Pa /conf/default/etc/fstab , /conf/default/etc/rc.conf ,
326 and
327 .Pa /conf/default/etc/rc.local .
328 .Pp
329 Overrides are hierarchical.
330 You can supply network-specific defaults
331 in the
332 .Pa /conf/ Ns Ao Ar BROADCASTIP Ac Ns Pa /etc
333 directory, where
334 .Aq Ar BROADCASTIP
335 represents the broadcast IP address of
336 the
337 .Nm
338 system as given to it via
339 .Tn BOOTP .
340 The
341 .Pa diskless_remount
342 and
343 .Pa md_size
344 features work in any of these directories.
345 The configuration feature works on directories other then
346 .Pa /etc ,
347 you simply create the directory you wish to replace or override in
348 .Pa /conf/{base,default,<broadcast>,<ip>}/*
349 and work it in the same way that you work
350 .Pa /etc .
351 .Pp
352 Since you normally clone the server's
353 .Pa /etc
354 using the
355 .Pa /conf/base/etc/diskless_remount ,
356 you might wish to remove unneeded files from the memory file system.
357 For example,
358 if the server has a firewall but you do not, you might wish
359 to remove
360 .Pa /etc/ipfw.conf .
361 You can do this by creating a
362 .Pa /conf/base/ Ns Ao Ar DIRECTORY Ac Ns Pa .remove
363 file.
364 For example,
365 .Pa /conf/base/etc.remove ,
366 which contains a list of relative paths that the boot scripts should remove
367 from the memory file systems.
368 .Pp
369 As a minimum, you normally need to have the following in
370 .Pa /conf/default/etc/fstab
371 .Bd -literal -offset indent
372 <SERVER>:<ROOT> /     nfs    ro 0 0
373 <SERVER>:/usr   /usr  nfs    ro 0 0
374 proc            /proc procfs rw 0 0
375 .Ed
376 .Pp
377 You also need to create a customized version of
378 .Pa /conf/default/etc/rc.conf
379 which should contain
380 the startup options for the
381 .Nm
382 client, and
383 .Pa /conf/default/etc/rc.local
384 which could be empty but prevents the server's own
385 .Pa /etc/rc.local
386 from leaking onto the
387 .Nm
388 system.
389 .Pp
390 In
391 .Pa rc.conf ,
392 most likely
393 you will not need to set
394 .Va hostname
395 and
396 .Va ifconfig_*
397 because these will be already set by the startup code.
398 Finally, it might be convenient to use a
399 .Ic case
400 statement using
401 .Li `hostname`
402 as the switch variable to do machine-specific configuration
403 in case a number of
404 .Nm
405 clients share the same configuration
406 files.
407 .It
408 The kernel for the
409 .Nm
410 clients, which will be loaded using
411 .Tn NFS
412 or
413 .Tn TFTP ,
414 must include support for the NFS client:
415 .Pp
416 .D1 Cd "options NFSCLIENT"
417 .D1 Cd "options NFS_ROOT"
418 .Pp
419 If you are using a boot mechanism that does not pass network configuration
420 to the kernel using the kernel environment, you will also need to include
421 the following options:
422 .Pp
423 .D1 Cd "options BOOTP"
424 .D1 Cd "options BOOTP_NFSROOT"
425 .D1 Cd "options BOOTP_COMPAT"
426 .Pp
427 .Em Note :
428 the PXE environment does not require these options.
429 .Pp
430 The
431 .Nm
432 booting environment relies on memory-backed file systems to
433 support temporary local storage in the event that the root file system
434 is mounted read-only; as such, it is necessary to add the following
435 to the device section of the kernel configuration:
436 .Pp
437 .D1 Cd "device md"
438 .Pp
439 If you use the firewall, remember to default to
440 .Dq open ,
441 or your kernel
442 will not be able to send/receive the
443 .Tn BOOTP
444 packets.
445 .El
446 .Sh SECURITY ISSUES
447 Be warned that using unencrypted
448 .Tn NFS
449 to mount root and user
450 partitions may expose information such as
451 encryption keys.
452 .Sh SEE ALSO
453 .Xr ethers 5 ,
454 .Xr exports 5 ,
455 .Xr bootpd 8 ,
456 .Xr make.conf 5 ,
457 .Xr mountd 8 ,
458 .Xr nfsd 8 ,
459 .Xr pxeboot 8 ,
460 .Xr reboot 8 ,
461 .Xr tftpd 8
462 .Pp
463 .Pa ports/net/etherboot
464 .Sh BUGS
465 This manpage is probably incomplete.
466 .Pp
467 .Fx
468 sometimes requires to write onto
469 the root partition, so the startup scripts mount MFS
470 file systems on some locations (e.g.\&
471 .Pa /etc
472 and
473 .Pa /var ) ,
474 while
475 trying to preserve the original content.
476 The process might not handle all cases.