Skip to content
  • Matteo Croce's avatar
    reboot: allow to specify reboot mode via sysfs · eab90a23
    Matteo Croce authored
    The kernel cmdline reboot= option offers some sort of control on how the
    reboot is issued.
    We don't always know in advance what type of reboot to perform.
    Sometimes a warm reboot is preferred to persist certain memory regions
    across the reboot.  Others a cold one is needed to apply a future
    system update that makes a memory memory model change, like changing
    the base page size or resizing a persistent memory region.
    Or simply we want to enable reboot_force because we noticed that
    something bad happened.
    Add handles in sysfs to allow setting these reboot options, so they can
    be changed when the system is booted, other than at boot time.
    The handlers are under <sysfs>/kernel/reboot, can be read to get the
    current configuration and written to alter it.
    	# cd /sys/kernel/reboot/
    	# grep . *
    	# echo 2 >cpu
    	# echo yes >force
    	# echo soft >mode
    	# echo bios >type
    	# grep . *
    Before setting anything, check for CAP_SYS_BOOT capability, so it's
    possible to allow an unpriviledged process to change these settings simply
    by relaxing the handles permissions, without opening them to the world.
    Signed-off-by: default avatarMatteo Croce <>
    Reviewed-by: default avatarPetr Mladek <>
    Cc: Mike Rapoport <>
    Cc: Guenter Roeck <>
    Cc: Arnd Bergmann <>
    Cc: Pavel Tatashin <>
    Cc: Kees Cook <>
    Cc: Tyler Hicks <>
    Cc: Nathan Chancellor <>
    Signed-off-by: default avatarAndrew Morton <>
    Signed-off-by: default avatarStephen Rothwell <>