]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/dumpon/dumpon.8
Copy libevent sources to contrib
[FreeBSD/FreeBSD.git] / sbin / dumpon / dumpon.8
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 June 13, 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
60 The
61 .Nm
62 utility is used to specify a device where the kernel can save a crash
63 dump in the case of a panic.
64 .Pp
65 Calls to
66 .Nm
67 normally occur from the system multi-user initialization file
68 .Pa /etc/rc ,
69 controlled by the
70 .Dq dumpdev
71 and
72 .Dq dumpon_flags
73 variables in the boot time configuration file
74 .Pa /etc/rc.conf .
75 .Pp
76 The default type of kernel crash dump is the mini crash dump.
77 Mini crash dumps hold only memory pages in use by the kernel.
78 Alternatively, full memory dumps can be enabled by setting the
79 .Va debug.minidump
80 .Xr sysctl 8
81 variable to 0.
82 .Pp
83 For systems using full memory dumps, the size of the specified dump
84 device must be at least the size of physical memory.
85 Even though an additional 64 kB header is added to the dump, the BIOS for a
86 platform typically holds back some memory, so it is not usually
87 necessary to size the dump device larger than the actual amount of RAM
88 available in the machine.
89 Also, when using full memory dumps, the
90 .Nm
91 utility will refuse to enable a dump device which is smaller than the
92 total amount of physical memory as reported by the
93 .Va hw.physmem
94 .Xr sysctl 8
95 variable.
96 .Pp
97 .Nm
98 is used to configure a local storage device as the dump device.
99 With additional parameters, the kernel can instead be configured to
100 transmit a dump to a remote server using
101 .Xr netdump 4 .
102 This eliminates the need to reserve space for saving crash dumps and
103 is especially useful in diskless environments.
104 The
105 .Xr netdump 4
106 server address is specified with
107 .Fl s Ar server ,
108 and the local address is specified with
109 .Fl c Ar client .
110 The
111 .Fl g Ar gateway
112 parameter may be used to specify a first-hop router to the server,
113 or to specify that the currently configured default gateway is to
114 be used.
115 Note that the
116 .Xr netdump 4
117 configuration is not automatically updated if any network configuration
118 (e.g., the default route) changes after the
119 .Nm
120 invocation.
121 The name of the interface to be used must be specified as
122 .Ar iface .
123 The interface must be up in order to configure
124 .Xr netdump 4 .
125 .Pp
126 The
127 .Fl k Ar pubkey
128 flag causes
129 .Nm
130 to generate a one-time key for kernel crash dump encryption.
131 The key will be replaced by a new one when the
132 .Nm
133 utility is run again.
134 The key is encrypted using
135 .Ar pubkey .
136 This process is sandboxed using
137 .Xr capsicum 4 .
138 Both plain and encrypted keys are sent to the kernel using
139 .Dv DIOCSKERNELDUMP
140 .Xr ioctl 2 .
141 A user can specify the
142 .Ar pubkey
143 in the
144 .Dq dumpon_flags
145 variable defined in
146 .Pa /etc/rc.conf
147 for use with the
148 .Pa /etc/rc.d/dumpon
149 .Xr rc 8
150 script.
151 This flag requires a kernel compiled with the
152 .Dv EKCD
153 kernel option.
154 .Pp
155 The
156 .Fl z
157 and
158 .Fl Z
159 options configure the kernel to compress the dump before writing it to
160 the dump device.
161 This reduces the amount of space required for the dump and accelerates
162 recovery with
163 .Xr savecore 8
164 since less data needs to be copied from the dump device.
165 When compression is enabled, the
166 .Nm
167 utility will not verify that the dump device is sufficiently large for a full
168 dump.
169 The
170 .Fl z
171 and
172 .Fl Z
173 options cause the dump to be written in
174 .Xr gzip 1
175 and
176 .Xr zstd 1
177 format, respectively.
178 These flags require a kernel compiled with the
179 .Dv GZIO
180 or
181 .Dv ZSTDIO
182 kernel options.
183 .Pp
184 The
185 .Fl l
186 flag causes
187 .Nm
188 to print the current dump device or _PATH_DEVNULL ("/dev/null") if no device is
189 configured.
190 .Pp
191 The
192 .Fl v
193 flag causes
194 .Nm
195 to be verbose about its activity.
196 .Sh IMPLEMENTATION NOTES
197 Since a
198 .Xr panic 9
199 condition may occur in a situation
200 where the kernel cannot trust its internal representation
201 of the state of any given file system,
202 one of the system swap devices,
203 and
204 .Em not
205 a device containing a file system,
206 should be used as the dump device.
207 .Pp
208 The
209 .Nm
210 utility operates by opening
211 .Ar device
212 and making a
213 .Dv DIOCSKERNELDUMP
214 .Xr ioctl 2
215 request on it to save kernel crash dumps.
216 If
217 .Ar device
218 is the text string:
219 .Dq Li off ,
220 .Nm
221 performs a
222 .Dv DIOCSKERNELDUMP
223 .Xr ioctl 2
224 on
225 .Pa /dev/null
226 and thus instructs the kernel not to save crash dumps.
227 .Pp
228 Since
229 .Nm
230 cannot be used during kernel initialization, the
231 .Va dumpdev
232 variable of
233 .Xr loader 8
234 must be used to enable dumps for system panics which occur
235 during kernel initialization.
236 .Sh FILES
237 .Bl -tag -width "/dev/{ada,da}?s?b" -compact
238 .It Pa /dev/{ada,da}?s?b
239 standard swap areas
240 .It Pa /etc/rc.conf
241 boot-time system configuration
242 .El
243 .Sh EXAMPLES
244 In order to generate an RSA private key a user can use the
245 .Xr genrsa 1
246 tool:
247 .Pp
248 .Dl # openssl genrsa -out private.pem 4096
249 .Pp
250 A public key can be extracted from the private key using the
251 .Xr rsa 1
252 tool:
253 .Pp
254 .Dl # openssl rsa -in private.pem -out public.pem -pubout
255 .Pp
256 Once the RSA keys are created the private key should be moved to a safe place.
257 Now
258 .Pa public.pem
259 can be used by
260 .Nm
261 to configure encrypted kernel crash dumps:
262 .Pp
263 .Dl # dumpon -k public.pem /dev/ada0s1b
264 .Pp
265 It is recommended to test if the kernel saves encrypted crash dumps using the
266 current configuration.
267 The easiest way to do that is to cause a kernel panic using the
268 .Xr ddb 4
269 debugger:
270 .Pp
271 .Dl # sysctl debug.kdb.panic=1
272 .Pp
273 In the debugger the following commands should be typed to write a core dump and
274 reboot:
275 .Pp
276 .Dl db> call doadump(0)
277 .Dl db> reset
278 .Pp
279 After reboot
280 .Xr savecore 8
281 should be able to save the core dump in the core directory which is
282 .Pa /var/crash
283 by default:
284 .Pp
285 .Dl # savecore /var/crash /dev/ada0s1b
286 .Pp
287 Three files should be created in the core directory:
288 .Pa info.# ,
289 .Pa key.#
290 and
291 .Pa vmcore_encrypted.#
292 where
293 .Dq #
294 is the number of the last core dump saved by
295 .Xr savecore 8 .
296 The
297 .Pa vmcore_encrypted.#
298 can be decrypted using the
299 .Xr decryptcore 8
300 utility:
301 .Pp
302 .Dl # decryptcore -p private.pem -k key.# -e vmcore_encrypted.# -c vmcore.#
303 .Pp
304 or shorter:
305 .Pp
306 .Dl # decryptcore -p private.pem -n #
307 .Pp
308 The
309 .Pa vmcore.#
310 can be now examined using
311 .Xr kgdb 1 :
312 .Pp
313 .Dl # kgdb /boot/kernel/kernel vmcore.#
314 .Pp
315 or shorter:
316 .Pp
317 .Dl # kgdb -n #
318 .Pp
319 The core was decrypted properly if
320 .Xr kgdb 1
321 does not print any errors.
322 Note that the live kernel might be at a different path
323 which can be examined by looking at the kern.bootfile sysctl.
324 .Sh SEE ALSO
325 .Xr gzip 1 ,
326 .Xr kgdb 1 ,
327 .Xr zstd 1 ,
328 .Xr ddb 4 ,
329 .Xr fstab 5 ,
330 .Xr rc.conf 5 ,
331 .Xr config 8 ,
332 .Xr decryptcore 8 ,
333 .Xr init 8 ,
334 .Xr loader 8 ,
335 .Xr rc 8 ,
336 .Xr savecore 8 ,
337 .Xr swapon 8 ,
338 .Xr panic 9
339 .Sh HISTORY
340 The
341 .Nm
342 utility appeared in
343 .Fx 2.0.5 .
344 .Sh BUGS
345 Because the file system layer is already dead by the time a crash dump
346 is taken, it is not possible to send crash dumps directly to a file.
347 .Pp
348 It is currently not possible to configure both compression and encryption.
349 The encrypted dump format assumes that the kernel dump size is a multiple
350 of the cipher block size, which may not be true when the dump is compressed.