Elouworld

Local boot on old Scaleway instances via kexec

Old instances (e.g. VC1S) don’t have the possibility to run kernel from upstream Linux distribution (you can’t reinstall using EFI), instead they use a kernel provided by Scaleway team, which is not regularly updated.

Fortunately, Scaleway has hidden features in their boot process that allow to run kexec which makes it possible to run the kernel of your choice.

These features are provided by setting tags on the instance in the Scaleway console.

This guide leads you to enable kexec on your instance.

Install a kernel on the server

For Debian:

1
apt install linux-image-amd64

For Ubuntu:

1
apt install linux-kvm # or: linux-image-generic

linux-update-symlinks is ran by APT to create symbolic links on /vmlinuz and /initrd.img.

1
ls -l /vmlinuz /initrd.img

This should point to the kernel that has just been installed in /boot.

Install a network daemon

1
apt install ifupdown

Configure it

Edit /etc/network/interfaces and comment out lines for eth0 interfaces, then add:

1
2
auto ens2
iface ens2 inet dhcp

Edit fstab for mounting disks on boot

Run blkid to get disk UUIDs.

Edit /etc/fstab so it will mount all your disks to the proper mount points on startup:

1
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx	/         	ext4      	rw,relatime	0 1

This step is important or it will only mount /dev/vda as read-only.

If you miss this step, you can still remount it as read-write:

1
mount -o remount,rw /

Check that setup is working

I advise you to disable the services you don’t want to start at boot in your tests, as these could be killed later if you restart your instance on Scaleway console.

1
2
systemctl status # check what units you want to disable
systemctl disable ...

Then install kexec locally:

1
apt install kexec-tools

When it asks whether or not to manage boot process, choose no.

It might be useful to open now the console of your instance (a virtual TTY) on the Scaleway console, to check the output of the boot process, in case of an error. Note that it often stays blank and doesn’t work, but it is very useful when it does.

Be aware that the network interface will be renamed from eth0 to ens2. You might want to update your firewall rules accordingly.

When you are ready, run these two commands and you’ll be logged out of SSH, as kernel runs kexec:

1
2
kexec -l /vmlinuz --initrd=/initrd.img --reuse-cmdline
systemctl kexec

If server seems not responsive or failed to boot, you can restart the server on Scaleway console. Note that as networking service has been enabled, it will probably fail to start and blocks the boot process for 5 minutes. Check the console for when it happens.

Edit Scaleway tags

When you have confirmed that your setup is working, add these two tags to make Scaleway boot process to run kexec by itself:

1
2
KEXEC_KERNEL=/vmlinuz
KEXEC_INITRD=/initrd.img

Add the first tag, press space, then add the second tag, press space again.

Reboot your server (using reboot via SSH) and profit!

Note: if you previously disabled some services, you can restart these now:

1
systemctl enable --now ...

References

Latest edition:

Copyright © 2021, Elouan Martinet (Exagone313) — This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.