# Using Gentoo kernel with other distros in multi-boot laptop

## Fx

I have another silly/newbie question... not sure if this is possible or even if it makes sense to do so.

One of the reasons I'm drawn to Gentoo is that it seems to me that a kernel compiled/optimized specifically for my laptop might be 'better' than a vanilla one.  Better could mean faster or using less memory or using less power (battery) or all three.

I read somewhere how the kernel could be put in different locations and that the same kernel could be used for different Linux distros on a multi-boot system... so of course, with my limited understanding of how things work kernel- and Linux-wise, I got to wondering whether there'd be an advantage to replacing the kernel that comes with Lubuntu, or Arch, or ChromeOS, or whatever, with the one I compile for Gentoo.

What do you think?  Have any of you tried this?  Or am I just being silly/insane?  :Smile: 

----------

## NeddySeagoon

Fx,

I don't think you will see much difference speed wise. The down side is that some distros patch their kerenl to make other distro specific things work. You would need to test that.  It will vary from kernel to kernel and distro to distro.

You will also need to install your gentoo kernel modules in the right place in the other distros, or modprobe will not find the modules. You also have to do that without trashing the host distros modules. Thats not too difficult.

----------

## Fx

 *NeddySeagoon wrote:*   

> Fx,
> 
> I don't think you will see much difference speed wise. The down side is that some distros patch their kerenl to make other distro specific things work. You would need to test that.  It will vary from kernel to kernel and distro to distro.
> 
> You will also need to install your gentoo kernel modules in the right place in the other distros, or modprobe will not find the modules. You also have to do that without trashing the host distros modules. Thats not too difficult.

 

Especially for not telling me I was being silly or crazy!  :Smile: 

I agree that speed differences would most likely be minimal... but memory footprint and/or power consumption might be improved enough that the effort would be worth it for me (on my laptop).  I'll run Gentoo by itself for a while and see if I notice advantages in those areas relative to other distros, and if so, give the common kernel approach a try.

It seems though that you're saying that placing the kernel in /boot won't necessarily work for all distros though.  :Sad:   The article I read seemed to suggest that doing that would work... and now I can't find the article.  Oh well, I suppose I could put it in /boot (would 100 MB or so of space be enough, do you think?) and use links to point to the modules from the right places of the other distros.

----------

## NeddySeagoon

Fx,

Having a common /boot shared by all kernels saves your sanity.

The kernel is in two parts - the part that goes into /boot and the part that goes into /lib/modules/`uname -r`/

You need both parts. the /lib/modules bit can be empty if you build a monolithic kernel buy some things won't work that way, so your gentoo /lib/modules/`uname -r`/ will need to be copied to all the other distros. You will need to do this at every kernel update.

Symlinks may work but you will need to have your Gentoo root mounted as that is where the links will point.

----------

## lxg

Fx,

I can tell you from a recent experience that trying to run (just for example) Ubuntu with a Gentoo kernel is a huge pain in the you-know-where. (I needed support for a specific piece of hardware that is not present in Lucid Lynxes 2.6.32.)

Heavily integrated distributions like Ubuntu have customized many things in the boot process, and they use different tools in various places. For example, Ubuntu 10.4 comes with Grub2, and you must use specific tools to manage the Grub configuration. Their way of setup also requires an Initial Ramdisk, in order to launch the graphical boot features – or you must uninstall them, too. Next, they doesn't use Init, but Upstart. And so on.

You will have a lot of trouble switching not only the kernel but also many other things, and even if you succeed, it will be far from stable: For example, as soon as you do an upgrade in Ubuntu that affects the kernel or the bootloader, you might end up with a unbootable system.

Apart from that, you will have a hard time getting support in forums. Not that anybody gets angry because you use some other distro's kernel.  :Wink:  But simply because nobody will be able to reproduce your problems.

This is why I switched that particular machine (my girlfriend's one) to Gentoo and didn't bother to integrate a Gentoo kernel into that other system.

(However, I once managed to get a SLES 9 to work with a then-current Gentoo kernel, but that was a server machine, and SLES 9 had a boot process similar to Gentoo's.)

----------

## Etal

As a suggestion, try to see if there are guides on how to compile the kernel for those particular distros, and what kind of stuff needs to be enabled. Many years ago, there used to be a guide on how to make a custom kernels for SuSE, for instance. If you know what the distro requires in the kernel, and you ensure it's in your kernel, it could save you some pain later.

----------

## Fx

Thank you all for the great suggestions and advice!!!

@Neddy:

Thank you for the tips on how to proceed.

I'm thinking of a quasi-monolithic kernel, in which filesystem support is compiled in (rather than using modules to add XFS/JFS/ReiserFS support)... I read elsewhere that doing so would help reduce CPU load if I was using different filesystems on my various partitions (which I intend to do).

@lxg:

Thank you for posting about your experiences with Ubuntu and a Gentoo kernel.  I'm installing Lubuntu 10.04 so I'll likely face similar issues... esp. w.r.t. using Grub to manage it.  :Sad:   It may not be worth it, as I expect that Gentoo or Arch will be my primary distro.

Your point about having trouble getting support for a 'rogue' configuration like mine is a good one that I hadn't considered.  

@AM088:

Thank you for your suggestion; I believe Arch has such a guide.

----------

## idella4

Fx,

all the above is quite right.  I have run gentoo kernel on a lenny and an ubuntu and a squeeze and a fedora, using the techniques described, without a problem.  So it can be done.  Neddy suggested to copy lib/modules/`uname -r` to lib/modules.   It amounts to the same as going directly to the kernel and running make modules_install when booted in the target distro, then make the initrd within the target distro.

That said, distros do customise.  debian has gone to quite a bit of trouble to create and describe methods for compiling and adjusting its own debian kernels.  I never did bring myself to try them out, but why not plug into them?

A single common boot partition would be convenient.  Just have the same entry for /dev/... /boot in each fstab.

Tell how it fares.

----------

## NeddySeagoon

Fx,

As idella4 says, there are other ways of installing the kernel modules into your other distros

----------

## rer

I don't see any side-effects from the baselayout to the kernel, I use since many years self-build gentoo-kernels for ubuntu and archlinux and vice-versa, without problems, but I mostly don't share them on the same machine, I unpack the 'make tarpkg-gz' tarballs to the other machines, with one exception, on one machine arch and gentoo share one kernel, it was a litte bit fiddling around with the /lib/modules. But I can't agree with the threadstarter. A self-build gentoo-kernel doesn't take any advantage from portage-USE-flag optimization, that you can only expect from the kernel-config itself

----------

