# Upgrade Kernel HOWTO (For Dummies)

## G2k

Ok, since I can't find a good solid tutorial on this that gives clear steps on how to do this, I decided to come up with this HOWTO. I'll try to be as throughrough as possible for all the n00bs out there  :Wink: , don't worry we've all been there. Comments are welcome.

To begin with, assuming you use Gentoo, you have to get the Kernel source. There are many types of kernels out there such as:vanilla-sources (the default kernel maintained by the godfathers of linux)

development-sources (more recent kernel. Maintained by godfathers of linux)

gentoo-sources (the stable kernel sources maintained by the gentoo staff. Basically a patched version of vanilla-sources)

gentoo-dev-sources (also stable but considered to be a bit more on the edge. Has many patches and fixes and uses a more recent kernel. Also this is maintained by gentoo staff)

And there are many more such as nitro-sources and whatnot. If you are a newbie, it is probably a good choice to go with either gentoo-sources or gentoo-dev-sources. It's a matter of taste and hardware needs.

I'll assume you use gentoo-dev-sources throughout this tutorial.

First off, download the kernel source:

```
emerge -av gentoo-dev-soures
```

Then, you will want to remove the symlink in /usr/src that points to your current kernel and make it point to the new one.

```
cd /usr/src

rm -i /usr/src/linux

ln -s <new-linux-kernel> /usr/src/linux
```

where new-kernel is the name of the kernel source you want to use. If you are unsure about what the name of the new kernel is, type `ls /usr/src` and you will see a listing of the kernel sources you have on your computer. You will want to put the name of the one you just emerged/downloaded.

Next, since we are not reconfiguring the whole kernel from scratch but using the settings of our current kernel to configure the new one, you will want to copy the old configuration file into whereour new kernel source is.

```
cp /usr/src/<old-linux-kernel>/.config /usr/src/<new-linux-kernel>

cd /usr/src/<new-linux-kernel>
```

This has copied the configuration file, but actually done nothing. Here comes the fun part.

Now you will want to tell the computer to use the old configuration file to set up the new kernel.

```
make oldconfig
```

The settings that are there from before will be set automatically. If it sees differences or new options however, it will prompt you on whether to add the support for that specific thing or not. It is usually safe to go with the default value (the capital letter.) If you are unsure about an option you can type '?' to see its information.

Repeat this until it finishes.

Optional

If you want to check the settings and see if everything is correct, you can run

```
make menuconfig
```

 (or xconfig if you prefer) and see that the kernel suits your needs.

---------

Now it is time to compile and install the kernel. 

For those who use a 2.4 kernel, type

```
make dep && make bzImage modules modules_install
```

For those who use a 2.6 kernel

```
make && make modules_install
```

Now run

```
mount /boot
```

in case you haven't already. If it was already done then automatically your old kernel will be called vmlinuz.old while the newly created one will be called vmlinuz. This is an added advantage for those of you who do not want to touch your bootloader's configuration file. It might be handy to leave your bootloader with two options: one that points to vmlinuz and the other to vmlinuz.old so you never have to make changes to the file. Linux is made for lazy people  :Very Happy: , can ya tell?

If it was already mounted, skip the next step, else do

```
cp arch/i386/boot/bzImage /boot/<new-linux-kernel>

cp System.map /boot/System.map
```

Now you'll want to edit your bootloader accordingly.

If you use GRUB, use your favorite editor to edit the grub configuration file

```
nano -w /boot/grub/grub.conf
```

If you use LILO

```
nano -w /etc/lilo.conf
```

In both cases you will have to add the name of the new kernel you are using to the options.

If you have lilo, run

```
/sbin/lilo
```

Now it is safe to unmount your boot partition with

```
umount /boot
```

If you have an nvidia card or are trying to load any specific separate module when your computer starts, make sure that that module will work. For nvidia users,

```
emerge -av nvidia-kernel
```

 To see what modules you are loading at boot time, type

```
cat /etc/modules.autoload.d/kernel-2.x
```

where 'x' is the subversion of the kernel you are using.

Reboot and cross your fingers  :Wink: 

If you have successfully rebooted, then it is safe to remove the old kernel (if you no longer need it.)

To do this, simply

```
emerge -aP gentoo-dev-sources

#assuming u used gentoo-dev-sources; adjust accordingly

cd /usr/src && rm -rf <old-linux-kernel>

cd /lib/modules && rm -rf <old-linux-kernel>

mount /boot && cd /boot && rm <old-linux-kernel-bzImage>
```

P.S.

I know that this mini howto may be redundant as it has been answered tons of times in the past but I just had to write it...also for future friends of mine who are new to linux, at least they will have a solid place to start. I hope I was thoughrough enough.

----------

## dsd

did you look very far?

http://www.gentoo.org/doc/en/kernel-upgrade.xml

 :Wink: 

----------

## G2k

heh...didnt see that to be honest but it doesn't talk about using .config i believe...well...it's not a waste of time on my behalf, now at least if someone searches the forums they're bound to find this one (hopefully of some use)

----------

## dsd

being the one that all bugs end up at, i really discourage the use of make oldconfig in most situations.. (no time to explain now, but it does cause problems, usually user errors that would be avoided if they hadnt of used the use-old-config hack...)

i have been meaning to add details of when it is ok to use it, but have not had a chance yet

----------

## G2k

