LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Linux Answers > Applications / GUI / Multimedia
User Name
Password

Notices


By acidjuice at 2005-02-28 04:57
This is a detailed guide to compiling a new kernel version 2.6.10 under a fresh install of Slackware 10.1.

In my first kernel compiling experiences I still missed some points I believe some newcomers may miss to successfully compiling their new kernel. I am therefore releasing this first 'acid guide' hoping to help out someone, as I was helped by all the kind people of LinuxQuestions. Please do feel free to leave comments on any suggestions / mistakes that you have found in this guide. Forums are all made of this, sharing.

Now for the guide part. For the purpose of this guide, I'll use version 2.6.10 which at the moment of this writing is the latest kernel release.

Note: even though strictly not necessary, if you are doing a fresh install of Slackware I recommend updating the kernel prior doing anything else, on the first boot after installing Slack (i.e. even before you get the X server configured and running). This is useful since many compiles do rely on the current version of kernel and may need to be reinstalled when upgrading it (for instance, NVIDIA drivers need to be reinstalled after a kernel upgrade).

The following are my recommended points to follow. Definitely not exhaustive. One last thing: this worked for me. It doesn't mean that it will work for you. Upgrading a kernel may result in the total mess up of your system (this sound scary: it is however a normal operation done by most linux users; it is here to ensure you are aware of what you are doing).

Before you begin, download the necessary files and save them to /usr/src:

1. Get the kernel 2.6.10 sources
Slackware 10.1 comes with kernel 2.4.29. You therefore need to download the full sources of the new kernel. You can get them here: linux-2.6.10.tar.bz2 (35MB). This is the .bz2 file format, which is more compressed than the tar.gz one.

2. Get a valid kernel 2.6.10 configuration file
At a certain point you will have to configure your kernel. You may start off with a fresh configuration, however I recommend getting a good starting point by downloading Patrick's excellent configuration file: config-2.6.10.

Now let's start the operations. Let's move into the /usr/src directory (where you have put the two files here above) and decompress the kernel 2.6.10 source code:

Code:
# cd /usr/src
/usr/src# tar xjvf linux-2.6.10.tar.bz2
The Kernel 2.6.10 source code will now be found into the directory /usr/src/linux-2.6.10.

Note: as per Linus Torvalds, there's a philosophy that if it doesn't have to be done as root it shouldn't be, in order to reduce error / hacking risks. You may consider compiling the kernel on your local home directory and then su to root to move the compiled files. However, I somewhat tend to believe that having a symbolic link /usr/src/linux to /usr/src/kernel-2.6.10 might be needed by some applications / installs that look for the kernel source, and therefore the fastest / easiest way to proceed is as described here below. If you didn't understand a single word of this, you may just as well ignore this note.

Now, delete the symbolic link 'linux' that is under /usr/src and which points to the old kernel source directory and recreate it to point to the new directory:

Code:
/usr/src# rm linux
/usr/src# ln -s linux-2.6.10 linux
Now the symbolic link 'linux' points to the new kernel source directory.

Move into the directory linux:

Code:
/usr/src# cd linux
Prepare the compiling by removing all eventual precedent files (which you shouldn't have since this is your first compiling, isn't it?) :)

Code:
/usr/src/linux# make mrproper
Now let's start configuring the kernel. There are several tools around, I prefer menuconfig. Start it up:

Code:
/usr/src/linux# make menuconfig
You may now start configuring from scratch, however as I already explained I believe that it is better to load Patrick's configuration file and build on it. In the configuration window, choose the option 'Load an alternate file', an type /usr/src/config-2.6.10 in the box, then click 'ok'. You have now loaded a proper startup configuration file.

Here things can get tricky, since the options that you set here must build the kernel according to the system you are running linux on. Read all available help and be sure to have the correct settings.

Personally, I setup these three additional things:

1. I have an AMD64 processor, therefore under the processors section I select 'AMD64' and leave 'PC-compatible' as architecture.

2. I use SATA disks, therefore I must ensure that these disks are understood by the kernel at boot time or it will not be able to read from it and I would experience a 'Kernel panic' error. To enable SATA support, under Device drivers->SCSI device support I ensure that I have 'SCSI disk' and 'SCSI generic' selected <*> and not loaded in modules <M>. Also, under SCSI Low Level Drivers, I make sure that 'Serial ATA' is <*>, and I ensure that my chipset support is also enabled here (I enabled NVIDIA chipset support since I have a NFORCE one). This is all done since at boot time modules are not loaded yet, therefore I can't have this support on modules (or, as explained, I wouldn't be able to boot).

