]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man8/diskless.8
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 August 7, 2011
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/resolv ,
150 .Pa /etc/rc.d/tmp ,
151 .Pa /etc/rc.d/var ,
152 and
153 .Pa /etc/rc.initdiskless .
154 .Sh CONFIGURATION
155 In order to run a
156 .Nm
157 client, you need the following:
158 .Bl -bullet
159 .It
160 An
161 .Tn NFS
162 server which exports a root and
163 .Pa /usr
164 partitions with appropriate permissions.
165 The
166 .Nm
167 scripts work with read-only partitions, as long as root is exported with
168 .Fl maproot Ns =0
169 so that some system files can be accessed.
170 As an example,
171 .Pa /etc/exports
172 can contain the following lines:
173 .Bd -literal -offset indent
174 <ROOT> -ro -maproot=0 -alldirs <list of diskless clients>
175 /usr -ro -alldirs <list of diskless clients>
176 .Ed
177 .Pp
178 where
179 .Aq ROOT
180 is the mount point on the server of the root partition.
181 The script
182 .Pa /usr/share/examples/diskless/clone_root
183 can be used to create a shared read-only root partition,
184 but in many cases you may decide to export
185 (again as read-only) the root directory used by
186 the server itself.
187 .It
188 A
189 .Tn BOOTP
190 or
191 .Tn DHCP
192 server.
193 .Xr bootpd 8
194 can be enabled by
195 uncommenting the
196 .Dq Li bootps
197 line in
198 .Pa /etc/inetd.conf .
199 A sample
200 .Pa /etc/bootptab
201 can be the following:
202 .Bd -literal -offset indent
203  .default:\\
204     hn:ht=1:vm=rfc1048:\\
205     :sm=255.255.255.0:\\
206     :sa=<SERVER>:\\
207     :gw=<GATEWAY>:\\
208     :rp="<SERVER>:<ROOT>":
209
210 <CLIENT>:ha=0123456789ab:tc=.default
211 .Ed
212 .Pp
213 where
214 .Aq SERVER ,
215 .Aq GATEWAY
216 and
217 .Aq ROOT
218 have the obvious meanings.
219 .It
220 A properly initialized root partition.
221 The script
222 .Pa /usr/share/examples/diskless/clone_root
223 can help in creating it, using the server's root partition
224 as a reference.
225 If you are just starting out, you should
226 simply use the server's own root directory,
227 .Pa / ,
228 and not try to clone it.
229 .Pp
230 You often do not want to use the same
231 .Pa rc.conf
232 or
233 .Pa rc.local
234 files for the
235 .Nm
236 boot as you do on the server.
237 The
238 .Nm
239 boot
240 scripts provide a mechanism through which you can override various files
241 in
242 .Pa /etc
243 (as well as other subdirectories of root).
244 .Pp
245 One difference that you should pay particular attention to is
246 the value of
247 .Va local_startup
248 in
249 .Pa /etc/defaults/rc.conf .
250 A typical value for a
251 .Nm
252 boot is
253 .Va mountcritremote ,
254 however your needs may be different.
255 .Pp
256 The scripts provide four
257 overriding directories situated in
258 .Pa /conf/base ,
259 .Pa /conf/default ,
260 .Pa /conf/<broadcast-ip> ,
261 and
262 .Pa /conf/<machine-ip> .
263 You should always create
264 .Pa /conf/base/etc ,
265 which will entirely replace the server's
266 .Pa /etc
267 on the
268 .Nm
269 machine.
270 You can clone the server's
271 .Pa /etc
272 here or you can create a special file which tells the
273 .Nm
274 boot scripts
275 to remount the server's
276 .Pa /etc
277 onto
278 .Pa /conf/base/etc .
279 You do this by creating the file
280 .Pa /conf/base/etc/diskless_remount
281 containing the mount point to use as a basis of the
282 .Nm
283 machine's
284 .Pa /etc .
285 For example, the file might contain:
286 .Pp
287 .Dl 10.0.0.1:/etc
288 .Pp
289 Alternatively, if the server contains several independent roots, the file
290 might contain:
291 .Pp
292 .Dl 10.0.0.1:/usr/diskless/4.7-RELEASE/etc
293 .Pp
294 This would work, but if you copied
295 .Pa /usr/diskless/4.7-RELEASE
296 to
297 .Pa /usr/diskless/4.8-RELEASE
298 and upgraded the installation, you would need to modify the
299 .Pa diskless_remount
300 files to reflect that move.
301 To avoid that, paths in
302 .Pa diskless_remount
303 files beginning with
304 .Pa /
305 have the actual path of the client's root prepended to them so the file
306 could instead contain:
307 .Pp
308 .Dl /etc
309 .Pp
310 The
311 .Nm
312 scripts create memory file systems to hold the overridden
313 directories.
314 Only a 2MB partition is created by default, which may not
315 be sufficient for your purposes.
316 To override this, you can create the
317 file
318 .Pa /conf/base/etc/md_size
319 containing the size, in 512 byte sectors, of the memory disk to create
320 for that directory.
321 .Pp
322 You then typically provide file-by-file overrides in the
323 .Pa /conf/default/etc
324 directory.
325 At a minimum, you must provide overrides for
326 .Pa /etc/fstab , /etc/rc.conf ,
327 and
328 .Pa /etc/rc.local
329 via
330 .Pa /conf/default/etc/fstab , /conf/default/etc/rc.conf ,
331 and
332 .Pa /conf/default/etc/rc.local .
333 .Pp
334 Overrides are hierarchical.
335 You can supply network-specific defaults
336 in the
337 .Pa /conf/ Ns Ao Ar BROADCASTIP Ac Ns Pa /etc
338 directory, where
339 .Aq Ar BROADCASTIP
340 represents the broadcast IP address of
341 the
342 .Nm
343 system as given to it via
344 .Tn BOOTP .
345 The
346 .Pa diskless_remount
347 and
348 .Pa md_size
349 features work in any of these directories.
350 The configuration feature works on directories other then
351 .Pa /etc ,
352 you simply create the directory you wish to replace or override in
353 .Pa /conf/{base,default,<broadcast>,<ip>}/*
354 and work it in the same way that you work
355 .Pa /etc .
356 .Pp
357 Since you normally clone the server's
358 .Pa /etc
359 using the
360 .Pa /conf/base/etc/diskless_remount ,
361 you might wish to remove unneeded files from the memory file system.
362 For example,
363 if the server has a firewall but you do not, you might wish
364 to remove
365 .Pa /etc/ipfw.conf .
366 You can do this by creating a
367 .Pa /conf/base/ Ns Ao Ar DIRECTORY Ac Ns Pa .remove
368 file.
369 For example,
370 .Pa /conf/base/etc.remove ,
371 which contains a list of relative paths that the boot scripts should remove
372 from the memory file systems.
373 .Pp
374 As a minimum, you normally need to have the following in
375 .Pa /conf/default/etc/fstab
376 .Bd -literal -offset indent
377 <SERVER>:<ROOT> /     nfs    ro 0 0
378 <SERVER>:/usr   /usr  nfs    ro 0 0
379 .Ed
380 .Pp
381 You also need to create a customized version of
382 .Pa /conf/default/etc/rc.conf
383 which should contain
384 the startup options for the
385 .Nm
386 client, and
387 .Pa /conf/default/etc/rc.local
388 which could be empty but prevents the server's own
389 .Pa /etc/rc.local
390 from leaking onto the
391 .Nm
392 system.
393 .Pp
394 In
395 .Pa rc.conf ,
396 most likely
397 you will not need to set
398 .Va hostname
399 and
400 .Va ifconfig_*
401 because these will be already set by the startup code.
402 Finally, it might be convenient to use a
403 .Ic case
404 statement using
405 .Li `hostname`
406 as the switch variable to do machine-specific configuration
407 in case a number of
408 .Nm
409 clients share the same configuration
410 files.
411 .It
412 The kernel for the
413 .Nm
414 clients, which will be loaded using
415 .Tn NFS
416 or
417 .Tn TFTP ,
418 must include support for the NFS client:
419 .Pp
420 .D1 Cd "options NFSCL"
421 .D1 Cd "options NFS_ROOT"
422 .Pp
423 If you are using a boot mechanism that does not pass network configuration
424 to the kernel using the kernel environment, you will also need to include
425 the following options:
426 .Pp
427 .D1 Cd "options BOOTP"
428 .D1 Cd "options BOOTP_NFSROOT"
429 .D1 Cd "options BOOTP_COMPAT"
430 .Pp
431 .Em Note :
432 the PXE environment does not require these options.
433 .Pp
434 The
435 .Nm
436 booting environment relies on memory-backed file systems to
437 support temporary local storage in the event that the root file system
438 is mounted read-only; as such, it is necessary to add the following
439 to the device section of the kernel configuration:
440 .Pp
441 .D1 Cd "device md"
442 .Pp
443 If you use the firewall, remember to default to
444 .Dq open ,
445 or your kernel
446 will not be able to send/receive the
447 .Tn BOOTP
448 packets.
449 .El
450 .Sh SECURITY ISSUES
451 Be warned that using unencrypted
452 .Tn NFS
453 to mount root and user
454 partitions may expose information such as
455 encryption keys.
456 .Sh SEE ALSO
457 .Xr ethers 5 ,
458 .Xr exports 5 ,
459 .Xr make.conf 5 ,
460 .Xr bootpd 8 ,
461 .Xr mountd 8 ,
462 .Xr nfsd 8 ,
463 .Xr pxeboot 8 ,
464 .Xr reboot 8 ,
465 .Xr tftpd 8
466 .Pp
467 .Pa ports/net/etherboot
468 .Sh BUGS
469 This manpage is probably incomplete.
470 .Pp
471 .Fx
472 sometimes requires to write onto
473 the root partition, so the startup scripts mount MFS
474 file systems on some locations (e.g.\&
475 .Pa /etc
476 and
477 .Pa /var ) ,
478 while
479 trying to preserve the original content.
480 The process might not handle all cases.