loader(8): adjustment & man update
[dragonfly.git] / sys / boot / common / loader.8
1 .\" Copyright (c) 1999 Daniel C. Sobral
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD: src/sys/boot/common/loader.8,v 1.57 2003/06/29 20:57:55 brueffer Exp $
26 .\"
27 .\" Note: The date here should be updated whenever a non-trivial
28 .\" change is made to the manual page.
29 .Dd October 6, 2010
30 .Dt LOADER 8
31 .Os
32 .Sh NAME
33 .Nm loader
34 .Nd kernel bootstrapping final stage
35 .Sh DESCRIPTION
36 The program called
37 .Nm
38 is the final stage of
39 .Dx Ns 's
40 kernel bootstrapping process.
41 It is implemented as a
42 .Tn BTX
43 client and
44 is linked statically to
45 .Xr libstand 3
46 and located in the
47 .Pa /boot
48 or
49 .Pa /
50 directory.
51 .Pp
52 If a
53 .Pa /boot
54 directory exist on the boot file system, then
55 .Dq /boot/
56 is prepended to all relative file names used by
57 .Nm .
58 This makes it possible to locate all files used by
59 .Nm
60 in either
61 .Pa /
62 or
63 .Pa /boot
64 directory on the boot file system.
65 If boot and root are the same file system, then files used by
66 .Nm
67 are located in
68 .Pa /boot .
69 If boot and root are different file systems, then files used by
70 .Nm
71 are located in
72 .Pa /
73 on the boot file system, which is mounted as
74 .Pa /boot
75 on the root file system when the kernel is running.
76 .Pp
77 During initialization,
78 .Nm
79 will probe for a console and set the
80 .Va console
81 variable, or set it to serial console
82 .Pq Dq comconsole
83 if the previous boot stage used that.
84 Then, devices are probed,
85 .Va currdev
86 and
87 .Va loaddev
88 are set, and
89 .Va LINES
90 is set to 24.
91 After that,
92 .Pa dloader.rc
93 is processed if available, and, failing that,
94 .Pa boot.conf
95 is read for historical reasons.
96 These files are processed through the
97 .Ic include
98 command, which reads all of them into memory before processing them,
99 making disk changes possible.
100 .Pp
101 At this point, if an
102 .Ic autoboot
103 has not been tried, and if
104 .Va autoboot_delay
105 is not set to
106 .Dq NO
107 (not case sensitive), then an
108 .Ic autoboot
109 will be tried.
110 If the system gets past this point,
111 .Va prompt
112 will be set and
113 .Nm
114 will engage interactive mode.
115 .Sh BUILTIN COMMANDS
116 In
117 .Nm ,
118 builtin commands take parameters from the command line.
119 .Pp
120 The builtin commands available are:
121 .Pp
122 .Bl -tag -width indent -compact
123 .It Ar variable Ns = Ns Ar value
124 Assign
125 .Ar value
126 to
127 .Ar variable .
128 Value is always assigned to local variable
129 .Ar variable .
130 If
131 .Ar variable
132 is in list of known kernel environment variables or
133 is a kernel tunable,
134 it is also assigned to the kernel environment variable of the given name.
135 .Ar variable
136 is unset if
137 .Ar value ,
138 is empty.
139 .Pp
140 In other words,
141 the assignment described above, will assign to a local variable and
142 if it seems applicable, also snoop assignment to kernel environment variable.
143 See also
144 .Sx ENVIRONMENT VARIABLES AND LOCAL VARIABLES .
145 .Pp
146 .It Ic autoboot Op Ar delay Op Ar prompt
147 Proceeds to bootstrap the system after a number of seconds, if not
148 interrupted by the user.
149 Displays a countdown prompt
150 warning the user the system is about to be booted,
151 unless interrupted by a key press.
152 The kernel will be loaded first if necessary.
153 Defaults to 10 seconds.
154 .Pp
155 .It Ic bcachestat
156 Displays statistics about disk cache usage.
157 For depuration only.
158 .Pp
159 .It Ic boot Oo Fl Ns Ar flag ... Oc Op Ar kernelname
160 Immediately proceeds to bootstrap the system, loading the kernel
161 if necessary.
162 Any flags or arguments are passed to the kernel, but they
163 must precede the kernel name, if a kernel name is provided.
164 Flags are described in
165 .Xr boot 8 .
166 .Pp
167 .It Ic cd Op Ar directory
168 Change working directory to
169 .Ar directory .
170 Default is $base.
171 .Pp
172 .It Ic echo Oo Fl n Oc Op Ar message
173 Displays text on the screen.
174 A new line will be printed unless
175 .Fl n
176 is specified.
177 .Pp
178 .It Ic heap
179 Displays memory usage statistics.
180 For debugging purposes only.
181 .Pp
182 .It Ic help Op Ar topic Op Ar subtopic
183 Shows help messages read from
184 .Pa loader.help .
185 The special
186 .Ar topic
187 .Cm index
188 will list all topics available.
189 .Pp
190 .It Ic include Ar
191 Process script files.
192 Each file, in turn, is completely read into memory,
193 and then each of its lines is passed to the command line interpreter.
194 If any error is returned by the interpreter, the include
195 command aborts immediately, without reading any other files, and
196 returns an error itself.
197 .Pp
198 .It Ic load Oo Fl t Ar type Oc Ar file Op Ar argument ...
199 Loads a kernel, kernel loadable module (kld), or file of opaque
200 contents tagged as being of the type
201 .Ar type .
202 Kernel and modules can be either in a.out or
203 .Tn ELF
204 format.
205 Any arguments passed after the name of the file to be loaded
206 will be passed as arguments to that file.
207 Currently, argument passing does not work for the kernel.
208 .Pp
209 .It Ic loadall
210 Load kernel and all modules specified by MODULE_load variables.
211 .Pp
212 .It Ic local Op Ar local_variable ...
213 Displays the specified variable's value, or all local variables and their
214 values if
215 .Ar local_variable
216 is not specified.
217 .Pp
218 .It Ic ls Oo Fl l Oc Op Ar path
219 Displays a listing of files in the directory
220 .Ar path ,
221 or the root directory if
222 .Ar path
223 is not specified.
224 If
225 .Fl l
226 is specified, file sizes will be shown too.
227 .Pp
228 .It Ic lsdev Op Fl v
229 Lists all devices.
230 A
231 .Sq *
232 prefix indicates a disk slice or partition from which it may be
233 possible to load modules.
234 If
235 .Fl v
236 is specified, more details,
237 like disk slice or partition size and position, are printed.
238 .Pp
239 .It Ic lsmod Op Fl v
240 Displays loaded modules.
241 If
242 .Fl v
243 is specified, more details are shown.
244 .Pp
245 .It Ic lunset Ar local_variable
246 Unset local variable: discard value and remove variable.
247 .Pp
248 .It Ic lunsetif Ar local_variable env_variable
249 Unset
250 .Ar local_variable
251 if
252 .Ar env_variable
253 is true, i.e.\& set to 1 or
254 .Ql YES .
255 .Pp
256 .It Ic menu
257 Run menu system.
258 .Pp
259 .It Ic menuadd Ar command_line
260 Add script line for current menu bullet.
261 .Pp
262 .It Ic menuclear
263 Clear all menu bullets.
264 .Pp
265 .It Ic menuitem Ar key description
266 Start new menu bullet.
267 When running menu system, a line with
268 .Ar key
269 and
270 .Ar description
271 is displayed, and bullet is choosen by pressing
272 .Ar key .
273 .Pp
274 .It Ic more Ar
275 Display the files specified, with a pause at each
276 .Va LINES
277 displayed.
278 .Pp
279 .It Ic optcd Op Ar directory
280 Change working directory to
281 .Ar directory .
282 Default is $base.
283 Ignore errors.
284 This command is like
285 .Ic cd ,
286 but ignores errors while changing directory.
287 .Pp
288 .It Ic optinclude Ar
289 Process script files.
290 Ignore errors.
291 This command is like
292 .Ic include ,
293 but ignores errors while executing commands in included files.
294 .Pp
295 .It Ic pnpscan Op Fl v
296 Scans for Plug-and-Play devices.
297 This is not functional at present.
298 .Pp
299 .It Ic pwd
300 Show working directory.
301 .Pp
302 .It Ic read Oo Fl t Ar seconds Oc Oo Fl p Ar prompt Oc Op Ar env_variable
303 Reads a line of input from the terminal, storing it in
304 .Ar env_variable
305 if specified.
306 A timeout can be specified with
307 .Fl t ,
308 though it will be canceled at the first key pressed.
309 A prompt may also be displayed through the
310 .Fl p
311 flag.
312 .Pp
313 .It Ic reboot
314 Immediately reboots the system.
315 .Pp
316 .It Ic set Ar env_variable
317 .It Ic set Ar env_variable Ns = Ns Ar value
318 Set
319 .Nm Ns 's
320 environment variables.
321 .Pp
322 .It Ic show Op Ar env_variable
323 Displays the specified kernel environment variable's value,
324 or all variables and their values if
325 .Ar env_variable
326 is not specified.
327 .Pp
328 .It Ic unload
329 Remove all modules from memory.
330 .Pp
331 .It Ic unset Ar env_variable
332 Removes
333 .Ar env_variable
334 from the environment.
335 .Pp
336 .It Ic \&?
337 List most available commands with short help.
338 .El
339 .Ss ENVIRONMENT VARIABLES AND LOCAL VARIABLES
340 The
341 .Nm
342 has actually two different kinds of variables.
343 There are
344 kernel environment variables, which is visible to the kernel when it is run,
345 and a separate space of local variables used by
346 .Nm ,
347 which are not available to the kernel.
348 .Pp
349 Environment variables can be set and unset through the
350 .Ic set
351 and
352 .Ic unset
353 builtins, and can have their values interactively examined through the
354 use of the
355 .Ic show
356 builtin.
357 .Pp
358 Notice that these environment variables are not inherited by any shell
359 after the system has been booted, but can be examined by
360 .Xr kenv 1 .
361 .Pp
362 A few variables are set automatically by
363 .Nm .
364 Others can affect the behavior of either
365 .Nm
366 or the kernel at boot.
367 Some options may require a value,
368 while others define behavior just by being set.
369 Both types of variables are described below.
370 .Bl -tag -width indent
371 .It Va acpi_load
372 Unset this to disable automatic loading of the ACPI module.
373 .It Va autoboot_delay
374 Number of seconds
375 .Ic autoboot
376 will wait before booting.
377 If this variable is not defined,
378 .Ic autoboot
379 will default to 10 seconds.
380 .Pp
381 If set to
382 .Dq NO ,
383 no
384 .Ic autoboot
385 will be automatically attempted after processing
386 .Pa dloader.rc ,
387 though explicit
388 .Ic autoboot Ns 's
389 will be processed normally, defaulting to 10 seconds delay.
390 .It Va boot_askname
391 Instructs the kernel to prompt the user for the name of the root device
392 when the kernel is booted.
393 .It Va boot_ddb
394 Instructs the kernel to start in the DDB debugger, rather than
395 proceeding to initialize when booted.
396 .It Va boot_gdb
397 Selects gdb-remote mode for the kernel debugger by default.
398 .It Va boot_single
399 Prevents the kernel from initiating a multi-user startup; instead single-user
400 mode will be entered when the kernel has finished device probing.
401 .It Va boot_userconfig
402 Requests that the kernel's interactive device configuration program
403 be run when the kernel is booted.
404 .It Va boot_verbose
405 Setting this variable causes extra debugging information to be printed
406 by the kernel especially during the boot phase.
407 .It Va bootfile
408 List of semicolon-separated search path for bootable kernels.
409 The default is
410 .Dq Li kernel;kernel.old .
411 .It Va console
412 Defines the current console.
413 .It Va currdev
414 Selects the default device.
415 Syntax for devices is odd.
416 .It Va ehci_load
417 Unset this to disable automatic loading of the EHCI module.
418 .It Va init_path
419 Sets the list of binaries which the kernel will try to run as the initial
420 process.
421 The first matching binary is used.
422 The default list is
423 .Dq Li /sbin/init:/sbin/oinit:/sbin/init.bak .
424 .It Va LINES
425 Define the number of lines on the screen, to be used by the pager.
426 .It Va module_path
427 Sets the list of directories which will be searched for modules named in a
428 .Nm load
429 command or implicitly required by a dependency.
430 The default value for this variable is
431 .Dq Li ;modules ,
432 which first searches the current working directory and then
433 .Pa modules .
434 .It Va num_ide_disks
435 Sets the number of IDE disks as a workaround for some problems in
436 finding the root disk at boot.
437 This has been deprecated in favor of
438 .Va root_disk_unit .
439 .It Va prompt
440 Value of
441 .Nm Ns 's
442 prompt.
443 Defaults to
444 .Dq Li OK .
445 .It Va root_disk_unit
446 If the code which detects the disk unit number for the root disk is
447 confused, e.g.\& by a mix of
448 .Tn SCSI
449 and
450 .Tn IDE
451 disks, or
452 .Tn IDE
453 disks with
454 gaps in the sequence (e.g.\& no primary slave), the unit number can
455 be forced by setting this variable.
456 .It Va rootdev
457 By default the value of
458 .Va currdev
459 is used to set the root file system
460 when the kernel is booted.
461 This can be overridden by setting
462 .Va rootdev
463 explicitly.
464 .It Va dumpdev
465 The name of a device where the kernel can save a crash dump in case
466 of a panic.
467 This automatically sets the
468 .Va kern.dumpdev
469 .Xr sysctl 3
470 .Tn MIB
471 variable.
472 .El
473 .Pp
474 Other variables are used to override kernel tunable parameters.
475 The following
476 .Nm
477 tunables are available:
478 .Bl -tag -width indent
479 .It Va hw.irq.X.dest
480 Set irqX's destination to the given
481 .Tn CPUID ,
482 which starts from 0.
483 If the specified value is larger than the last
484 .Tn CPUID ,
485 then the first CPUID will be used.
486 This variable should not be used if
487 .Tn IO/APIC
488 support is not compiled into kernel.
489 .It Va hw.physmem
490 Limit the amount of physical memory the system will use.
491 By default the size is in bytes, but the
492 .Cm k , K , m , M , g
493 and
494 .Cm G
495 suffixes
496 are also accepted and indicate kilobytes, megabytes and gigabytes
497 respectively.
498 An invalid suffix will result in the variable being ignored by the
499 kernel.
500 .It Va hw.usb.hack_defer_exploration
501 The USB keyboard will sometimes not attach properly unless you set this
502 variable to 0.
503 .It Va kern.emergency_intr_enable
504 Setting this to 1 enables emergency interrupt polling.
505 All interrupt
506 handlers are executed periodically.
507 This mode is very expensive and should
508 only be used to get a system accessible when interrupt routing is
509 otherwise broken.
510 It is primarily used by kernel developers to debug new systems.
511 .It Va kern.emergency_intr_freq
512 Set the polling rate for the emergency interrupt polling code.
513 The default is 10 (hz) to dissuade casual use.
514 If you are doing real work
515 with emergency interrupt polling mode enabled, it is recommended
516 that you use a frequency between 100hz and 300hz.
517 .It Va kern.maxusers
518 Set the size of a number of statically allocated system tables; see
519 .Xr tuning 7
520 for a description of how to select an appropriate value for this tunable.
521 When set, this tunable replaces the value declared in the kernel
522 compile-time configuration file.
523 .It Va kern.ipc.nmbclusters
524 Set the number of mbuf clusters to be allocated.
525 The value cannot be set below the default
526 determined when the kernel was compiled.
527 Modifies
528 .Va NMBCLUSTERS .
529 .It Va kern.mmxopt
530 Toggles the mmx optimizations for the bcopy/copyin/copyout routines
531 .It Va kern.vm.kmem.size
532 Sets the size of kernel memory (bytes).
533 This overrides the value determined when the kernel was compiled.
534 .It Va kern.maxswzone
535 Limits the amount of
536 .Tn KVM
537 to be used to hold swap
538 meta information, which directly governs the
539 maximum amount of swap the system can support.
540 This value is specified in bytes of KVA space
541 and defaults to around 70MBytes.
542 Care should be taken
543 to not reduce this value such that the actual
544 amount of configured swap exceeds \(12 the
545 kernel-supported swap.
546 The default 70MB allows
547 the kernel to support a maximum of (approximately)
548 14GB of configured swap.
549 Only mess around with
550 this parameter if you need to greatly extend the
551 .Tn KVM
552 reservation for other resources such as the
553 buffer cache or
554 .Va NMBCLUSTERS .
555 Modifies
556 .Va VM_SWZONE_SIZE_MAX .
557 .It Va kern.maxbcache
558 Limits the amount of KVM reserved for use by the
559 buffer cache, specified in bytes.
560 The default maximum is 200MB.
561 This parameter is used to
562 prevent the buffer cache from eating too much
563 .Tn KVM
564 in large-memory machine configurations.
565 Only mess around with this parameter if you need to
566 greatly extend the
567 .Tn KVM
568 reservation for other resources
569 such as the swap zone or
570 .Va NMBCLUSTERS .
571 Note that
572 the NBUF parameter will override this limit.
573 Modifies
574 .Va VM_BCACHE_SIZE_MAX .
575 .It Va machdep.disable_mtrrs
576 Disable the use of
577 .Sy i686
578 .Tn MTRRs
579 (x86 only).
580 .It Va net.inet.tcp.tcbhashsize
581 Overrides the compile-time set value of
582 .Va TCBHASHSIZE
583 or the preset default of 512.
584 Must be a power of 2.
585 .It Va vfs.root.mountfrom
586 Specify root file system.
587 A semicolon separated list of file systems to try
588 as the kernel root file system.
589 File system format is file system type and disk store,
590 separated by colon.
591 This variable needs to be set when using boot-only partition, which is
592 typically mounted on root file system as
593 .Pa /boot .
594 .Pp
595 One file system example:
596 .Dl hammer:da8s1a
597 .Pp
598 One file system
599 .Nm HAMMER
600 multi volume example:
601 .Dl hammer:da8s1a:da9s1a
602 .Pp
603 Several file systems, boot list, example:
604 .Dl ufs:da0s1a;hammer:ad1s1d
605 .Pp
606 Each file system in the list will be tried in the order specified
607 until the mount succeeds.
608 If all fail, the
609 .Ql mountroot>
610 prompt is displayed for manual entry.
611 .Pp
612 You may not specify devtab labels here but you can specify paths available to
613 .Nm devfs
614 such as:
615 .Dl hammer:serno/L41JYE0G.s1d
616 .El
617 .Sh FILES
618 .Bl -tag -width /boot/defaults/dloader.menu -compact
619 .It Pa /boot/boot.conf
620 .Nm
621 bootstrapping script.
622 Deprecated.
623 .It Pa /boot/loader
624 .Nm
625 itself.
626 .It Pa /boot/defaults/dloader.menu
627 .Nm
628 menu setup commands -- do not change this file.
629 .It Pa /boot/defaults/loader.conf
630 .Nm
631 configuration file, see
632 .Xr loader.conf 5
633 -- do not change this file.
634 .It Pa /boot/dloader.menu
635 .Nm
636 menu setup commands.
637 .It Pa /boot/dloader.rc
638 .Nm
639 bootstrapping script.
640 .It Pa /boot/loader.conf
641 .It Pa /boot/loader.conf.local
642 .Nm
643 configuration files, see
644 .Xr loader.conf 5 .
645 .It Pa /boot/loader.help
646 help messages, used by
647 .Ic help
648 command.
649 .El
650 .Sh EXAMPLES
651 Boot in single user mode:
652 .Pp
653 .Dl loadall
654 .Dl boot -s
655 .Pp
656 Load kernel's user configuration file.
657 Notice that a kernel must be loaded before any other
658 .Ic load
659 command is attempted.
660 .Bd -literal -offset indent
661 load kernel
662 load -t userconfig_script kernel.conf
663 .Ed
664 .Pp
665 Load the kernel, a splash screen, and then autoboot in five seconds.
666 .Bd -literal -offset indent
667 load kernel
668 load splash_bmp
669 load -t splash_image_data chuckrulez.bmp
670 autoboot 5
671 .Ed
672 .Pp
673 Set the disk unit of the root device to 2, and then boot.
674 This would be needed in a system with two IDE disks,
675 with the second IDE disk hardwired to
676 .Pa ad2
677 instead of
678 .Pa ad1 .
679 .Bd -literal -offset indent
680 set root_disk_unit=2
681 boot kernel
682 .Ed
683 .Sh SEE ALSO
684 .Xr libstand 3 ,
685 .Xr loader.conf 5 ,
686 .Xr tuning 7 ,
687 .Xr boot 8 ,
688 .Xr btxld 8 ,
689 .Xr pxeboot 8 ,
690 .Xr pxeboot_tftp 8 ,
691 .Xr sysctl 8
692 .Sh HISTORY
693 The
694 .Nm
695 first appeared in
696 .Fx 3.1 .
697 dloader was introduced and
698 .Tn FORTH
699 removed in
700 .Dx 2.7 .
701 .Sh AUTHORS
702 .An -nosplit
703 The
704 .Nm
705 was written by
706 .An Michael Smith Aq msmith@FreeBSD.org .
707 .Pp
708 dloader was written by
709 .An Matthew Dillon Aq dillon@backplane.com .