When dealing with RAID controllers that require lengthy initialization, traditional reboots can be painfully slow. The kexec
system call allows us to load a new kernel into memory and boot it without going through BIOS/firmware initialization.
First verify your system supports kexec:
# Check kexec support
grep KEXEC /boot/config-$(uname -r)
# Install necessary packages
sudo apt-get install kexec-tools linux-image-$(uname -r)
Here's the complete workflow for Debian systems:
# 1. Load the new kernel
sudo kexec -l /boot/vmlinuz-$(uname -r) \
--initrd=/boot/initrd.img-$(uname -r) \
--command-line="$(cat /proc/cmdline)"
# 2. Perform the reboot (takes effect immediately)
sudo kexec -e
For RAID arrays, we need to ensure proper module loading:
# Create custom initrd with RAID modules
sudo mkinitramfs -o /boot/initrd-kexec.img $(uname -r)
# Then specify this initrd in kexec command
sudo kexec -l /boot/vmlinuz-$(uname -r) \
--initrd=/boot/initrd-kexec.img \
--command-line="$(cat /proc/cmdline)"
Create a systemd service for automated kexec reboots:
[Unit]
Description=Load kexec kernel
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/kexec -l /boot/vmlinuz-$(uname -r) \
--initrd=/boot/initrd.img-$(uname -r) \
--command-line="$(cat /proc/cmdline)"
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
If kexec fails, check:
dmesg | grep kexec
for kernel messages- Verify ACPI tables with
acpidump
- Test with
kexec --test
before actual execution
When dealing with RAID controllers that require lengthy initialization periods, traditional reboots become time-consuming. The hardware-level restart forces the RAID controller through its entire POST sequence before Linux can load.
The kexec
system call allows loading a new kernel into memory and executing it without going through firmware/bootloader stages. This means your RAID controller maintains its state while the OS restarts.
# Install kexec-tools on Debian
sudo apt-get install kexec-tools
First, verify your system supports kexec:
grep KEXEC /boot/config-$(uname -r)
# Should return CONFIG_KEXEC=y
Basic usage for immediate reboot:
sudo kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initrd.img-$(uname -r) --reuse-cmdline
sudo kexec -e
For RAID arrays that maintain consistency during soft reboots, consider adding these parameters:
sudo kexec -l /boot/vmlinuz-$(uname -r) \
--initrd=/boot/initrd.img-$(uname -r) \
--append="root=/dev/md0 raid=noautodetect"
If devices fail to initialize properly after kexec:
- Check
dmesg
for hardware-related errors - Try passing specific kernel parameters with
--append
- Verify your initramfs includes necessary RAID modules
Create a systemd service for automatic kexec reboots:
[Unit]
Description=Load kernel for kexec
Before=reboot.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initrd.img-$(uname -r) --reuse-cmdline
RemainAfterExit=yes
[Install]
WantedBy=reboot.target
Typical soft reboot times with kexec:
- Regular system: 5-15 seconds
- RAID systems (without controller reset): 10-25 seconds
- Compared to full reboots (with RAID init): 1-5 minutes