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

(2) Seagate SAS Hard Drive Exos 7E8 3TB 7200RPM 128MB 12Gb/s 3.5 ST3000NM0035
$49.99
Dell EMC WD-HITACHI H5H72101CLAR10T0 10TB 7.2K SAS 12Gb/s SED 3.5in A POH 0-50k
$189.99
Seagate BarraCuda ST3000DM008 3TB Internal SATA 6Gb 3.5" Hard Drive 7200RPM 64MB
$91.99
Seagate ST500DM009 BarraCuda 500 GB 3.5" SATA III Desktop Hard Drive
$14.99
Toshiba MG04ACA400 4TB 3.5-inch SATA 6 Gb/s 7,200 RPM Internal Hard Drive
$49.99
Seagate ST28000NM001C 28TB 256MB 7200RPM 3.5" SATA 6.0Gb/s Enterprise Hard Drive
$669.99
Toshiba 14TB MG07 MG07ACA14TEY 7.2K RPM SATA 6Gb/s 512e 3.5" Enterprise HDD
$299.00
ST6000NM0034 DELL 6TB 7.2K 12G SAS 512E 3.5" ENTERPRISE HARD DRIVE 8D1V4 08D1V4
$54.99
WD Ultrastar DC HC530 14TB SATA 6G 3.5" 7200RPM Enterprise HDD - WUH721414ALE604
$329.99
Seagate 6TB HDD ST6000NM0034 7.2K 3.5" SAS 12Gb/s (NOT FOR PC - FOR SERVER ONLY)
$87.00