Compiling the Linux kernel

I've always had tons of trouble trying to get kernels compiled.  But today I successfully compiled the 2.4.22 kernel from kernel.org, on my Via EPIA ME6000 mini-itx motherboard, which has a built-in Via Eden 600MHz fanless processor, and on-board sound, video, networking, USB2, and Firewire.  I also have 256MB of DDR RAM and a 40gig IBM Travelstar notebook hard drive in the system, and it's running Slackware Linux 8.1.

Here's some more technical info about the chips on the motherboard, from the text printed on the chips themselves, and/or from the manual:

VIA CLE266 - northbridge
VIA VT1622/M  - (Macrovision) TV-Out Controller
VIA VT8235 - southbridge
VIA VT6307S - firewire
VIA VT6103 - ethernet
VIA VT1616 - six channel AC'97 Codec

So, here are the steps I took, as root.  I basically followed the instructions at http://www.tldp.org/HOWTO/Kernel-HOWTO/quick_steps.html, but I had to change a few things and do more once that was all done.

Note: one common reason to recompile the kernel is when you need to apply a patch to it. To do that, save the patch to the /usr/src directory (as root), then run zcat <patch-name>.gz | patch -p0 -E to apply it.  After it's done, run find /usr/src/linux -name '*.rej' -print which will show you any parts of the patch that got rejected.  If nothing got rejected, then the patch was successfully applied, and you can now recompile your kernel. (Source)

  1. download the kernel to /usr/src/linux-2.4.22.tar.bz2, and cd to /usr/src if you're not already there

  2. tar jzf linux-2.4.22.tar.bz2 to unpack it

  3. rm /usr/src/linux to remove the existing soft-link to the old kernel source directory (/usr/src/linux-2.4.18)

  4. ln -s /usr/src/linux-2.4.22 /usr/src/linux to create /usr/src/linux as a soft-link to /usr/src/linux-2.4.22

  5. mv /usr/src/linux/.config /boot/config-old to save the old .config file, just in case you might want to recompile the old kernel again with the same options you used before

  6. cd /usr/src/linux

  7. make clean; make mrproper; make clean

  8. make menuconfig and go through the menus to choose the options you want. If you already have a .config file that you want to start from, load that (with "Load Alt Config File" towards the bottom of the options list) before making any changes.

    If unsure about any given option, configure it as "M" (a module) instead of "*" (built-in to the kernel). When you're done, exit, and it will ask you if you want to save your configuration -- say yes, and it will save it to /usr/src/linux/.config for use by the make commands.

    Some notes about my specific setup here: I chose i386 as the processor architecture after reading http://www.viaarena.com/?PageID=193.  I specifically did NOT install any i2c support, because I planned on installing the lmsensors package later (which allows you to read the temperature/fan/voltage sensors on your motherboard), and the current version specifically says to leave i2c out of your kernel, so you can then install the lastest version of it when you install lmsensors.  Other than that, I just made sure to set my ethernet driver (via-rhine) and sound driver (via82cxxx_audio) as modules, and to set USB and USB-hid as built-in to the kernel, because I have a USB keyboard.  Oh, and I also had to specifically enable support for my VIA IDE controller, otherwise I couldn't use DMA-access, so I could only transfer data at about 3.5 MB/s instead of the ~25MB/s I get with DMA enabled (using hdparm to set/check transfer rates and the DMA settings).  Finally, in order to get decent fonts and high(ish) resolution at the console, you need to enable the "Prompt for development and/or incomplete code/drivers" option, and then enable "Console drivers > Frame-buffer support > VESA VGA graphics console", as well as any other options under Frame-buffer support (like specific fonts) you might want.

  9. make dep

  10. make bzImage and make modules can be done simultaneously in two different consoles. This will create /usr/src/linux/arch/i386/boot/bzImage and will compile the modules (but not install them).

  11. make modules_install will put the modules into /lib/modules/2.4.22/kernel/ subdirectories.

  12. cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.myker will copy the kernel into a place from which it can be loaded at boot.

  13. cp /usr/src/linux/.config /boot/config-anthony-2.4.22 in case I want to compile the kernel again with these same options, or similar options.  (If I do, then I just repeat the steps on this page, except during the make menuconfig step, I use its "load alternate configuration" option to load /boot/config-anthony-2.4.22 before making any changes to the setup.)

  14. cp /usr/src/linux/System.map /boot/ -- this file apparently contains address info that programs need when printing diagnostic/error messages.

  15. edit /etc/lilo.conf and add a new section, below the existing one(s):
    image=/boot/bzImage.myker
      label=myker
      root=/dev/hda1
      read-only
    
    I also had to edit the line that said vga=773 and change it to vga=ask, or else I just got a blank screen after lilo loaded the next time I rebooted.  (You can also just type "myker vga=ask" at the lilo boot prompt when you reboot.)

  16. run lilo one time, to enable the changes you made to lilo.conf.

  17. Reboot, and hold the left-shift key before/while lilo loads.  This will give you a lilo prompt (if you didn't get one already, by default) where you can type myker <ENTER> to boot your new kernel.  You'll then get prompted to choose a video mode; you should probably type scan <ENTER> which will automatically check which ones you can use, and present you with a list.  When you find one that you like, set your vga= option in /etc/lilo.conf to it (I set mine as vga=0xf01).

  18. If your system books ok, then you won.  Edit /etc/lilo.conf again, and move your new section above the existing section(s), to make it the default.  Run lilo again to apply the changes, then reboot, and you're done.

    If it doesn't boot properly, then reboot, hold left-shift, and choose your old kernel.  You can try to repeat all these steps again; the problem is most likely the result of something you set or didn't set during the make menuconfig step.  It might take a little trial and error till you get it right.