xref: /netbsd-src/sbin/savecore/savecore.8 (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1.\"	$NetBSD: savecore.8,v 1.36 2011/09/13 08:54:11 wiz Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)savecore.8	8.1 (Berkeley) 6/5/93
31.\"
32.Dd September 13, 2011
33.Dt SAVECORE 8
34.Os
35.Sh NAME
36.Nm savecore
37.Nd save a core dump of the operating system
38.Sh SYNOPSIS
39.Nm
40.Op Fl fvz
41.Op Fl N Ar system
42.Op Fl Z Ar level
43.Op Ar directory
44.Nm
45.Fl c
46.Op Fl v
47.Op Fl N Ar system
48.Nm
49.Fl n
50.Op Fl v
51.Op Fl N Ar system
52.Sh DESCRIPTION
53When the
54.Nx
55kernel encounters a fatal error, the
56.Xr panic 9
57routine arranges for a snapshot of the contents of physical memory to
58be written into a dump area, typically in the swap partition.
59.Pp
60Upon a subsequent reboot,
61.Nm
62is typically run out of
63.Xr rc 8 ,
64before swapping is enabled, to copy the kernel and the saved memory image
65into
66.Fa directory ,
67and enters a reboot message and information about the core dump into
68the system log.
69If a directory is not specified, then
70.Pa /var/crash
71is used.
72.Pp
73The kernel and core file can then be analyzed using various tools,
74including
75.Xr crash 8 ,
76.Xr dmesg 8 ,
77.Xr fstat 1 ,
78.Xr gdb 1 ,
79.Xr iostat 8 ,
80.Xr netstat 1 ,
81.Xr ps 1 ,
82and
83.Xr pstat 8 ,
84to attempt to deduce the cause of the crash.
85.Pp
86Crashes are usually the result of hardware faults or kernel bugs.
87If a kernel bug is suspected, a full bug report should be filed at
88http://www.netbsd.org/, or using
89.Xr send-pr 1 ,
90containing as much information as possible about the circumstances of
91the crash.
92Since crash dumps are typically very large and may contain
93whatever (potentially confidential) information was in memory at the
94time of the crash, do
95.Em NOT
96include a copy of the crash dump file in the bug report; instead, save it
97somewhere in the event that a
98.Nx
99developer wants to examine it.
100.Pp
101The options are as follows:
102.Bl -tag -width directory
103.It Fl c
104Only clears the dump without saving it, so that future invocations of
105.Nm
106will ignore it.
107.It Fl f
108Forces a dump to be taken even if the dump doesn't appear correct or there
109is insufficient disk space.
110.It Fl n
111Check whether a dump is present without taking further action.
112The command exits with zero status if a dump is present, or with non-zero
113status otherwise.
114.It Fl N
115Use
116.Ar system
117as the kernel instead of the default (returned by
118.Xr getbootfile 3 ) .
119Note that
120.Xr getbootfile 3
121uses
122.Xr secure_path 3
123to check that kernel file is
124.Dq secure
125and will default to
126.Pa /netbsd
127if the check fails.
128.It Fl v
129Prints out some additional debugging information.
130.It Fl z
131Compresses the core dump and kernel (see
132.Xr gzip 1 ) .
133.It Fl Z Ar level
134Set the compression level for
135.Fl z
136to
137.Ar level .
138Defaults to 1 (the fastest compression mode).
139Refer to
140.Xr gzip 1
141for more information regarding the compression level.
142.El
143.Pp
144.Nm
145checks the core dump in various ways to make sure that it is current and
146that it corresponds to the currently running system.
147If it passes these checks, it saves the core image in
148.Ar directory Ns Pa /netbsd.#.core
149and the system in
150.Ar directory Ns Pa /netbsd.#
151(or in
152.Ar directory Ns Pa /netbsd.#.core.gz
153and
154.Ar directory Ns Pa /netbsd.#.gz ,
155respectively, if the
156.Fl z
157option is used).
158The
159.Dq #
160is the number from the first line of the file
161.Ar directory Ns Pa /bounds ,
162and it is incremented and stored back into the file each time
163.Nm
164successfully runs.
165.Pp
166.Nm
167also checks the available disk space before attempting to make the copies.
168If there is insufficient disk space in the file system containing
169.Ar directory ,
170or if the file
171.Ar directory Ns Pa /minfree
172exists and the number of free kilobytes (for non-superusers) in the
173file system after the copies were made would be less than the number
174in the first line of this file, the copies are not attempted.
175.Pp
176If
177.Nm
178successfully copies the kernel and the core dump, the core dump is cleared
179so that future invocations of
180.Nm
181will ignore it.
182.Sh SEE ALSO
183.Xr fstat 1 ,
184.Xr gdb 1 ,
185.Xr gzip 1 ,
186.Xr netstat 1 ,
187.Xr ps 1 ,
188.Xr send-pr 1 ,
189.Xr crash 8 ,
190.Xr dmesg 8 ,
191.Xr iostat 8 ,
192.Xr pstat 8 ,
193.Xr rc 8 ,
194.Xr syslogd 8 ,
195.Xr panic 9
196.Sh HISTORY
197The
198.Nm
199command appeared in
200.Bx 4.1 .
201.Sh BUGS
202The minfree code does not consider the effect of compression.
203