Proxmox 7 fast reboot with kexec?

verulian

Well-Known Member
Feb 18, 2019
169
16
58
44
I'm attempting to synthesize the instructions found here with this as mentioned previously in order to get kexec to work with Proxmox 7 for fast reboots. Some servers I work with have just insane reboot times and this would help dramatically in some situations.

I ended up taking the following steps and am hoping that someone could shed some light onto what is missing or wrong here in order to make this work correctly:

$ nano /etc/systemd/system/kexec-load.service
Code:
# File: /etc/systemd/system/kexec-load.service
[Unit]
Description=boot into into the current pve kernel
Documentation=man:kexec(8)
DefaultDependencies=no
Before=shutdown.target umount.target final.target reboot.target
RequiresMountsFor=/boot

[Service]
Type=oneshot
ExecStart=/sbin/kexec -l /boot/pve/vmlinuz --initrd=/boot/pve/initrd.img --reuse-cmdline

[Install]
WantedBy=kexec.target

$ mkdir -p /etc/systemd/system/systemd-reboot.service.d/ $ nano /etc/systemd/system/systemd-reboot.service.d/override.conf
Code:
[Service]
Type=oneshot
ExecStart=
ExecStart=-/bin/systemctl --force kexec
ExecStart=/bin/systemctl --force reboot

And for good measure:
$ nano /usr/local/bin/normal-reboot
Code:
#!/bin/sh
# File: /usr/local/bin/normal-reboot
mkdir -p /run/systemd/transient/systemd-reboot.service.d/
ln -sf /dev/null /run/systemd/transient/systemd-reboot.service.d/override.conf
ln -sf /dev/null /run/systemd/transient/kexec-load.service
systemctl daemon-reload
reboot

$ chmod 0755 /usr/local/bin/normal-reboot $ systemctl enable kexec-load.service ##### SEE UPDATE DOWN A FEW LINES ##### $ reboot

Any observations / corrections?

UPDATE FROM @juliokele

At the point mentioned above, one can now do the following to start via fast reboot:
Code:
systemctl restart kexec-load.service
systemctl kexec

By doing the following you can simply use reboot to reboot quickly / fast reboot and normal-reboot to reboot fully (normally) such that the hardware reboots:
Code:
systemctl enable kexec-load.service
systemctl start kexec-load.service

"normal" reboot override:
Code:
ln -s /usr/lib/systemd/system/kexec.target /etc/systemd/system/reboot.target

And to change it back, "normal" reboot restore:
Code:
rm /etc/systemd/system/reboot.target
 
Last edited:
Thanks for calling that out @juliokele for direct exec, here is the output:
systemctl kexec
Code:
No kexec kernel loaded and autodetection failed.
Cannot automatically load kernel: ESP partition mount point not found.
 
Ah I see. That seems to have worked I believe! So we need to start kexec-load.service at system start. The process is also labeled as making reboot also initiate this fast restart. Are you aware of how to make this work?

From my impression normal-reboot and a halt and then starting the server back up would be the "right" way to get a full restart after appropriate modifications.
 
apt install kexec-tools

nano /etc/systemd/system/kexec-load.service

Code:
# File: /etc/systemd/system/kexec-load.service
[Unit]
Description=boot into into the current pve kernel
Documentation=man:kexec(8)
DefaultDependencies=no
Before=shutdown.target umount.target final.target reboot.target
RequiresMountsFor=/boot

[Service]
Type=oneshot
ExecStart=/sbin/kexec -l /boot/pve/vmlinuz --initrd=/boot/pve/initrd.img --reuse-cmdline

[Install]
WantedBy=kexec.target

systemctl enable kexec-load.service systemctl start kexec-load.service

"normal" reboot override:
ln -s /usr/lib/systemd/system/kexec.target /etc/systemd/system/reboot.target

"normal" reboot restore:
rm /etc/systemd/system/reboot.target
 
Last edited:
  • Like
Reactions: ph0x
@juliokele thank you - am I missing something? I diff'd the code you shared above but it is no diff from the one I originally posted. Was there supposed to be a change? I think something must be missing.

Thank you for the last three lines that apparently will cause it to use this instead of "normal" reboots now.
 
i tried the instructions posted above, but i get
systemctl kexec
No boot loader entry suitable as default, refusing to guess.
 
i just want to confirm, is reloading the kernel also result in restart of all VM?

i am asking this because i was remote login to my server and installed the kexec, i can switch kernel, but every time i switch it result in all my VM get restarted.

if restart of VM is compulsory then it doesnt save too much time for machine with bios quick boot.
 
i just want to confirm, is reloading the kernel also result in restart of all VM?

i am asking this because i was remote login to my server and installed the kexec, i can switch kernel, but every time i switch it result in all my VM get restarted.

if restart of VM is compulsory then it doesnt save too much time for machine with bios quick boot.
Yes, all VMs and containers must be shut down, basically whole system goes "off" and it switches kernel instead of computer restart.

Very long booting is on servers, when BIOS checks everything and kexec really helps there to skip this.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!