3. Also, since I've formatted my disks using ReiserFS, I also want to be sure that at boot time the Kernel is able to read from them. To do so, under File systems I enable Reiserfs support <*>.

4. I have a PS2 mouse, therefore I ensure that under Device Drivers I select all the necessary PS2 and serial port support otherwise my mouse will not work.

5. Under the Sound section, I enable ALSA support to allow for my sound card configuration and I ensure to select the driver for my card (SoundBlaster). You may consider in setting this as module <M> instead of compiled into the kernel <*>.

6. Finally, I also enable both OSS options as module <M> which is the module that manages system sounds.

If you do believe that you need to make additional changes, do so. Otherwise, quit and, when prompted, save the file leaving the .config name as it is by default. You have now configured your kernel.

Now, it's time to build the compressed kernel image using the command:

Code:
/usr/src/linux# make -j5 bzImage
You'll have to wait some time here depending on your machine's speed.

Note: -j5 is just an optimization for CPU speed, you may omit this parameter.

After a certain time it will finish, and you will have the kernel image into the directory /usr/src/linux/arch/i386/boot/ (do not browse there for now, stay into the /usr/src/linux directory).

Now let's proceed with compiling and the install of the modules by issuing these 2 commands:

Code:
/usr/src/linux# make -j5 modules
/usr/src/linux# make modules_install
This will take longer, and the modules will be installed into /lib/modules/**kernel version here**.

We will now create a new boot entry for LILO, so that you can boot in your new kernel but keeping the old kernel still available.

First, we need to put the freshly generated System.map, .config and the compiled kernel image bzImage into the /boot/ directory.

To do so:

Code:
/usr/src/linux# cp System.map /boot/System.map-2.6.10
/usr/src/linux# cp .config /boot/config-2.6.10
/usr/src/linux# cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.6.10
Now we need to rename the old kernel image (why we do this will become clear when we recreate the virtual links):

Code:
/usr/src/linux# mv /boot/vmlinuz /boot/vmlinuz-old
Now let's create the new LILO entry, modifying its config file (lilo.conf). Open this file in pico, a very simple text editor:

Code:
/usr/src/linux# pico /etc/lilo.conf
Note on pico: pico is only installed if PINE is installed. If you selected a full install of Slack, you will have it. If not, you may try using 'nano' instead of 'pico', or use any text editor you may be familiar with.

You will see at the end of the lilo.conf file the Windows entry of your boot option, and then the Linux one. Do not touch the Windows entry. We will modify the existing Linux entry and add a new one so that the last two entries of this file look like this:

Code:
# Slack NEW begins
image = /boot/vmlinuz-2.6.10
  root = /dev/sdb5
  label = Slack_2.6.10
  read-only
# Slack NEW ends
# Slack OLD begins
image = /boot/vmlinuz-old
  root = /dev/sdb5
  label = Slack_OLD
  read-only
# Slack OLD ends
Important note: please do use the appropriate root disk instead of the example /dev/sdb5 which is the partition that I use in my system.

Quit pico by pressing Ctrl-X and say yes to save the file, leave default name unchanged (lilo.conf).

Now, let's activate these changes by running lilo:

Code:
/usr/src/linux# lilo
You may now remove the existing symbolic links to the old kernel files:

Code:
/usr/src/linux# cd /boot
/boot# rm System.map
/boot# rm config
/boot# rm vmlinuz
We can now add the links to the new files:

Code:
/boot# ln -s System.map-2.6.10 System.map
/boot# ln -s config-2.6.10 config
/boot# ln -s vmlinuz-2.6.10 vmlinuz
Now these symlinks will point directly to the new compiled files.

We're almost done. Since kernel version 2.6.xx, the file modules.conf is now substituted by the file modprobe.conf, which you normally shouldn't have already, or if you do, it might just as well be empty.

to see if you have it or if it is empty, type:

Code:
/boot# pico /etc/modprobe.conf
and see if the file contains something. Exit pico, typing Ctrl-X. If the file doesn't contain anything, delete it:

Code:
/boot# rm /etc/modprobe.conf
(If you receive an error it is simply because you didn't have the file in the first place).

Now let's create a good file from the new kernel:

Code:
/boot# generate-modprobe.conf /etc/modprobe.conf
Final step. Starting with kernel 2.6 there's a new /sys directory for Plug and Play configuration. Upgrading from previous versions of the kernel, you might therefore not have it. Please ensure that you have a /sys directory, and if you do not have, create one with:

Code:
mkdir /sys
You may now reboot, and at boot select the Slack_2.6.10 option from LILO.

Enjoy.

Roberto Ostinelli.

by masand on Mon, 2005-03-07 23:10
hi there

everthing looks good
but i think it will be a good point to specify here

"3. Also, since I've formatted my disks using ReiserFS, I also want to be sure that at boot time the Kernel is able to read from them. To do so, under File systems I enable Reiserfs support <*>.

that nomatter what FS u use u neecxd to have ext2 Filesystem support in ur kernel
since this is required while booting

also why are u using "-j5" in the make bzImge command


regards

by acidjuice on Tue, 2005-03-22 06:58
hello masand,

are you sure you need ext2 even on all reiser disks? if so, i will modify this guide.

to answer your question, the -j5 is just an optimization for CPU speed.

cheers,

aj.

by masand on Tue, 2005-03-22 09:48
hi there

yes u need ext2 fs support as well because linux first mounts as ext2 then it remounts it as reiserfs

u can check this after removing support for ext2 fs in ur kernel and it won't work

regards

by acidjuice on Wed, 2005-03-23 08:15
hi,

thanks for this, however i can't modify the guide anymore. i'll keep this however.

cheers,

aj.

by Komakino on Fri, 2005-03-25 18:46
Hey, just read your article to see how similar your experience was to mine.

One comment:

You say to delete the /usr/src/linux symlink and replace it with one pointing to the new source. This is BAD!! According to linus /usr/src/linux should point to the kernel headers that glibc was compiled against, not those of the running kernel.

Programs will still link (or whatever) to the right headers because they will use uname -r to find the right directory, i.e.:
Code:
cd /usr/src/`uname -r`/

by hameedkhan on Mon, 2005-03-28 10:03
Hi,
Thanks for your guide. One thing that I really didn't understand is why do we need /sys? What if I'll not make this dir? Will my kernel not work? What is the use of this dir?

Thanks,
Hameed U. Khan

by acidjuice on Fri, 2005-04-01 04:45
Quote:
Originally posted by Komakino
This is BAD!! According to linus /usr/src/linux should point to the kernel headers that glibc was compiled against, not those of the running kernel.

Programs will still link (or whatever) to the right headers because they will use uname -r to find the right directory, i.e.:
Code:
cd /usr/src/`uname -r`/
i guess no real harm done then...

but this is still strange to me, 95% of all users compiling kernel DO use this method. there are metropolitan legends about this symlink... i guess it's the most discussed symlink ever

any opinions on this welcomed.

cheers,

aj.

by acidjuice on Fri, 2005-04-01 04:50
Quote:
Originally posted by hameedkhan
Hi,
Thanks for your guide. One thing that I really didn't understand is why do we need /sys? What if I'll not make this dir? Will my kernel not work? What is the use of this dir?

Thanks,
Hameed U. Khan
Starting with kernel 2.6 there's a new /sys directory for Plug and Play configuration. upgrading from previous versions of the kernel, you might therefore not have it there.

by michaelsanford on Tue, 2005-04-12 12:40
I've just built 2.6.11.7 using a similar method, reiserfs, SATA and all (we have very similar setups).

I'm running an AMD64 3500+ (on an nVidiva nForce 3-based motherboard) and recently tried to install an app that was designed for x86_64, which is my system, right?

For some reason the program (nVidia motherboard drivers) reports that this is really a 32 bit kernel. Did I forget to check something off when I built it, or should I have built a different target (like `make bzImage x86_64` or something)?

uname -a
Code:
Linux gateway 2.6.11.7 #1 Mon Apr 11 17:18:24 EDT 2005 i686 unknown unknown GNU/Linux
GREAT how-to by the way!

by r_x on Wed, 2005-05-04 06:10
this was cool...............
i upgraded my slack box from 2.4.29 to 2.6.11.8 .............
add that 1 more step in the end...................removing the old kernel when the new one fires up


  



All times are GMT -5. The time now is 05:41 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration