Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: How to reboot using kexec? #774

Open
Forza-tng opened this issue Feb 2, 2025 · 0 comments
Open

Q: How to reboot using kexec? #774

Forza-tng opened this issue Feb 2, 2025 · 0 comments

Comments

@Forza-tng
Copy link
Contributor

Forza-tng commented Feb 2, 2025

Hi,

I note that openrc-shutdown supports --kexec option. Does it mean it is possible to load a kernel and initrd and then have openrc call kexec to boot the loaded kernel instead of doing a normal reboot? If so, how can I enable this option?

I tried calling openrc-shutdown manually, but that does not work. It says it will reboot, but nothing actually happens.

# openrc-shutdown -v --kexec now
Broadcast message from root@static (pts/0) (Sun Feb  2 18:16:31 2025):
The system will reboot now

Using Gentoo with openrc-0.55.1

For now I created a service kexec-boot that I added to the shutdown runlevel.

#!/sbin/openrc-run
description="Execute kexec if a kernel is preloaded, otherwise do a normal reboot"
depend() {
    after *
}
start_pre() {
    if yesno ${RC_REBOOT}; then
        if [ -f /sys/kernel/kexec_loaded ] && [ "$(cat /sys/kernel/kexec_loaded)" -eq 1 ]; then
                einfo "Executing kexec..."
            sleep 10
                kexec -e
                eerror "kexec failed, proceeding with normal reboot"
        fi
    fi
}
status() {
    if [ -f /sys/kernel/kexec_loaded ] && [ "$(cat /sys/kernel/kexec_loaded)" -eq 1 ]; then
        einfo "A kernel is loaded for kexec"
    else
        einfo "No kernel is loaded for kexec"
    fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant