Skip to content


How to compile (and install) the latest Linux kernel for an OVH server

Not a step by step tutorial this time, because if you can’t figure it out with those pointers probably you shouldn’t be compiling your own kernel anyway. Using Debian 7 here. And (obviously) kernel 3.9.2. Change numbers if appropriate, of course.
Edit: on Debian 6, you’ll need to install package lzma first. And maybe to move around bzImage (cf later) yourself, although I’m not sure this is really necessary.

First install the required compilation stuff:
apt-get install gcc make

Grab the kernel sources from https://www.kernel.org/. Last time I tried, Debian didn’t like the HTTPS certificate so I had to download from the FTP (for instance kernel 3.9.2 is there: ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.9.2.tar.bz2).
wget ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.9.2.tar.bz2

Grab the config file from OVH. It should prevent you from making stupid choices when configuring. There are a few different ones to choose from, on a dedicated server you’ll probably want ftp://ftp.ovh.net/made-in-ovh/bzImage/3.8.13-2/config-3.8.13-xxxx-grs-ipv6-64 (but if you want to pick others, just browse the folder, they’re all here).
On a side note, the config file from your distribution should be in /boot/ (for me it was /boot/config-3.2.0-4-amd64). If you’re on OVH, their config file is most likely much more appropriate, but if you’re elsewhere, the config file they left you here is probably your best option.

Pretty self-explanatory steps then:
tar xf linux-3.9.2.tar.bz2
cd linux-3.9.2
wget ftp://ftp.ovh.net/made-in-ovh/bzImage/3.8.13-2/config-3.8.13-xxxx-grs-ipv6-64

Now in order to use the custom config, simply copy it to linux-3.9.2/.config:
cp config-3.8.13-xxxx-grs-ipv6-64 .config

That’s about it. Now you can just run make or make bzImage (but before that, maybe you’ll want to run make dep to check for missing dependencies – which I didn’t, with no issue). It will still ask a bunch of questions the first time. I started by reviewing them, then got bored and just went ahead accepting default choices, which seemed globally good (most of them default to “No”, so rushing there shouldn’t cause to much junk).

It may take a little while (say, about 15-20 minutes on a cheap dedicated server – by this I mean, some dual core better than an Atom or Celeron).

When it’s done, you need to grab linux-3.9.2/arch/x86/boot/bzImage, which is the kernel, and linux-3.9.2/System.map, which is some mysterious kernel symbol table. Although this is probably enough for OpenSUSE (I didn’t check, but that’s all I could find in the /boot folder of my OpenSUSE installation), on Debian you’ll probably also need linux-3.9.2/vmlinux. Just copy them into /boot. For the sake of clarity, maybe rename them to bzImage-3.9.2 and System.map-3.9.2.
Actually, no need for this manual mayhem. Just run make install and all needed files should go to their rightful place (notably the initrd.img file which i wasn’t able to find). Doing so will even run update-grub, so basically you’re then ready for reboot (disclaimer: if it fails, I’m not responsible, this is a tutorial for experimenting, not for production).

(!) OVH only: if you had your server configured to use the OVH kernel, you may need to go to /etc/grub.d and then rename 06_OVHkernel to, for instance 16_OVHkernel (it should start with a number higher than 10 and lower than 20), otherwise priority will be given to the OVH kernel instead of yours. Then run update-grub (or grub-mkconfig) again.

Don’t forget to make a copy of your updated .config file. When the time comes to install the next version, it will save you some time to start from this updated version rather than from your previous version!

Bonus: you can create your very own kernel version by editing CONFIG_LOCALVERSION in .config 😉

Sources:

Update (2013-05-21): due to some pretty severe bug, this will probably fail at make install (or update-bootloader) on OpenSUSE 12.2 and 12.3.

Update (2013-05-29): it turned out that my issue getting the sources from HTTPS was that I was missing the certificates package. apt-get install ca-certificates did the trick.

Posted in Linux, servers.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA