Created
September 1, 2023 05:15
-
-
Save jvyden/649fe491987344fa783172da5e9492ac to your computer and use it in GitHub Desktop.
A script to softly reboot a Linux system with kexec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$EUID" -ne 0 ]; then | |
echo "This script requires root." | |
sudo $0 | |
exit | |
fi | |
if [ "$1" == "complete" ]; then | |
systemctl stop graphical.target | |
killall -9 -u jvyden | |
sleep 0.5 | |
modprobe -r nvidia_drm | |
kexec -e | |
fi | |
# load kernel here, might as well do something before we switch away | |
kexec -l /boot/vmlinuz-linux-zen --initrd=/boot/initramfs-linux-zen.img --reuse-cmdline | |
# defer this to another systemd session so we don't get ourselves killed | |
systemd-run /usr/bin/soft-reboot complete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment