xref: /freebsd/sbin/dumpon/dumpon.8 (revision 4928135658a9d0eaee37003df6137ab363fcb0b4)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  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.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     From: @(#)swapon.8	8.1 (Berkeley) 6/5/93
29.\" $FreeBSD$
30.\"
31.Dd March 6, 2018
32.Dt DUMPON 8
33.Os
34.Sh NAME
35.Nm dumpon
36.Nd "specify a device for crash dumps"
37.Sh SYNOPSIS
38.Nm
39.Op Fl v
40.Op Fl k Ar pubkey
41.Op Fl Z
42.Op Fl z
43.Ar device
44.Nm
45.Op Fl v
46.Op Fl k Ar pubkey
47.Op Fl Z
48.Op Fl z
49.Op Fl g Ar gateway | Li default
50.Fl s Ar server
51.Fl c Ar client
52.Ar iface
53.Nm
54.Op Fl v
55.Cm off
56.Nm
57.Op Fl v
58.Fl l
59.Sh DESCRIPTION
60The
61.Nm
62utility is used to specify a device where the kernel can save a crash
63dump in the case of a panic.
64.Pp
65Calls to
66.Nm
67normally occur from the system multi-user initialization file
68.Pa /etc/rc ,
69controlled by the
70.Dq dumpdev
71and
72.Dq dumpon_flags
73variables in the boot time configuration file
74.Pa /etc/rc.conf .
75.Pp
76The default type of kernel crash dump is the mini crash dump.
77Mini crash dumps hold only memory pages in use by the kernel.
78Alternatively, full memory dumps can be enabled by setting the
79.Va debug.minidump
80.Xr sysctl 8
81variable to 0.
82.Pp
83For systems using full memory dumps, the size of the specified dump
84device must be at least the size of physical memory.
85Even though an additional 64 kB header is added to the dump, the BIOS for a
86platform typically holds back some memory, so it is not usually
87necessary to size the dump device larger than the actual amount of RAM
88available in the machine.
89Also, when using full memory dumps, the
90.Nm
91utility will refuse to enable a dump device which is smaller than the
92total amount of physical memory as reported by the
93.Va hw.physmem
94.Xr sysctl 8
95variable.
96.Pp
97.Nm
98is used to configure a local storage device as the dump device.
99With additional parameters, the kernel can instead be configured to
100transmit a dump to a remote server using
101.Xr netdump 4 .
102This eliminates the need to reserve space for saving crash dumps and
103is especially useful in diskless environments.
104The
105.Xr netdump 4
106server address is specified with
107.Fl s Ar server ,
108and the local address is specified with
109.Fl c Ar client .
110The
111.Fl g Ar gateway
112parameter may be used to specify a first-hop router to the server,
113or to specify that the currently configured default gateway is to
114be used.
115Note that the
116.Xr netdump 4
117configuration is not automatically updated if any network configuration
118(e.g., the default route) changes after the
119.Nm
120invocation.
121The name of the interface to be used must be specified as
122.Ar iface .
123The interface must be up in order to configure
124.Xr netdump 4 .
125.Pp
126The
127.Fl k Ar pubkey
128flag causes
129.Nm
130to generate a one-time key for kernel crash dump encryption.
131The key will be replaced by a new one when the
132.Nm
133utility is run again.
134The key is encrypted using
135.Ar pubkey .
136This process is sandboxed using
137.Xr capsicum 4 .
138Both plain and encrypted keys are sent to the kernel using
139.Dv DIOCSKERNELDUMP
140.Xr ioctl 2 .
141A user can specify the
142.Ar pubkey
143in the
144.Dq dumpon_flags
145variable defined in
146.Pa /etc/rc.conf
147for use with the
148.Pa /etc/rc.d/dumpon
149.Xr rc 8
150script.
151This flag requires a kernel compiled with the
152.Dv EKCD
153kernel option.
154.Pp
155The
156.Fl z
157and
158.Fl Z
159options configure the kernel to compress the dump before writing it to
160the dump device.
161This reduces the amount of space required for the dump and accelerates
162recovery with
163.Xr savecore 8
164since less data needs to be copied from the dump device.
165When compression is enabled, the
166.Nm
167utility will not verify that the dump device is sufficiently large for a full
168dump.
169The
170.Fl z
171and
172.Fl Z
173options cause the dump to be written in
174.Xr gzip 1
175and
176.Xr zstd 1
177format, respectively.
178These flags require a kernel compiled with the
179.Dv GZIO
180or
181.Dv ZSTDIO
182kernel options.
183.Pp
184.Pp
185The
186.Fl l
187flag causes
188.Nm
189to print the current dump device or _PATH_DEVNULL ("/dev/null") if no device is
190configured.
191.Pp
192The
193.Fl v
194flag causes
195.Nm
196to be verbose about its activity.
197.Sh IMPLEMENTATION NOTES
198Since a
199.Xr panic 9
200condition may occur in a situation
201where the kernel cannot trust its internal representation
202of the state of any given file system,
203one of the system swap devices,
204and
205.Em not
206a device containing a file system,
207should be used as the dump device.
208.Pp
209The
210.Nm
211utility operates by opening
212.Ar device
213and making a
214.Dv DIOCSKERNELDUMP
215.Xr ioctl 2
216request on it to save kernel crash dumps.
217If
218.Ar device
219is the text string:
220.Dq Li off ,
221.Nm
222performs a
223.Dv DIOCSKERNELDUMP
224.Xr ioctl 2
225on
226.Pa /dev/null
227and thus instructs the kernel not to save crash dumps.
228.Pp
229Since
230.Nm
231cannot be used during kernel initialization, the
232.Va dumpdev
233variable of
234.Xr loader 8
235must be used to enable dumps for system panics which occur
236during kernel initialization.
237.Sh FILES
238.Bl -tag -width "/dev/{ada,da}?s?b" -compact
239.It Pa /dev/{ada,da}?s?b
240standard swap areas
241.It Pa /etc/rc.conf
242boot-time system configuration
243.El
244.Sh EXAMPLES
245In order to generate an RSA private key a user can use the
246.Xr genrsa 1
247tool:
248.Pp
249.Dl # openssl genrsa -out private.pem 4096
250.Pp
251A public key can be extracted from the private key using the
252.Xr rsa 1
253tool:
254.Pp
255.Dl # openssl rsa -in private.pem -out public.pem -pubout
256.Pp
257Once the RSA keys are created the private key should be moved to a safe place.
258Now
259.Pa public.pem
260can be used by
261.Nm
262to configure encrypted kernel crash dumps:
263.Pp
264.Dl # dumpon -k public.pem /dev/ada0s1b
265.Pp
266It is recommended to test if the kernel saves encrypted crash dumps using the
267current configuration.
268The easiest way to do that is to cause a kernel panic using the
269.Xr ddb 4
270debugger:
271.Pp
272.Dl # sysctl debug.kdb.panic=1
273.Pp
274In the debugger the following commands should be typed to write a core dump and
275reboot:
276.Pp
277.Dl db> call doadump(0)
278.Dl db> reset
279.Pp
280After reboot
281.Xr savecore 8
282should be able to save the core dump in the core directory which is
283.Pa /var/crash
284by default:
285.Pp
286.Dl # savecore /var/crash /dev/ada0s1b
287.Pp
288Three files should be created in the core directory:
289.Pa info.# ,
290.Pa key.#
291and
292.Pa vmcore_encrypted.#
293where
294.Dq #
295is the number of the last core dump saved by
296.Xr savecore 8 .
297The
298.Pa vmcore_encrypted.#
299can be decrypted using the
300.Xr decryptcore 8
301utility:
302.Pp
303.Dl # decryptcore -p private.pem -k key.# -e vmcore_encrypted.# -c vmcore.#
304.Pp
305or shorter:
306.Pp
307.Dl # decryptcore -p private.pem -n #
308.Pp
309The
310.Pa vmcore.#
311can be now examined using
312.Xr kgdb 1 :
313.Pp
314.Dl # kgdb /usr/lib/debug/boot/kernel/kernel.debug vmcore.#
315.Pp
316or shorter:
317.Pp
318.Dl # kgdb -n # /usr/lib/debug/boot/kernel/kernel.debug
319.Pp
320The core was decrypted properly if
321.Xr kgdb 1
322does not print any errors.
323.Sh SEE ALSO
324.Xr gzip 1 ,
325.Xr kgdb 1 ,
326.Xr zstd 1 ,
327.Xr ddb 4 ,
328.Xr fstab 5 ,
329.Xr rc.conf 5 ,
330.Xr config 8 ,
331.Xr decryptcore 8 ,
332.Xr init 8 ,
333.Xr loader 8 ,
334.Xr rc 8 ,
335.Xr savecore 8 ,
336.Xr swapon 8 ,
337.Xr panic 9
338.Sh HISTORY
339The
340.Nm
341utility appeared in
342.Fx 2.0.5 .
343.Sh BUGS
344Because the file system layer is already dead by the time a crash dump
345is taken, it is not possible to send crash dumps directly to a file.
346.Pp
347It is currently not possible to configure both compression and encryption.
348The encrypted dump format assumes that the kernel dump size is a multiple
349of the cipher block size, which may not be true when the dump is compressed.
350