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:
- Linux Kernel – Compiling the Kernel: a fairly outdated tutorial, yet the ore stuff didn’t change much
- Compiling the kernel: found nice stuff about make dep, make bzImage, etc here. The previous page, “How to actually configure the kernel”, is pretty interesting too
- How to: Compile Linux kernel 2.6: that’s where I found the obvious (but you need to think of it first!)
make install
- Stackoverflow – How do I get the correct .config file for compiling the Linux kernel source specific to my hardware?
- The Linux 2.4 SCSI subsystem HOWTO – Chapter 4. Kernel Configuration: not a lot here, just interesting about the different config creation tools
- Appendix A – Creating initrd.img file (seems to be useless now but mentioned for the historical interest)
- OVH: Comment installer un noyau OVH et booter le serveur depuis votre disque dur ? (French) English version here.
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.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.