xref: /openbsd/usr.sbin/config/config.8 (revision a6445c1d)
1.\"	$OpenBSD: config.8,v 1.60 2014/01/20 01:11:49 schwarze Exp $
2.\"	$NetBSD: config.8,v 1.10 1996/08/31 20:58:16 mycroft Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     from: @(#)config.8	8.2 (Berkeley) 4/19/94
32.\"
33.Dd $Mdocdate: January 20 2014 $
34.Dt CONFIG 8
35.Os
36.Sh NAME
37.Nm config
38.Nd build kernel compilation directories or modify a kernel
39.Sh SYNOPSIS
40.Nm config
41.Op Fl p
42.Op Fl b Ar builddir
43.Op Fl s Ar srcdir
44.Op Ar config-file
45.Nm config
46.Op Fl u
47.Op Fl f | o Ar outfile
48.Fl e
49.Ar infile
50.Sh DESCRIPTION
51In the first synopsis form, the
52.Nm
53program creates a kernel build directory from the kernel configuration file
54specified by
55.Ar config-file .
56.Pp
57In the second synopsis form,
58.Nm
59allows editing of the kernel binary specified by
60.Ar infile .
61Devices may be enabled, disabled, or modified without recompiling,
62by editing the kernel executable.
63Similarly, the same editing can be done at boot-time,
64using the in-kernel editor,
65as described in
66.Xr boot_config 8 .
67.Pp
68For kernel building, the options are as follows:
69.Bl -tag -width Ds
70.It Fl b Ar builddir
71Create the build directory in the path specified by
72.Ar builddir
73instead of the default
74.Pa ../compile/SYSTEMNAME .
75.It Fl p
76Configure for a system that includes profiling code; see
77.Xr kgmon 8
78and
79.Xr gprof 1 .
80When this option is specified,
81.Nm
82acts as if the lines
83.Dq makeoptions PROF="-pg"
84and
85.Dq option GPROF
86appeared in the specified kernel configuration file.
87In addition,
88.Dq .PROF
89is appended to the default compilation directory name.
90.Pp
91The
92.Fl p
93flag is expected to be used for
94.Dq one-shot
95profiles of existing systems; for regular profiling, it is probably wiser to
96make a separate configuration containing the makeoptions line.
97.It Fl s Ar srcdir
98Use
99.Ar srcdir
100as the top-level kernel source directory instead of the default (four
101directories above the build directory).
102.El
103.Pp
104For kernel modification, the options are as follows:
105.Bl -tag -width Ds
106.It Fl e
107Allows the modification of kernel device configuration (see
108.Xr boot_config 8 ) .
109Temporary changes can be made to the running kernel's configuration or a new
110kernel binary may be written for permanent changes between system reboots.
111See the section
112.Sx KERNEL MODIFICATION
113below for more details.
114.It Fl f
115Overwrite the
116.Ar infile
117kernel binary with the modified kernel.
118Otherwise,
119.Fl o
120should be given to specify an alternate output file.
121.It Fl o Ar outfile
122Write the modified kernel to
123.Ar outfile .
124.It Fl u
125Check to see if the kernel configuration was modified at boot-time
126(i.e.\&
127.Cm boot -c
128was used).
129If so, compare the running kernel with the kernel to be edited
130.Pq Ar infile .
131If they seem to be the same, apply all configuration changes performed at
132boot.
133.El
134.Sh KERNEL BUILDING
135The output of
136.Nm
137consists of a number of files, principally
138.Pa ioconf.c
139(a description of I/O devices that may be attached to the system)
140and a
141.Pa Makefile ,
142used by
143.Xr make 1
144when building the kernel.
145.Pp
146If
147.Nm
148stops due to errors, the problems reported should be corrected and
149.Nm
150should be run again.
151.Nm
152attempts to avoid changing the compilation directory if there are
153configuration errors, but this code is not well-tested and some problems
154(such as running out of disk space) are unrecoverable.
155.Pp
156If
157.Ar config-file
158is not specified,
159.Nm
160uses the current directory as the build directory, and looks in it for
161a file called
162.Pa CONFIG .
163If
164.Nm
165is run this way, the location of the top-level kernel source
166directory must be specified using the
167.Fl s
168option or by using the
169.Dq Li source
170directive at the beginning of the system configuration file.
171.Pp
172The configuration files consists of various statements which
173include the following:
174.Bl -tag -offset indent -width indent
175.It Ic machine Ar var
176Required.
177Specifies the machine architecture.
178.It Ic include Ar file
179Include another configuration file.
180.It Ic option Ar name
181Set a kernel option.
182Kernel options may take either the form
183.Ar NAME
184or the form
185.Ar NAME Ns = Ns Ar value .
186These options are passed to the compiler with the
187.Fl D
188flag.
189.It Ic rmoption Ar name
190Delete a previously set option.
191This is useful when including another kernel configuration file.
192A typical use is to include the
193.Va GENERIC
194kernel provided with each release and remove options that are
195unwanted, thus allowing for automatic inclusion of new device
196drivers.
197.It Ic maxusers Ar number
198Required.
199Used to size various system tables and maximum operating conditions
200in an approximate fashion.
201Multiple instances of this keyword may be specified.
202The number provided in the last instance will be used, and
203warnings will be printed for each duplicate value.
204This is convenient when used with the
205.Va include
206directive.
207.It Xo Ic config Cm bsd root on Ar dev
208.Op Cm swap on Ar dev Op Cm and Ar dev ...
209.Op Cm dumps on Ar dev Op Cm and Ar dev ...
210.Xc
211Required.
212Specifies the swap and dump devices which the system should use.
213.It Ic config Cm bsd swap generic
214Otherwise, if generic is specified, the system follows generic routines to
215decide what should happen.
216.El
217.Pp
218To debug kernels and their crash dumps with gdb, add
219.Dq makeoptions DEBUG="-g"
220to the kernel configuration file, along with (typically)
221.Dq option KGDB .
222Refer to
223.Xr options 4
224for further details.
225.Pp
226Many other statements exist, and the file format is fairly rich; for more
227information see the various configuration files included in the system, as
228well as
229.Xr files.conf 5
230for the
231.Nm
232rules base.
233.Sh KERNEL MODIFICATION
234When
235.Fl e
236is specified, device parameters that are normally hard-coded into the kernel
237may be changed.
238This is useful to avoid the need for kernel recompilation or rebooting.
239Modifications are made to the currently running kernel and can be written to
240a new kernel binary so changes are preserved during subsequent system restarts.
241.Pp
242When invoked, the kernel identification is first shown.
243.Bd -literal -offset indent
244# config -e -o bsd.new /bsd
245OpenBSD 5.3-current (GENERIC.MP) #91: Mon Mar 25 16:43:17 MDT 2013
246    deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
247Enter 'help' for information
248ukc\*(Gt
249.Ed
250.Pp
251One or more warnings may be printed before the
252.Li ukc\*(Gt
253prompt.
254.Bd -literal -offset indent
255warning: no output file specified
256.Ed
257.Pp
258Neither the
259.Fl f
260nor
261.Fl o
262option has been specified.
263Changes will be ignored.
264.Bd -literal -offset indent
265WARNING kernel mismatch. -u ignored.
266WARNING the running kernel version:
267.Ed
268.Pp
269.Nm
270does not believe the running kernel is the same as the
271.Ar infile
272specified.
273Since the log of changes (from
274.Cm boot -c )
275in the running kernel is kernel-specific, the
276.Fl u
277option is ignored.
278.Pp
279The commands are as follows:
280.Bl -tag -width "disable attr val | devno | dev"
281.It Ic add Ar dev
282Add a device through copying another.
283.It Ic base Cm 8 | 10 | 16
284Change the base of numbers displayed and entered,
285e.g. I/O addresses in a VAXen are octal.
286.It Ic bufcachepercent Op Ar number
287Change the BUFCACHEPERCENT value.
288Without arguments, displays its current value.
289.It Ic change Ar devno | dev
290Modify one or more devices.
291.It Ic disable Ar attr val | devno | dev
292Disable one or more devices.
293.It Ic enable Ar attr val | devno | dev
294Enable one or more devices.
295.It Ic exit
296Exit without saving changes.
297.It Ic find Ar devno | dev
298Find one or more devices.
299.It Ic help
300Give a short summary of all commands and their arguments.
301.It Ic lines Op Ar count
302Set the number of rows per page.
303.It Ic list
304Show all known devices, a screen at a time.
305.It Ic nkmempg Op Ar number
306Change the NKMEMPAGES value.
307Without arguments, displays its current value.
308.It Ic quit
309Exit and save changes.
310.It Ic show Op Ar attr Op Ar val
311Show all devices for which attribute
312.Ar attr
313has the value
314.Ar val .
315.It Ic timezone Op Ar minuteswest Op Ar dst
316Change the
317.Va tz
318timezone structure.
319.Va minuteswest
320is the number of minutes west of GMT and
321.Va dst
322is non-zero if Daylight Saving Time is in effect.
323Without arguments, displays its current value.
324.El
325.Sh EXAMPLES (kernel building)
326Note:
327The standard
328.Ox
329kernel configuration
330(GENERIC or GENERIC.MP)
331is suitable for most purposes.
332Use of an alternative kernel configuration is not recommended.
333A custom kernel is built in the following way.
334.Pp
335To compile a kernel from a non-writable media (such as a CD-ROM)
336mounted on
337.Pa /usr/src ,
338do the following:
339.Bd -literal -offset indent
340# cd /somedir
341# cp /usr/src/sys/arch/somearch/conf/SOMEFILE .
342# vi SOMEFILE	(to make any changes)
343# config -s /usr/src/sys -b . SOMEFILE
344# make
345.Ed
346.Pp
347To compile a kernel inside a writable source tree, do the following:
348.Bd -literal -offset indent
349# cd /usr/src/sys/arch/somearch/conf
350# vi SOMEFILE	(to make any changes)
351# config SOMEFILE
352# cd ../compile/SOMEFILE
353# make
354.Ed
355.Pp
356In the examples above,
357.Ar somedir
358is a writable directory,
359.Ar somearch
360is the architecture (e.g. i386),
361and
362.Ar SOMEFILE
363should be a name indicative of a particular configuration (often
364that of the hostname).
365.Nm config
366will warn if a
367.Dq make clean
368is required.
369.Pp
370The new kernel, called
371.Pa bsd ,
372can be copied to
373.Pa /bsd
374and the system will boot it next time.
375Most people save their backup kernels as
376.Pa /bsd.1 ,
377.Pa /bsd.2 ,
378etc.
379.Sh EXAMPLES (kernel modification)
380The Ethernet card is not detected at boot because the kernel configuration
381does not match the physical hardware configuration,
382e.g. wrong IRQ in OpenBSD/i386.
383The Ethernet card is supposed to use the
384.Xr ne 4
385driver.
386.Bd -literal
387.No ukc\*(Gt Ic find ne
38824 ne0 at isa0 port 0x240 size 0 iomem 0xd8000 iosiz 0 irq 9 drq -1 drq2 -1 flags 0x0
38925 ne1 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 10 drq -1 drq2 -1 flags 0x0
39026 ne* at isapnp0 port -1 size 0 iomem -1 iosiz 0 irq -1 drq -1 flags 0x0
39127 ne* at pci* dev -1 function -1 flags 0x0
39228 ne* at pcmcia* function -1 irq -1 flags 0x0
393ukc\*(Gt
394.Ed
395.Pp
396ne1 seems to match the configuration except it uses IRQ 10 instead of IRQ 5.
397So the irq on ne1 should be changed via the
398.Ic change
399command.
400The device can be specified by either name or number.
401.Bd -literal
402.No ukc\*(Gt Ic change ne1
40325 ne1 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 10 drq -1 drq2 -1
404.No change (y/n) \&? Ic y
405.No port [0x300] \&?
406.No size [0] \&?
407.No iomem [-1] \&?
408.No iosiz [0] \&?
409.No irq [10] \&? Ic 5
410.No drq [-1] \&?
411.No drq2 [-1] \&?
412.No flags [0] \&?
41325 ne1 changed
41425 ne1 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 5 drq -1 drq2 -1 flags 0x0
415ukc\*(Gt
416.Ed
417.Pp
418It's also possible to disable all devices with a common attribute.
419For example:
420.Bd -literal
421.No ukc\*(Gt Ic disable port 0x300
422 25 ne1 disabled
423 72 we1 disabled
424 75 el0 disabled
425 77 ie1 disabled
426.Ed
427.Pp
428The
429.Cm show
430command is useful for finding which devices have a certain attribute.
431It can also be used to find those devices with a particular value for
432an attribute.
433.Bd -literal
434.No ukc\*(Gt Ic show slot
435  2 ahc* at eisa0 slot -1
436 10 uha* at eisa0 slot -1
437 12 ep0 at eisa0 slot -1
438 17 ep* at eisa0 slot -1
439102 ahb* at eisa0 slot -1
440103 fea* at eisa0 slot -1
441.No ukc\*(Gt Ic show port 0x300
442 25 ne1 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 10 drq -1 drq2 -1 flags 0x0
443 72 we1 at isa0 port 0x300 size 0 iomem 0xcc000 iosiz 0 irq 10 drq -1 drq2 -1 flags 0x0
444 75 el0 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 9 drq -1 drq2 -1 flags 0x0
445 77 ie1 at isa0 port 0x300 size 0 iomem -1 iosiz 0 irq 10 drq -1 drq2 -1 flags 0x0
446ukc\*(Gt
447.Ed
448.Pp
449It is possible to add new devices, but only devices that were linked into the
450kernel.
451If a new device is added, following devices will be renumbered.
452.Bd -literal
453.No ukc\*(Gt Ic find ep
454 11 ep0 at isa0 port -1 size 0 iomem -1 iosiz 0 irq -1 drq -1 drq2 -1 flags 0x0
455 12 ep0 at eisa0 slot -1 flags 0x0
456 13 ep0 at pci* dev -1 function -1 flags 0x0
457 14 ep* at isapnp0 port -1 size 0 iomem -1 iosiz 0 irq -1 drq -1 flags 0x0
458 15 ep* at isa0 port -1 size 0 iomem -1 iosiz 0 irq -1 drq -1 drq2 -1 flags 0x0
459 16 ep* at eisa0 slot -1 flags 0x0
460 17 ep* at pci* dev -1 function -1 flags 0x0
461 18 ep* at pcmcia* dev -1 irq -1 flags 0x0
462.No ukc\*(Gt Ic add ep1
463.No "Clone Device (DevNo, 'q' or '\&?') \&?" Ic 13
464.No "Insert before Device (DevNo, 'q' or '\&?')" Ic 14
465 14 ep1 at pci* dev -1 function -1
466.No ukc\*(Gt Ic change 14
467 14 ep1 at pci* dev -1 function -1
468.No change (y/n) \&? Ic y
469.No dev [-1] \&? Ic 14
470.No function [-1] \&?
471.No flags [0] \&? Ic 18
472 14 ep1 changed
473 14 ep1 at pci* dev 14 function -1 flags 0x12
474ukc\*(Gt
475.Ed
476.Pp
477When done, exit the program with the
478.Ic quit
479or
480.Ic exit
481commands.
482.Ic exit
483will ignore any changes while
484.Ic quit
485writes the changes to
486.Ar outfile
487(if
488.Fl o
489or
490.Fl f
491was given, else ignore changes).
492.Bd -literal
493.No ukc\*(Gt Ic quit
494.Ed
495.Sh SEE ALSO
496.Xr options 4 ,
497.Xr boot.conf 5 ,
498.Xr files.conf 5 ,
499.Xr boot_config 8
500.Pp
501The SYNOPSIS portion of each device in section 4 of the manual.
502.Rs
503.%T "Building 4.4 BSD Systems with Config"
504.Re
505.Sh HISTORY
506The
507.Nm
508program appeared in
509.Bx 4.1
510and was completely revised in
511.Bx 4.4 .
512The
513.Fl e
514option appeared in
515.Ox 2.6 .
516.Sh BUGS
517Included files should start with an empty line or comment.
518