Add a -k option to reboot to specify the kernel to boot next time
around. If the kernel boots successfully, the record of this kernel is erased, it is intended to be a one-shot option for testing kernels. This could be improved by having the loader remove the record of the next kernel to boot, it is currently removed in /etc/rc immediately after disks are mounted r/w. I'd like to MFC this before the 4.6 freeze unless there is violent objection. Reviewed by: Several on IRC MFC after: 4 days
This commit is contained in:
parent
a182065f27
commit
1de372dcd4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95485
4
etc/rc
4
etc/rc
@ -314,6 +314,10 @@ if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
|
|||||||
sh ${diskless_mount}
|
sh ${diskless_mount}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If we booted a special kernel remove the record so we will boot
|
||||||
|
# the default kernel next time
|
||||||
|
rm -f /boot/nextkernel
|
||||||
|
|
||||||
# Reseed /dev/random with previously stored entropy.
|
# Reseed /dev/random with previously stored entropy.
|
||||||
case ${entropy_dir} in
|
case ${entropy_dir} in
|
||||||
[Nn][Oo])
|
[Nn][Oo])
|
||||||
|
@ -44,12 +44,16 @@
|
|||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm halt
|
.Nm halt
|
||||||
.Op Fl lnqp
|
.Op Fl lnqp
|
||||||
|
.Op Fl k Ar kernel
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl dlnqp
|
.Op Fl dlnqp
|
||||||
|
.Op Fl k Ar kernel
|
||||||
.Nm fasthalt
|
.Nm fasthalt
|
||||||
.Op Fl lnqp
|
.Op Fl lnqp
|
||||||
|
.Op Fl k Ar kernel
|
||||||
.Nm fastboot
|
.Nm fastboot
|
||||||
.Op Fl dlnqp
|
.Op Fl dlnqp
|
||||||
|
.Op Fl k Ar kernel
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The
|
The
|
||||||
.Nm halt
|
.Nm halt
|
||||||
@ -72,6 +76,16 @@ The system is requested to create a crash dump. This option is
|
|||||||
supported only when rebooting, and it has no effect unless a dump
|
supported only when rebooting, and it has no effect unless a dump
|
||||||
device has previously been specified with
|
device has previously been specified with
|
||||||
.Xr dumpon 8 .
|
.Xr dumpon 8 .
|
||||||
|
.It Fl k Ar kernel
|
||||||
|
Boot the specified
|
||||||
|
.Ar kernel
|
||||||
|
on the next system boot. If the kernel boots successfully, the
|
||||||
|
.Em default
|
||||||
|
kernel will be booted on succesive boots, this is a one-shot option.
|
||||||
|
If the boot fails, the system will continue attempting to boot
|
||||||
|
.Ar kernel
|
||||||
|
until the boot process is interrupted and a valid kernel booted.
|
||||||
|
This may change in the future.
|
||||||
.It Fl l
|
.It Fl l
|
||||||
The halt or reboot is
|
The halt or reboot is
|
||||||
.Em not
|
.Em not
|
||||||
|
@ -51,6 +51,7 @@ static const char rcsid[] =
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
@ -68,9 +69,9 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
int ch, howto, i, lflag, nflag, qflag, pflag, sverrno;
|
int ch, howto, i, fd, kflag, lflag, nflag, qflag, pflag, sverrno;
|
||||||
u_int pageins;
|
u_int pageins;
|
||||||
char *p;
|
char *kernel, *p;
|
||||||
const char *user;
|
const char *user;
|
||||||
|
|
||||||
if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
|
if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
|
||||||
@ -78,12 +79,16 @@ main(int argc, char *argv[])
|
|||||||
howto = RB_HALT;
|
howto = RB_HALT;
|
||||||
} else
|
} else
|
||||||
howto = 0;
|
howto = 0;
|
||||||
lflag = nflag = qflag = 0;
|
kflag = lflag = nflag = qflag = 0;
|
||||||
while ((ch = getopt(argc, argv, "dlnpq")) != -1)
|
while ((ch = getopt(argc, argv, "dk:lnpq")) != -1)
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
howto |= RB_DUMP;
|
howto |= RB_DUMP;
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
kflag = 1;
|
||||||
|
kernel = optarg;
|
||||||
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
lflag = 1;
|
lflag = 1;
|
||||||
break;
|
break;
|
||||||
@ -117,6 +122,16 @@ main(int argc, char *argv[])
|
|||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kflag) {
|
||||||
|
fd = open("/boot/nextkernel", O_WRONLY | O_CREAT, 0444);
|
||||||
|
if (fd > -1) {
|
||||||
|
(void)write(fd, "kernel=\"", 8L);
|
||||||
|
(void)write(fd, kernel, strlen(kernel));
|
||||||
|
(void)write(fd, "\"\n", 2);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Log the reboot. */
|
/* Log the reboot. */
|
||||||
if (!lflag) {
|
if (!lflag) {
|
||||||
if ((user = getlogin()) == NULL)
|
if ((user = getlogin()) == NULL)
|
||||||
@ -195,7 +210,7 @@ main(int argc, char *argv[])
|
|||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr, "usage: %s [-dnpq]\n",
|
(void)fprintf(stderr, "usage: %s [-dnpq] [-k kernel]\n",
|
||||||
dohalt ? "halt" : "reboot");
|
dohalt ? "halt" : "reboot");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ userconfig_script_load="NO"
|
|||||||
userconfig_script_name="/boot/kernel.conf"
|
userconfig_script_name="/boot/kernel.conf"
|
||||||
userconfig_script_type="userconfig_script"
|
userconfig_script_type="userconfig_script"
|
||||||
|
|
||||||
loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local"
|
loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local /boot/nextkernel"
|
||||||
|
|
||||||
verbose_loading="NO" # Set to YES for verbose loader output
|
verbose_loading="NO" # Set to YES for verbose loader output
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user