kexec-alpine
kexec is a Linux system call that allows you to load and boot another kernel from the currently running one.
In this guide we will see how to boot Alpine Linux with kexec from Debian 13 (trixie).
Warning: do NOT try this on your main system! Use a virtual machine or a disposable test system instead. Your system can become unbootable if something goes wrong. I am NOT responsible for any data loss, system breakage, or any other damage that may result from following this guide.
Download the Alpine Linux ISO file. In my case I chose the virt flavor because I'm testing in a VirtualBox VM. Then mount it:
Copy the boot and apks directories from the ISO to a filesystem that will be directly accessible by the new kernel at boot time, i.e. that does not depend on LVM, encryption, or other userspace setup.
In my case the root filesystem (/) is a plain ext4 partition, so copying to / works fine for me, but your setup may be different. For example, if you use LVM for / and have a dedicated /boot partition, you could copy to /boot instead.
| Bash | |
|---|---|
Make sure you have the kexec command available on your system:
| Bash | |
|---|---|
Then run the following:
| Bash | |
|---|---|
At this point, Alpine Linux should start.
Note that, if you want it running completely from RAM now, you should stop all the services that may use the disk, such as modloop:
| Bash | |
|---|---|
To check that no disk is used anymore, you can use the mount and df -h commands.
At this point you can do whatever you want with the disks, such as installing another OS:
Warning: the following example
ddcommands overwrite EVERYTHING on/dev/sda! Unrecoverable data loss will occur.
| Bash | |
|---|---|
Note: the
curlcommand and\ordd'sstatus=progressoption might be unavailable by default on Alpine Linux.
Or even writing a netboot installer ISO to the main disk, so that you can perform a regular guided installation at reboot:
| Bash | |
|---|---|