Skip to content

Instantly share code, notes, and snippets.

@sandip4n
Last active April 10, 2021 18:38
Show Gist options
  • Save sandip4n/470f332f2b8b0bdf8584b6108766813f to your computer and use it in GitHub Desktop.
Save sandip4n/470f332f2b8b0bdf8584b6108766813f to your computer and use it in GitHub Desktop.

For building on a POWER server running GNU/Linux. First, clone the Linus Torvalds' kernel source tree.

$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
$ cd linux

To be on the safe side, use one of the standard distro-provided build configurations.

$ cp /boot/config-$(uname -r) .config

The config (and also the total build time) can be trimmed down by only building modules that are currently in use. This also makes sure that the modules are built into the vmlinux binary itself.

$ make localyesconfig

Start building the kernel. You might initially be asked to choose to enable any new options and features that were recently introduced and not configured in the current .config. Choose the recommended default in such cases by simply hitting enter.

$ make -j $(nproc) vmlinux headers_install modules
$ sudo make modules_install

Note the version number right beside DEPMOD in the last-ish line. Use that to build the initrd image.

$ sudo mkinitrd initrd.img-<version> <version>

Now use kexec to quickly switch over to the new kernel without having to fully install the kernel or reboot the system.

$ sudo kexec -l vmlinux --initrd initrd.img-<version> --command-line="$(cat /proc/cmdline)"
$ sync
$ sudo kexec -e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment