Heres a simple script for using kexec to do a quick reboot. The script properly kills all running processes, unmounts all local filesystem, remounts root read-only and then loads the current running kernel ( /boot/vmlinuz-$(uname -r) ) and executes it with kexec -e
If it is supplied with the "-i" command line option it also includes the matching initrd
Since a partial shutdown is done... and root is remounted read-only. fsck doesnt complainCode:#!/bin/bash ######## Settings ######## KERNEL=/boot/vmlinuz-$(uname -r) # Edit this to the format of your initrd filenames INITRD="/boot/initrd.img" # Set env and do some sanity checks CMDLINE=$(cat /proc/cmdline) KEXEC_STATUS=$(dpkg --get-selections kexec-tools | awk '{ print $2 }') [ "$1" = "-i" ] && INITRD="--initrd=$INITRD-$(uname -r)" || INITRD="" [ "$UID" != "0" ] && echo "This script must be run as root!" && exit 1 [ ! "$KEXEC_STATUS" = "install" ] && echo "kexec not found! Please install the package 'kexec-tools'" && exit 1 # Function to blank the screen... cosmedic screen_dump() { # Edit CYCLES if you like. Less cycles means the script will be faster # but may leave garbage on the screen from the previous kernel CYCLES=1000 PASS=0 clear while [[ $PASS -lt $CYCLES ]] do echo "" >/dev/console ; echo "" >/dev/tty0 echo "" >/dev/tty1 ; echo "" >/dev/tty2 echo "" >/dev/tty3 ; echo "" >/dev/tty4 echo "" >/dev/tty5 ; echo "" >/dev/tty6 PASS=$(($PASS + 1)) done clear } FATAL_ERROR() { echo "" echo "FATAL: $1 not found." exit 1 } # Deactivate current system and go read-only ## Make sure no other kernel has been loaded kexec -u sync echo -n "Killing all running processes ..." [ -x /etc/init.d/sendsigs ] && /etc/init.d/sendsigs stop >/dev/null 2>&1 || FATAL_ERROR "/etc/init.d/umountroot" echo "Done" echo -n "Mounting root read-only ..." [ -x /etc/init.d/umountfs ] && /etc/init.d/umountfs stop >/dev/null 2>&1 || FATAL_ERROR "/etc/init.d/umountroot" [ -x /etc/init.d/umountroot ] && /etc/init.d/umountroot stop >/dev/null 2>&1 || FATAL_ERROR "/etc/init.d/umountroot" echo "Done" # Clear the screen once again and boot the new kernel # Load the system kexec -l $KERNEL $INITRD --append="$CMDLINE" echo "Booting the system...." screen_dump kexec -e
Enjoy!
-Justin
One Mynds Eye

Kingston 32GB 64GB 128GB 256GB USB 3.0 Flash Drive Thumb Memory Stick Pen lot
$285.90
Samsung 32GB (1x32GB) PC4-17000 (DDR4-2133) LRDIMM Memory (M386A4G40DM0-CPB0Q)
$120.00
HPE 32GB 2Rx4 PC4-2933Y-R DDR4 Svr RAM P03052-091 P00924-B21 M393A4K40DB2-CVFBY
$270.00
2 in 1 USB 3.0 Card Reader Micro TF card Reader usb adapter High Speed Cardreder
$3.99
Kingston 32GB 2Rx4 PC4-2400T-RB1-11 ECC REG Server Memory HP24D4R7D4MAM-32
$150.00
NMA1XXD128GPS Intel Optane 1X128GB DDR4 PC4-21300 DCPMM Persistent Server Memory
$75.00
Hynix 32GB DDR4 PC4-3200AA 2Rx4 ECC REG DIMM HMA84GR7CJR4N-XN SERVER MEM
$310.00
USB 3.0 Flash Drive 32GB 64GB 128GB Memory Stick Thumb Stick Lot Pack
$369.59
Wholesale USB 2.0 5/10/ 100PCS 2GB 4GB 8GB 16GB 32GB 64GB Metal USB Flash Drive
$176.00
2 Pack USB C SD TF Card Reader Adapter Zinc Alloy USB-C to USB for iPhone 15-17
$3.35