# Compiling kernel from another pc can I use it to my pc?

## colag

There is a pc with intel core i5 32 bit linux system. I've compiled kernel 4.7 there. Can I use this compiled kernel to my home pc. Home computer has also 32 bit same linux operating system.

----------

## Keruskerfuerst

How is the kernel configured and compiled?

When the hardware of both machines is the same, the kernel can be transferred.

----------

## colag

 *Keruskerfuerst wrote:*   

> How is the kernel configured and compiled?
> 
> When the hardware of both machines is the same, the kernel can be transferred.

 

cd linux-4.7.2

make menuconfig

make -j2

Compiled with intel core i5 3.3 GHz. I want to copy linux-4.7.2 to home pc. Home pc has intel pentium D 2.66GHz. Both have same linux operating system.Last edited by colag on Tue Jan 03, 2017 1:44 pm; edited 1 time in total

----------

## NeddySeagoon

colag,

You must make a kernel that has all the drivers for both systems.

e.g. if one system has a realtec network card and the other an intel card, you need both drivers.

Its the same for all the hardware.

You need to transfer the kernel file, initrd file, if you use one and the modules directory /lib/modules/<kernel-version>

Its useful to copy /usr/src/<kernel-version>/[.config Makefile] too as some build systems refer to these files.

Typically, the build won't fail, you will just get warnings about kernel checks failing.

If you can live with the warnings, these files are not required.

----------

## colag

 *NeddySeagoon wrote:*   

> colag,
> 
> You must make a kernel that has all the drivers for both systems.
> 
> e.g. if one system has a realtec network card and the other an intel card, you need both drivers.
> ...

 

I will run the kernel at home only. So I selected/checked only those drivers I need for home use. Will it work? Why do I need to check/select drivers of the pc with intel core i5?

Does make -j2 create initrd file? And make modules_install should copy modules in /lib/modules/<kernel-version>

----------

## NeddySeagoon

colag,

make -j2 does not make the initrd file.  If you configure the kernel with everything for booting set to <*> then no initrd is needed.

If you will only use the kernel at home, it need only support that hardware.

Reading you post, I read that you wanted to use it on both systems.

There is a small trap.  /lib/modules/<kernel-version> will be overwritten if it exists.

You can avoid that with 

```
make modules_install INSTALL_MOD_PATH=/mnt/floppy
```

or whatever alternate path you want.

It might be a very bad thing to overwrite your work  /lib/modules/<kernel-version> with your home one.

----------

## colag

@NeddySeagoon,

I will not use this linux-4.7.2 in that pc with intel core i5 3.3 GHz. I will use it only at home. It's compiled with drivers and necessary modules or other options for home pc. I will copy linux-4.7.2 in my home pc, delete /lib/modules/<kernel-version>. Then

make modules_install

cp arch/x86/boot/bzImage /boot/vmlinuz-4.7.2

cp System.map /boot/System.map-4.7.2

cp .config /boot/config-4.7.2

Will it work?

----------

## NeddySeagoon

colag,

To run make modules_install at home, you need the entire kernel tree.

I had in mind you would only take home the pieces that you need. 

What you say will work.

----------

