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