That question: Compiling and installing a kernel.org kernel to a custom volume on disk partially answers my question, however, not completely!
I have a disk with 30GB capacity. It has 2 partitions
- 2GB partition (
/dev/sda1) which contains Debian - 28GB partition (
/dev/sda2) which is completely empty (formatted, filesystem isext4)
I want to compile and install kernel.org kernel (https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.78.tar.xz) on /dev/sda2 and setup dual boot between my Debian and new kernel
So far:
I mounted my second partition to /mnt (i.e. mount /dev/sda2 /mnt) and created a directory /src within it (i.e. I have /mnt/src directory)
When in /mnt/src,
I downloaded the kernel and extracted it
wget --no-check-certificate https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.78.tar.xz
unxz -v linux-5.10.78.tar.xz
tar xvf linux-5.10.78.tar
I also installed the necessary tools to be able to compile and install the kernel
apt-get update
apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
When in /mnt/src/linux-5.10.78
I copied my existing Debian kernel configuration to the current directory (i.e. cp -v /boot/config-$(uname -r) .config) and then ran make olddefconfig (with the idea to use my existing configuration and provide default values for everything else). I also unchecked the Avoid speculative indirect branches in kernel option because I hit You are building kernel with non-retpoline compiler, please update your compiler.. Stop. during make.
I then ran make -j 4 again and waited for it to finish.
After that I ran INSTALL_MOD_PATH=/mnt INSTALL_PATH=/mnt/boot make modules_install to install the necessary modules, following the suggestion from the question I have linked above.
My problem is that now when I run update-initramfs it fails as it can't find a /lib/modules/5.10.78 folder. That would obviously be the case as it is under /mnt/lib/modules/5.10.78. I tried providing different root path (using the -b option) but that didn't work. I also tried chroot, however, I don't really have the necessary setup/ executables in /mnt to chroot into it.
After "fixing" above, I expect running update-grub would discover the kernel image, the root filesystem for booting it and the configuration files and setup everything so that after reboot I am provided with both booting options (Debian and the new kernel).
Any help with both update-initramfs and the actual grub configuration afterwards would be greatly appreciated! I have found links here and there but they are always very high level overview of the process.