Kernel installation

If you’ve been following along, you should now have configured and compiled the kernel. The next step is to install all the files you just created into the correct place. That’s what we will do here.

When you configured the kernel, there is likely (almost definitely) to be a lot of the code configured to be built as modules. That is, chunks of code that can be loaded into (or removed from) a running kernel. These need to be put somewhere where the kernel can find them later, and this is done using the make utility.

sudo make modules_install

Note that this command will move files into a folder owned by root, and so must be executed with sudo.

From this point there are two different ways to finish installation of the kernel.

The easy way (only applicable to non-Arch users)

If you’re not using Arch Linux, then this part is very easy. In fact, with one more command you can complete the entire process, allowing you to skip the remaining steps.

sudo make install

In the case where this worked, then congratulations! All you have to do now is reboot into your shiny new kernel!

If not, then do not fear — follow the next few steps to get things going.

The not-so-easy-but-not-so-hard way

The last step here is to move the kernel image into the /boot folder, and you have to be a little careful with that. Since /boot is owned by root you will have to do this with sudo, and because of this you have the power to accidentally overwrite anything in that folder. Including the running kernel. BE CAREFUL!

To protect against this, one technique is to use the string that you set for CONFIG_LOCALVERSION when you configured the kernel compilation. This can be done by fishing the value of that config option out of the .config file, and storing it in a variable.

ext=$(grep CONFIG_LOCALVERSION= .config | cut -d \" -f 2)

Then append this on to the filename when you copy the kernel image to /boot.

cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-linux$ext

Note that this command assumes that you are using the x86_64 architecture like me. If not, make the appropriate change to that command.

Cool! You now have (almost) everything built and put in the right place. Only a couple more steps to go before you can reboot into your shiny new kernel.

Leave a comment

2 thoughts on “Kernel installation