how can anyone possibly remember all the settings he puts besides the ones that the gentoo handbook already tells you to put? i'd never remember adding support for my printer, USB stick, ethernet card, floppy support, windows support, alsa.....blah blah, yadda yadda, you get the idea. I find oldconfig quite convenient to be honest.

----------

## FrodoNL

 *G2k wrote:*   

> how can anyone possibly remember all the settings he puts besides the ones that the gentoo handbook already tells you to put? i'd never remember adding support for my printer, USB stick, ethernet card, floppy support, windows support, alsa.....blah blah, yadda yadda, you get the idea. I find oldconfig quite convenient to be honest.

 

I usually just use a bit of dead-tree to print my current .config on. Then I just start from a clean config.

----------

## feld

I mount /boot first and then to make the kernel I

make && make modules_install install

and it will automatically put the kernel in /boot and name it

vmlinuz-linux-#.#.##-(-name if applicable)-revision

-Feld

----------

## G2k

said that already  :Wink: 

----------

## xianx

 *dsd wrote:*   

> being the one that all bugs end up at, i really discourage the use of make oldconfig in most situations.. (no time to explain now, but it does cause problems, usually user errors that would be avoided if they hadnt of used the use-old-config hack...)
> 
> i have been meaning to add details of when it is ok to use it, but have not had a chance yet

 

Hey dsd, can you post some details of make oldconfig issues when you got the time? I would very much appreciate it.

----------

## feld

 *G2k wrote:*   

> said that already 

 

uhhh... where does it say that in your tutorial?

NOTICE:

make && make modules_install install

theres another INSTALL at the end.

like I said, it COPIES OVER your kernel, system map, and .config for you. In YOUR tutorial, you have them do this manually. If the files already exist, it renames them to*.old first.

-Feld

----------

## G2k

but i mentioned it in my tut  :Wink:  read and you'll see...maybe i should add a whole part that shows how to do it?

----------

## dsd

ok, here's why i dont like make oldconfig:

if you take a 2.4 config and run it through make oldconfig on 2.6 sources you usually get an unbootable kernel (no keyboard input, no vga output, ...)

you'd think its fairly obvious that you cant do this effectively, but people do it...

there are other cases, in less major kernel incrementations, where using "make oldconfig" causes you problems. heres just a few examples:

CONFIG_LOCALVERSION (introduced in linux 2.6.9) - this allows you to choose something to add to your version string. so setting this as "-dsd" would give me a "2.6.9-dsd" kernel. the problem was that the thousands of "make oldconfig" users interpreted this as a y/n/m question and produced kernels such as 2.6.9-gentoo-r1n (notice the added 'n')

at the time, portage did not support localversion, so when installing external modules (e.g. nvidia-kernel, ati-drivers) it installed them to /lib/modules/2.6.9-gentoo/ and as such, modprobe couldnt find them, so thousands of oldconfig users filed bugs about nvidia being broken / a random y being appended to kernel string / etc. nobody who used menuconfig experienced this.

another example is the FAT codepage/charset options which were introduced in 2.6.9 (i think). it seems that most of the oldconfig users decided that they didnt need codepages or character sets and said 'n' to those questions. they then booted up, tried to mount a fat partition, and couldn't, so created hundreds of forum threads about it. "make menuconfig" users either didnt see the options (hence accepted the working defaults) or saw the options in their full context and realised their importance.

take CONFIG_INITRAMFS_LIST, also introduced recently. a string parameter that was introduced recently. it takes the path to a file, but oldconfig users decided to reply "y" or "n" to it and were very confused when their kernel build failed with "couldnt find file: y"

another example, the "UB" low performance USB storage driver. this was experimental and quite broken in 2.6.9, many users ran into problems, most of which who were the oldconfig users. menuconfig users either hadnt noticed the new option, didnt realise it was new, or just chose not to enable it.

there are other examples too, which i wont go into. but i should finish by saying when it *is* ok to use make oldconfig. thats between revisions of the same version of the same package. so if you are upgrading from gentoo-dev-sources-2.6.9-r4 to gentoo-dev-sources-2.6.9-r6 then you can do this. nothing much changes between revisions, occasionally you may be presented with one or two new config options, but nothing very drastic. make oldconfig can be handy here, and a timesaver, especially considering the frequency of the 2.6.9 revision releases coming out.

in other situations (e.g. upgrading from 2.6.9 to 2.6.10), i'd recommend using "make menuconfig" for the first time you configure the new version. its not *really* that hard just to select a few options every 8 weeks or so. and once you have done it a few times, you can do it with your eyes closed.

----------

## G2k

Even if I had rebuilt the kernel on my own with make menuconfig i still wouldn't have understood those options or known whether to add them or not. Ergo imo they should change how make oldconfig works: if there's simply a revision then it should work as it does now, but if there are big differences someone should program it to make the user pay special attention to those options, maybe telling him what that option does and what it replaces (if it does replace something.) I simply find it too hard to remember all the options  I have set in my kernel...and yes you can do it with your eyes closed but the devs have to remember that not everyone is a dev

However, thanks for the info, it was really useful

----------

## dsd

 *G2k wrote:*   

> Even if I had rebuilt the kernel on my own with make menuconfig i still wouldn't have understood those options or known whether to add them or not.

 

but you would (probably) have accepted the (safe) defaults..

----------

## Doom0r

ok, i have a valid question that's not answered anywhere else that i've found and since the point on the need for this having been written, i'll hopefully validate this thread by asking this question

how the hell does whatever figure out which system.map to use?

----------

