I'm reading Robert Love's Linux Kernel Development in order to learn more about, well, Linux kernel development!

But in Chapter 2: Getting Started with the Kernel, I'm instructed to download and install the kernel. This confuses me. "Building the kernel is easy", he says. Yet the thought of installing a Linux kernel inside a Linux environment doesn't make sense to me- as if I'd be running this new Linux virtually?

The steps he gives are to obtain the kernel source

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
$ git pull

Then decompress the tarball (two different methods in case it's GNU zip but here's the bzip2 method),

$ tar xvjf linux-x.y.z.tar.bz2

Then from there you build the kernel by running make on menuconfig, deconfig, oldconfig, etc.

Then you install the new kernel. He explains that the install is "architecture and boot-loader-dependent" and to "consult the directions for [my] boot loader on where to copy the kernel image." He then provides an example of where one might copy the image and then to run

$ make modules_install

and then the chapter simply goes no further on this tutorial of installing the kernel.

This is where I'm lost. Up to this point I understand all of the commands so far (I've been using Fedora for a few years, writing system code in C, etc.) but I don't understand this concept of "installing" the the Linux kernel in my already Linux environment. There's no explanation of what's going on here (maybe he goes into detail later) or how to actually get the kernel running. Do I put it on a new hard drive? Do I run in like a VM? Do I choose some boot-up option in BIOS? How do I actually run it? This step is not in this chapter, nor in Chapter 3 or 4.

  • 1
    It goes in /boot, then you update your boot loader (e.g. grub) to use it, then reboot. – Mikel May 6 '16 at 0:30
  • @Mikel Do I then select the Linux version to use? More specifically, do I have to worry about my existing copy of Fedora (or its contents)? – 8protons May 6 '16 at 0:31
  • 1
    See also unix.stackexchange.com/questions/198003/… – Mikel May 6 '16 at 0:32
  • 1
    You can usually use a custom kernel on your existing Linux distribution. Configure it as an additional entry in GRUB, then you can choose. – Mikel May 6 '16 at 0:34

make install simply copies the kernel image to the /boot directory. make modules_install copies the modules to /lib/modules/kernel-version/. Most linux distributions these days boot using grub, so you need to run update-grub to notice the new kernel image in /boot, and add an entry to boot it to the grub configuration file so you get the option to boot using that kernel. Typically you also need an initrd containing modules needed to access boot hardware and some boot scripts, and at least on Debian based distributions, you can generate this by running update-initramfs -k kernelversion, prior to running update-grub.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.