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.
debootstrap
or other command to load the target partition with an other system. If you do it, you will be able to typechroot /mnt
and be able to useupdate-initramfs
. Note that some directory should be mounted to some of the/mnt/*
(dev, sys, proc). If you don’t want an other copy of Debian, grub should manage other kernel in its/boot
directory. – Frédéric Loyer Nov 11 '21 at 11:32debootstrap
. What does it do exactly? I haven't seen it referenced in any of the articles I have read (e.g. https://www.cyberciti.biz/tips/compiling-linux-kernel-26.html, https://phoenixnap.com/kb/build-linux-kernel, https://unix.stackexchange.com/questions/115620/configuring-compiling-and-installing-a-custom-linux-kernel, etc). – festiv Nov 11 '21 at 11:38apt
system and can load other package afterwards. It can be useful to build container images. As a Debian system it may not be minimal is the way you think. Note : the initramfs is needed for kernel with complex booting procedure (root on RAID filesystem). For a minimal system, you don’t need it. – Frédéric Loyer Nov 11 '21 at 11:53debootstrap buster /mnt
… and you get a minimal system on/mnt
. It doesn’t install the kernel, but you have installed it there.Now, add an entry in grub to load the kernel, and use
– Frédéric Loyer Nov 11 '21 at 14:39/dev/sda2
as root.