Difference between revisions of "HOWTO: Upgrade kernel using genkernel"

From Sabayon Wiki
Jump to: navigation, search
m (obsolete as per: http://bugs.sabayon.org/show_bug.cgi?id=2270)
 
(change grub-mkconfig to grub2-mkconfig as recently the former has resulted in error messages (see recent forum thread).)
Line 82: Line 82:
 
Currently genkernel only knows about Grub Legacy, so you will need to regenerate the Grub2 grub.cfg file after completing the above, using the following command:
 
Currently genkernel only knows about Grub Legacy, so you will need to regenerate the Grub2 grub.cfg file after completing the above, using the following command:
  
{{Console| <pre class="clear"># grub-mkconfig -o /boot/grub/grub.cfg</pre>}}
+
{{Console| <pre class="clear"># grub2-mkconfig -o /boot/grub/grub.cfg</pre>}}
  
 
Any questions/problems/comments can be posted on the forums.
 
Any questions/problems/comments can be posted on the forums.

Revision as of 02:11, 4 May 2013

i18n: en es pl
Stop.png
This how-to is for the Portage package manager. Please use the Entropy package manager if you are not familiar with Portage.


Stop.png
Before actually performing any of the commands listed below, read through the entire article and WARNING No. 1 at the end, as it may alter what commands you use.

Open a Konsole/Terminal window and use the su command to log in as the root user.

If you have a separate boot partition, make sure it is mounted onto /boot before proceeding. For example, if the boot partition is /dev/sda3 then:

# mount /dev/sda3 /boot

Update portage and genkernel first, then install the newest kernel source code:

# emerge --sync && layman -S
# emerge genkernel
# USE="sources_standalone" emerge sabayon-sources


Question.png
Note 1: There's no need to merge genkernel if the latest version is already installed.


# eselect kernel list

Note which kernel in the list you want to install. It has a number like this next to it: [x]. More than likely x = 2 [2]. Now use this number in the following command, in order to set the symlink to the new version of the kernel:

# eselect kernel set x 
# zcat /proc/config.gz > /usr/src/config 


Question.png
Note 2: If you are just making some changes to the same version of kernel and rebuilding it then using the zcat command is probably appropriate. However if you are upgrading or downgrading to a different version of kernel then the zcat command is probably not appropriate. See WARNING No. 1 at the end of this article for what to do in the latter case.


Do the following if you manually edited your partitions:

# genkernel --kernel-config=/usr/src/config --menuconfig --splash=sabayon --disklabel --luks all

Do the following if you used anaconda's automatic diskdruid or created a lvm:

# genkernel --kernel-config=/usr/src/config --menuconfig  --splash=sabayon --disklabel --lvm --luks all


Question.png
Note 3: If you get an error about an expected integer expression on line 96 of gen_funcs.sh, you will most likely need to update your config files. I used etc-update and selected the second option (-5).


Question.png
Note 4: If you have an older version of genkernel, for example 3.4.7-x, replace "--lvm" with "--lvm2" and "--splash" with "--gensplash".


Question.png
Note 5: If you want to be able to use a UUID for real_root in grub.conf then include "--disklabel". Otherwise you can omit the "--disklabel" (which I normally do).


Question.png
Note 6: "--disklabel" is needed if, after you have built the kernel and reboot, mounting of the root partition fails and you see an error message "blkid: not found". See Gentoo Bugzilla Report No. 229847 for more details. Alternatively, edit grub.conf and make real_root point to the file name of the root partition (/dev/sda5 or whatever) rather than to the root partition's UUID.


Question.png
Note 7: "--luks" is only needed if you want LUKS support for disk encryption.


When you get into the linux kernel menu where you can go and edit all sorts of linux kernel variables (and it's very tempting to mess with), unless you are very, VERY well versed in understanding what it is you are doing, the default settings are good and reliable to start with and will create a kernel that actually WORKS.

SO, you can simply exit and save without changing anything, this way your kernel will compile and you can actually boot into it.

Then we need to rebuild our modules and such to make sure everything works with the new kernel. So do:

# module-rebuild rebuild

Sometimes this will fail if old modules are still around, so you might need to re-emerge your video drivers

I had to re-emerge my nvidia drivers because the old drivers were no longer in the portage tree:

# emerge nvidia-drivers

OR, if you have an ATI GPU:

# emerge ati-drivers

and if it says that ati-drivers-<version> is unavailable, try:

# module-rebuild del ati-drivers-<version> 

If you still have problems, you can clean-out and renew your moduledb first like this:

# rm /var/lib/module-rebuild/moduledb
# module-rebuild populate
# module-rebuild rebuild

Note that the latest kernel has built-in wireless stuff, causing the wireless modules to fail the module-rebuild. The trick is to make sure the wireless stuff is enabled during the kernel compile.

Currently genkernel only knows about Grub Legacy, so you will need to regenerate the Grub2 grub.cfg file after completing the above, using the following command:

# grub2-mkconfig -o /boot/grub/grub.cfg

Any questions/problems/comments can be posted on the forums.

Now, reboot.

Choose to boot into your freshly compiled kernel, the old reliable one will still be there and may be a nice backup for safe keeping so, don't worry about getting rid of it.


There you have it. It will take some time, but it's good.


Unsupported kernels

For other unsupported kernels, please have a look at the unsupported software section at the Gentoo forums.

Most unsupported kernels are in the custom-kernels overlay which is accessible with Layman.

# layman -a custom-kernels





WARNING No. 1: Think carefully about what you are trying to achieve here, i.e. do you want to upgrade to a newer version of the kernel or do you want to rebuild the same version of the kernel you are currently using (perhaps, optionally, making some manual changes to the kernel configuration)? Note that the zcat command mentioned above creates a configuration file based on the currently-running kernel. However, the configuration of the current kernel may not be suitable for the new version of the kernel sources you just merged (downloaded). It could be that you want or need to use a configuration file for the new version of kernel you have just merged. To give a hypothetical example in order to try and illustrate the distinction, let's suppose you are currently running the 2.6.22 kernel but now want to build the 2.6.25 kernel. In which case you would not need to bother with the zcat command as some of the configuration parameters in the 2.6.22 kernel do not exist in the 2.6.25 kernel (and vice versa), so instead of using a file /usr/src/config you could create using zcat, you would instead use the .config file (notice the dot) in the directory /usr/src/linux-2.6.25-sabayon/ created when you merged linux-sabayon-2.6.25 earlier, which is different from the .config file (and config file created by zcat) for the 2.6.22 kernel. In other words, you would instead use the command:

# genkernel --kernel-config=/usr/src/linux-2.6.25-sabayon/.config --menuconfig --bootloader=grub --splash=sabayon --disklabel all

(or

# genkernel --kernel-config=/usr/src/linux-2.6.25-sabayon/.config --menuconfig --bootloader=grub --splash=sabayon --disklabel --lvm all 

if you used anaconda's automatic diskdruid or created a lvm.)

Notice the difference between "--kernel-config=/usr/src/config" ( the file "config" would be created by using the zcat command) and "--kernel-config=/usr/src/linux-2.6.25-sabayon/.config" (the file ".config" would be created when you merge linux-sabayon-2.6.25).

Note also that the file /usr/src/linux-2.6.25-sabayon/.config would be the same as the file /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-x86.config if you merged linux-sabayon-2.6.25 for the x86 edition of Sabayon Linux, or the file /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-amd64.config if you merged linux-sabayon-2.6.25 for the x86_64 edition of Sabayon Linux. Thus, if you run one of the above commands and an error message is displayed to the effect that /usr/src/linux-2.6.25-sabayon/.config cannot be opened, then try using --kernel-config=/usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-x86.config (or /usr/portage/local/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.25-amd64.config if you have the 64-bit edition of SL installed). Note also that the default location of the Portage overlay sources has been changed from directory /usr/portage/local/layman/ to directory /usr/local/portage/layman/ in the latest version of SL (and Gentoo), so modify the aforementioned command accordingly if you are using SL 4.0 and onwards. For example, in the case of the 2.6.31 kernel the switch would be the following for the x86 edition:

--kernel-config=/usr/local/portage/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.31-x86.config 

and the following for the x86_64 edition:

--kernel-config=/usr/local/portage/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.31-amd64.config 


Question.png
Note 8: In SL 5.2 and onwards (Layman 1.3.0 and onwards), replace "/usr/local/portage/layman/" with "/var/lib/layman/" in the text above.


Question.png
Note 9: Use "/usr/portage/distfiles/sabayon-2.6.34-amd64.config" instead of "/var/lib/layman/sabayon/sys-kernel/linux-sabayon/files/linux-sabayon-2.6.34-amd64.config" (replace "amd64" with "x86" for x86) for kernel 2.6.34 and onwards.


Question.png
Note 10: The location of the .config file changed again for kernel 3.0.0 (and possibly earlier). Rather than adding notes here ad infinitum, please use the locate command (install mlocate if not already installed) to find the .config file.