xref: /freebsd-14.2/lib/libc/sys/reboot.2 (revision b2c76c41)
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.\"     @(#)reboot.2	8.1 (Berkeley) 6/4/93
29.\"
30.Dd July 10, 2018
31.Dt REBOOT 2
32.Os
33.Sh NAME
34.Nm reboot
35.Nd reboot system or halt processor
36.Sh LIBRARY
37.Lb libc
38.Sh SYNOPSIS
39.In unistd.h
40.In sys/reboot.h
41.Ft int
42.Fn reboot "int howto"
43.Sh DESCRIPTION
44The
45.Fn reboot
46system call
47reboots the system.
48Only the super-user may reboot a machine on demand.
49However, a reboot is invoked
50automatically in the event of unrecoverable system failures.
51.Pp
52The
53.Fa howto
54argument
55is a mask of options; the system call interface allows the following
56options, defined in the include file
57.In sys/reboot.h ,
58to be passed
59to the new kernel or the new bootstrap and init programs.
60.Bl -tag -width RB_POWERCYCLE
61.It Dv RB_AUTOBOOT
62The default, causing the system to reboot in its usual fashion.
63.It Dv RB_ASKNAME
64Normally the system only prompts the user if the loader specified root
65file system has an error.
66This flag forces it to always prompt the user for the root partition.
67.It Dv RB_DFLTROOT
68Use the compiled in root device.
69Normally, the system uses the device from which it was booted
70as the root device if possible.
71(The default behavior is dependent on the ability of the bootstrap program
72to determine the drive from which it was loaded, which is not possible
73on all systems.)
74.It Dv RB_DUMP
75Dump kernel memory before rebooting; see
76.Xr savecore 8
77for more information.
78.It Dv RB_HALT
79The processor is simply halted; no reboot takes place.
80This option should be used with caution.
81.It Dv RB_POWERCYCLE
82After halting, the shutdown code will do what it can to turn
83off the power and then turn the power back on.
84This requires hardware support, usually an auxiliary microprocessor
85that can sequence the power supply.
86At present only the
87.Xr ipmi 4
88driver implements this feature.
89.It Dv RB_POWEROFF
90After halting, the shutdown code will do what it can to turn
91off the power.
92This requires hardware support.
93.It Dv RB_KDB
94Load the symbol table and enable a built-in debugger in the system.
95This option will have no useful function if the kernel is not configured
96for debugging.
97Several other options have different meaning if combined
98with this option, although their use may not be possible
99via the
100.Fn reboot
101system call.
102See
103.Xr ddb 4
104for more information.
105.It Dv RB_NOSYNC
106Normally, the disks are sync'd (see
107.Xr sync 8 )
108before the processor is halted or rebooted.
109This option may be useful if file system changes have been made manually
110or if the processor is on fire.
111.It Dv RB_REROOT
112Instead of rebooting, unmount all filesystems except the one containing
113currently-running executable, and mount root filesystem using the same
114mechanism which is used during normal boot, based on
115vfs.root.mountfrom
116.Xr kenv 1
117variable.
118.It Dv RB_RDONLY
119Initially mount the root file system read-only.
120This is currently the default, and this option has been deprecated.
121.It Dv RB_SINGLE
122Normally, the reboot procedure involves an automatic disk consistency
123check and then multi-user operations.
124.Dv RB_SINGLE
125prevents this, booting the system with a single-user shell
126on the console.
127.Dv RB_SINGLE
128is actually interpreted by the
129.Xr init 8
130program in the newly booted system.
131.El
132.Pp
133When no options are given (i.e.,
134.Dv RB_AUTOBOOT
135is used), the system is
136rebooted from file
137.Dq kernel
138in the root file system of unit 0
139of a disk chosen in a processor specific way.
140An automatic consistency check of the disks is normally performed
141(see
142.Xr fsck 8 ) .
143.Sh RETURN VALUES
144If successful, this call never returns.
145Otherwise, a -1 is returned and an error is returned in the global
146variable
147.Va errno .
148.Sh ERRORS
149.Bl -tag -width Er
150.It Bq Er EPERM
151The caller is not the super-user.
152.El
153.Sh SEE ALSO
154.Xr crash 8 ,
155.Xr halt 8 ,
156.Xr init 8 ,
157.Xr reboot 8 ,
158.Xr savecore 8 ,
159.Xr reboot 9
160.Sh HISTORY
161The
162.Fn reboot
163system call appeared in
164.Bx 4.0 .
165