Posted by nevermind on Wed 3 Aug 2005 at 13:05
We've covered building a 2.6 Kernel before in the Debian manner, but here's another introduction in case you missed the last one.
Building a 2.6 Kernel on Debian is rather easy, first we need the kernel sourceto apply this, we run the following command:
aptitude -f install kernel-source-2.6.8
This will fetch the kernel source and all needed tools to compile and configure it from debian.
Next we need to unpack the kernel:
cd /usr/src tar xvfj kernel-source-2.6.8.tar.bz2
This will create a directory called "kernel-source-2.6.8" under /usr/src.
Once the source code is unpackaged we can call the kernel configuration menu:
cd /usr/src/kernel-source-2.6.8/ make menuconfig
(If you receive some an error message rather than a build menu you should run "apt-get install libncurses5-dev").
Now we rather than make sure we've matched our kernel configuration with the correct options we can cheat - and take the kernel configuration file from the currently installed version of the kernel. This is done by using the menu to choose "Load an Alternate Configuration File".
The default 2.6 kernel configuration file of the kernel image that comes with Debian Sarge may be found in the directory "/boot".
Simply load the file "config-2.6.8-*-*", where the first "*" stands for the Debian subversion of the kernel, and the second "*" names your system architecture.
(To find out which kernel you are currently running you can run "uname -a").
If you dont want to change anything on the kernel, but just build your own, you may now exit the configuration menu.
When selecting Exit from the build menu you will be asked to confirm your changes. Ensure you select "yes", or they will be lost.
Now we are going to take a look on the debian specific make command for kernel rebuilds, called "make-kpkg".
make-kpkg is a rather simple program, that takes a few arguments, the most important arguments for our use are:
To proceed further we need to choose which kind of compilation we wish to persue:
Do we want to build the whole package? Just the kernel image? The modules Or just a package containing the headers?
A full list of supported targets can be viewed via the --targets option for make-kpkg.
To just build the kernel image and all that is needed for running the kernel and compile custom modules (e.g. nvidia) into it, we issue the following commands:
make-kpkg --initrd --revision examplerev01 kernel_image
During the build make-kpkg will ask you the following question:
Warning: You are using the initrd option, that may not work, depending on your kernel version and architecture, unless you have applied the initrd cramfs patch to the kernel, or modified mkinitrd not to use cramfs by default. The cramfs initrd patch, is included in the Debian supplied kernel sources. New kernels on most architectures do work fine. By default, I assume you know what you are doing, and I apologize for being so annoying. Should I abort[Ny]?
We can safely answer that question with "N", as we do know what we are doing;)
The compilation will take a while, bout 35 minutes on my 1.2ghz AMD Duron, so go and get yourself some air/coffee/cigarette, and listen to some of your favorite tunes. (If you wish to speed up multiple rebuilds you could look at using ccache, or distcc to build across multiple hosts - if you have more than one machine available to you).
When it finishes we can also conitinue to build a matching kernel-headers package - this is needed if you wish to build some custom kernel modules, such as Nvidia drivers, or the gmail filesystem.
make-kpkg --initrd --revision examplerev01 kernel_headers
That command should complete reasonably quickly, as its just packing the headers, that were already built by the first command.
The results of our build steps will be two files in our /usr/src directory, so lets go back to that directory, and look:
kernel-headers-2.6.8_2.6.8-3examplerev01_i386.deb kernel-image-2.6.8_2.6.8-3examplerev01_i386.deb
To install the packages we can use dpkg:
dpkg -i kernel-image-2.6.8_2.6.8-3examplerev01_i386.deb
Answer the questions it asks you with "Yes".
dpkg -i kernel-headers-2.6.8_2.6.8-3examplerev01_i386.deb
To initialize the initrd image we can run:
mkinitrd /boot/config-2.6.8 2.6.8
Thats it. Now all we need to do is to add our new kernel to our bootmanager, in my case lilo. Open /etc/lilo.conf in your favorite text editor, and add something like this to the menu, in case its not already there:
image=/vmlinuz initrd=/initrd.img label=Linux read-only optional
(The new kernel installs itself into /boot directory, and will change the symbolic links in / - so that we can refer to it as /vmlinuz, with the old kernel being refered to as /vmlinuz.old.)
Once you've updated your configuration run "lilo -v" to make it active, and reboot your machine.
[ Parent ]
[ Parent ]
[ Parent ]
Bear in mind that to write to /usr/src/ you will need to be a member of the src group.
(This isn't an issue if you place the source code elsewhere)
Steve
-- Steve.org.uk
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
Great article! Last time I upgraded a Kernel was 2.2 to 2.4 back in college and this really sparked my memory. Now stationed in Korea with my own computer (my wife doesn't have to use it too), I'm back on Linux. I recently did a fresh Sarge (2.4) install (last night, about 1:30am) and want to upgrade to 2.6. I followed your directions only vectoring off a couple times to get some packages that weren't installed. I'm having trouble booting, however.
I'm using GRUB as my boot loader, this is my config in menu.lst:
---------------
title Debian GNU/Linux, kernel 2.6.12.4
root (hd0,0)
kernel /vmlinuz-2.6.12.4 root=/dev/hdc8 ro
initrd /initrd.img-2.6.12.4
savedefault
boot
title Debian GNU/Linux, kernel 2.4.27-2-386
root (hd0,0)
kernel /vmlinuz-2.4.27-2-386 root=/dev/hdc8 ro
initrd /initrd.img-2.4.27-2-386
savedefault
boot
-----------------
I 'customized' the kernel but I am pretty sure I didn't leave out anything that would cause the following error. I am getting this error about 7 seconds into boot:VFS: Cannot open root device "hdc8" or unknown-block(0,0)
Please append a correct "root=" boot option
Kernel panic - not syncing:VFS:Unable to mount root FS on unknown-block(0,0)
As you can see the config in menu.lst is the same for my 2.4 and 2.6 kernels. I can still boot to my 2.4 kernel, thankfully, so I'm confused as to why the error is stating that hdc8 is not the correct root device. I'm assuming hdc8 (/dev/hdc8) is my / partition. Funny, though, because my drive is SATA..shouldn't it be /dev/sda* ?
I appreciate any help I can get. This one has me lost. I may install Lilo so I can work with something I am familiar with.
Thanks,
Steve
SGT Steven Siebert
US Army
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]
[ Parent ]