Kernel compile and install for newbies

Share your own howto's etc. Not for support questions!

Re: Kernel compile and install for newbies

Postby acimmarusti » 2011-11-17 20:37

Ibidem wrote:That's the first problem. If you build a custom kernel, why use the default config? That's not meant to provide what you need--it's meant to run on every x86 computer made since around 1995,provided it has enough ram, and support every peripheral known to the kernel developers.
I would strongly recommend that you do "make localmodconfig" and then configure with make nconfig ( or menuconfig/xconfig/gconfig ).
I'm getting install sizes of 9-12 MB, with wireless, KVM, and all. (9 MB when I use XZ compression, 12 MB when I use LZO compression--which is the lowest compression available)
Build times are well under an hour (maybe 30-40 minutes max, without any parallelization). I'm pretty sure a full default kernel would take over 3 hrs to build here.


Thanks for your response. Well I found out the problem I was having. My kernel images are still about 3 times larger than yours, but they are of the same size as the default debian amd64 kernel image.

The problem is that you have to turn off the kernel option CONFIG_DEBUG_INFO. Which is located under the Kernel hacking menu (if you use make menuconfig / xconfig /gconfig). Curiously, the other method of creating deb packages, strips this debug info out of the kernel image. I guess this eventually becomes the usual debianized linux-*-dbg package if you want it that way.

I'm interested about this localmodconfig option. I realize I can do better at customizing my kernels, but I'm just paranoid about not having a driver for some bizarre peripheral device that I could potentially hook up to my laptop / computer.

Andres
acimmarusti
 
Posts: 393
Joined: 2009-02-27 04:59
Location: College Park, MD USA

Re: Kernel compile and install for newbies

Postby vbrummond » 2011-11-17 20:52

I never saw any performance benefit to use make localmodconfig. All it does is detect what modules your system is currently using and disable all (except what you need) of the options (already) marked as a kernel module. So basically it makes your kernel into a monolithic binary. It might save some space or compile time; However if you ever add a new piece of hardware that requires a missing module you will need to recompile a new kernel.
System: Retina 5K iMac, 27-inch, Late 2015 - Intel i5-6600 3.3ghz, 8gb RAM, AMD Radeon R9 M395 2048 MB
OS: Mac OS 10.12
vbrummond
 
Posts: 4422
Joined: 2010-03-02 01:42

Re: Kernel compile and install for newbies

Postby Ibidem » 2011-11-23 01:16

vbrummond wrote:I never saw any performance benefit to use make localmodconfig. All it does is detect what modules your system is currently using and disable all (except what you need) of the options (already) marked as a kernel module. So basically it makes your kernel into a monolithic binary. It might save some space or compile time; However if you ever add a new piece of hardware that requires a missing module you will need to recompile a new kernel.

That's all that it does. But the point is to start there, so you won't have to spend 2 hours building the kernel, and have 100+ MB used for the kernel.

Since it only disables modules, you can reconfigure the sources later to re-enable a driver, make modules, and install the modules (I've done this at least a couple times, it's not just speculation).
Then you do the tuning:
check if you need ISA (lspci|grep ISA)--some boards use it for odd purposes;
disable MCA (you almost certainly don't need it);
tune for the lowest CPU you'll use (eg, i586, i686, k{6,7,8}, Core whatever...); select your general options; etc.
If you messed up, you wasted maybe 1-2 hours, not 4-6 hours like you might otherwise.

If you're paranoid about "What if I end up needing to test a DEC network card or find an MGA card for a spare console :-P on my desktop, or get given some Infiniband card?", it's not for you. But otherwise, you can add back the useful stuff faster than you'd remove anything.
Thinkpad X100e/Debian Squeeze (All reposiories enabled)/Linux 3.4.11:
1GB RAM/1.6GHz Neo X2/ATI HD 3200/RTL8191SEVA2 wlan0, RTL8169 eth0
Ibidem
 
Posts: 160
Joined: 2010-12-24 18:28

Re: Kernel compile and install for newbies

Postby acimmarusti » 2012-02-03 20:17

make-kpkg is very well documented. It has a very helpful manpage, etc.

Is there any similar documentation regarding 'make deb-pkg' ? I cannot seem to find anything...

Also though I have been using 'make deb-pkg' as of late I have several grievances with it (apart from the apparent lack of documentation). The firmware package gets called "linux-firmware-x.x.x.deb". This package conflicts with the debianized firmware-linux, firmware-linux-free and nonfree. This is annoying, is there a way to change the names? (that's why I'm asking about that documentation).

Recently, nvidia-kernel-dkms from backports failed to compile and install the module on one of my computers running a 3.0.18 kernel customized and compiled by myself with "make deb-pkg". It failed saying that there were no sources for the kernel image (even though kernel headers were installed). Curiously module-assistant had no trouble at all compiling the nvidia module for the kernel... kernels from backports had no trouble with dkms though.

On the other hand make-kpkg doesn't seem to even offer the option of the separate firmware package.

Anyone encountered these problems and found documentation / solutions?

Thanks
acimmarusti
 
Posts: 393
Joined: 2009-02-27 04:59
Location: College Park, MD USA

Re: Kernel compile and install for newbies

Postby Ibidem » 2012-02-04 17:07

acimmarusti wrote:make-kpkg is very well documented. It has a very helpful manpage, etc.

Is there any similar documentation regarding 'make deb-pkg' ? I cannot seem to find anything...

Also though I have been using 'make deb-pkg' as of late I have several grievances with it (apart from the apparent lack of documentation). The firmware package gets called "linux-firmware-x.x.x.deb". This package conflicts with the debianized firmware-linux, firmware-linux-free and nonfree. This is annoying, is there a way to change the names? (that's why I'm asking about that documentation).

Recently, nvidia-kernel-dkms from backports failed to compile and install the module on one of my computers running a 3.0.18 kernel customized and compiled by myself with "make deb-pkg". It failed saying that there were no sources for the kernel image (even though kernel headers were installed). Curiously module-assistant had no trouble at all compiling the nvidia module for the kernel... kernels from backports had no trouble with dkms though.

On the other hand make-kpkg doesn't seem to even offer the option of the separate firmware package.

Anyone encountered these problems and found documentation / solutions?

Thanks

linux-firmware-x.x.x contains the same files as firmware-lnux,firmware-linux-free, & firmware-linux-nonfree.
Therefore, it must always conflict. You only need one of the options, though.

dkms:
The default links (/lib/modules/`uname -r`/{build,source} point to the original build directory.
This is the one problem with this method...
I wrote a script to handle this.
Code: Select all
#!/bin/sh
#fixkernlink
usage(){
cat <<EOF
kernlinks.sh--clean up /lib/modules/<kernel-release> for building modules.
USAGE:
kernlinks.sh <kernelversion>
cd /lib/modules;for K in * ; do kernlinks.sh $K; done; cd -
EOF
}
if [ ! -d /lib/modules/$1 ]
        then usage; exit 255
fi
#If build is not a link, there are no headers or it's not a kernel version
test -L /lib/modules/$1/build||exit 127
cd /lib/modules/$1/
export KERNVER=`pwd`; export KERNVER=`basename ${KERNVER}`
#Are headers installed?
export KERNHDR=/usr/src/linux-headers-${KERNVER}
test -d ${KERNHDR} || exit 126
unlink build
unlink source
ln -s ${KERNHDR} build
ln -s ${KERNHDR} source
cd ${KERNHDR}/arch/x86
#Makefile_32.cpu -- for OSS4
test -e Makefile_32.cpu || cp ../../../all/arch/x86/Makefile_32.cpu ./
exit 0

Note that all/arch/x86/Makefile_32.cpu was copied (cp --parents) from the build directory to /usr/src
Thinkpad X100e/Debian Squeeze (All reposiories enabled)/Linux 3.4.11:
1GB RAM/1.6GHz Neo X2/ATI HD 3200/RTL8191SEVA2 wlan0, RTL8169 eth0
Ibidem
 
Posts: 160
Joined: 2010-12-24 18:28

Re: Kernel compile and install for newbies

Postby javidemon95 » 2012-02-25 21:25

Hello. Wireless don't work with my compiled kernel. What can I do?
javidemon95
 
Posts: 1
Joined: 2012-02-25 20:18

Re: Kernel compile and install for newbies

Postby Ibidem » 2012-02-26 23:19

javidemon95 wrote:Hello. Wireless don't work with my compiled kernel. What can I do?

Recompile your kernel, with the right version and configuration, of course. That's all your info tells us.

If you actually want to solve this, here are my recommendations:

0. Ask in another part of the forum with more details. (This forum is for "How-to"s, not for asking how to do something.)

This report is about as useless for getting help as it can be:
1. You did not state which Debian version you're using. (If you aren't using Debian, ask in your distro's forums.)
Please state whether it's Stable/Squeeze, Testing/Wheezy, or Sid.
2. You did not mention whether wireless worked without a custom kernel.
->If you didn't check, why do you expect your kernel to work?
3. You did not mention what kernel version you built (Kernel 3.x has drivers that are missing in 2.6.32, while some old drivers may have been dropped/broken)
4. You did not mention what wireless card you are using (As root run
Code: Select all
lspci -k #or lshw
)
5. You did not mention whether you enabled the driver for your wireless card.
(If you have no clue, run "make savedefconfig" and attach the defconfig that you get.)

If you don't have the details from at least 1-4, please ask in the beginners forum how to find out or go Google it.
Assuming that you post these details in another part of the forum (Hardware, System Configuration, or Beginners), I'd be happy to help.
But if you want help, please do not use this subforum.
Thinkpad X100e/Debian Squeeze (All reposiories enabled)/Linux 3.4.11:
1GB RAM/1.6GHz Neo X2/ATI HD 3200/RTL8191SEVA2 wlan0, RTL8169 eth0
Ibidem
 
Posts: 160
Joined: 2010-12-24 18:28

Re: Kernel compile and install for newbies

Postby MarianHill » 2012-04-18 10:45

Hello,
I'm probably making some dumb mistake or two but I can't seem to get a .deb file out to install.
All I'm trying to do is change the system timer resolution from 250Hz to 1000Hz.

I followed instructions from these links; http://newbiedoc.sourceforge.net/system/kernel-pkg.html and https://docs.google.com/viewer?a=v&q=cache:B4cAbt_olKgJ:download.gabsoftware.com/docs/SqueezeKernelCompilation.pdf+tar+-jxf+linux-source-2.6.32.tar.bz2&hl=en&gl=us&pid=bl&srcid=ADGEEShK-wEIE-_n5IMLGilpmXzpuhWFM0S01pIAEoVaNQsmQNkIY9MqQqjlRGeERAHD02wl99Mq38okdY14Mv9-jWsNespsnwkat5xP60AgYnTI0CyZM46aHG6UL4g6cz2nLODR9Gz1&sig=AHIEtbQfJgu0e1pPC2XQlYhWhsg_WYCLZA

after menuconfig it looks like the change is ok

Code: Select all
root@debian:/usr/src/linux# diff /boot/config-2.6.32-5-686 .config
3,4c3,4
< # Linux kernel version: 2.6.32
< # Mon Mar 26 03:57:35 2012
---
> # Linux kernel version: 2.6.32.hz1000
> # Tue Apr 17 05:45:44 2012
370c370
< CONFIG_HZ_250=y
---
> # CONFIG_HZ_250 is not set
372,373c372,373
< # CONFIG_HZ_1000 is not set
< CONFIG_HZ=250
---
> CONFIG_HZ_1000=y
> CONFIG_HZ=1000
root@debian:/usr/src/linux#


here's the command I've been using
/usr/src$ fakeroot make-kpkg --append-to-version=.hz1000 kernel_image

So, can I just do some sort of make-deb-file from the newly created linux folder?
Can I just replace the old config file with the new one?
Or, somewhere I got the impression you can do this without installing a deb file.
Any ideas would be much appreciated.
MarianHill
 
Posts: 1
Joined: 2012-04-18 10:01

Re: Kernel compile and install for newbies

Postby este.el.paz » 2012-04-21 17:20

@MHill: did you check my PM? was that any help to you? Sorry to cut into the How-to on the maiden post . . . .

e.e.p.
este.el.paz
 
Posts: 29
Joined: 2012-03-09 19:56
Location: SoCal

Re: Kernel compile and install for newbies

Postby Ibidem » 2012-04-21 20:22

MarianHill wrote:Hello,
I'm probably making some dumb mistake or two but I can't seem to get a .deb file out to install.
All I'm trying to do is change the system timer resolution from 250Hz to 1000Hz.
...
after menuconfig it looks like the change is ok

Code: Select all
root@debian:/usr/src/linux# diff /boot/config-2.6.32-5-686 .config
3,4c3,4
< # Linux kernel version: 2.6.32
< # Mon Mar 26 03:57:35 2012
---
> # Linux kernel version: 2.6.32.hz1000
> # Tue Apr 17 05:45:44 2012
370c370
< CONFIG_HZ_250=y
---
> # CONFIG_HZ_250 is not set
372,373c372,373
< # CONFIG_HZ_1000 is not set
< CONFIG_HZ=250
---
> CONFIG_HZ_1000=y
> CONFIG_HZ=1000
root@debian:/usr/src/linux#


here's the command I've been using
/usr/src$ fakeroot make-kpkg --append-to-version=.hz1000 kernel_image

So, can I just do some sort of make-deb-file from the newly created linux folder?
Can I just replace the old config file with the new one?
Or, somewhere I got the impression you can do this without installing a deb file.
Any ideas would be much appreciated.

I presume that make-kpkg is not creating a deb in the parent directory like it should?
In other words--does
Code: Select all
ls ../*.deb
show anything?

If it didn't work, do this in the kernel source directory:
Code: Select all
make menuconfig #Change CONFIG_LOCALVERSION, and make sure that CONFIG_HZ is properly set
make deb-pkg #as previously discussed in this thread


You have to boot the vmlinuz or bzImage, replacing a config will NOT work.
It's possible to install a kernel without a deb, but if you don't know how, you would be risking an unbootable system; the deb has several hooks for the system to configure everything properly.


PS: FYI, it's also possible to install linux-image-rt-686-pae from backports.org, if you want a realtime kernel.
Thinkpad X100e/Debian Squeeze (All reposiories enabled)/Linux 3.4.11:
1GB RAM/1.6GHz Neo X2/ATI HD 3200/RTL8191SEVA2 wlan0, RTL8169 eth0
Ibidem
 
Posts: 160
Joined: 2010-12-24 18:28

Re: Kernel compile and install for newbies

Postby Soapm » 2012-07-26 06:35

Removed post...
User avatar
Soapm
 
Posts: 541
Joined: 2012-05-22 04:23

Re: Kernel compile and install for newbies

Postby Soapm » 2012-08-10 02:03

Why so may different ways to compile a kernel? And how do you know which method is best for what you're trying to acheive?

http://kernelnewbies.org/FAQ/KernelCompilation

make
make modules_install
make install

http://wiki.debian.org/HowToRebuildAnOf ... nelPackage

fakeroot make -f debian/rules.gen setup_i386_none_686
fakeroot make -f debian/rules.gen binary-arch_i386_none_686 binary-indep \
DEBIAN_KERNEL_JOBS=${NR_CPUS}
"I have no idea which of the many packages this creates to install"

Then this thread has

make-kpkg clean
make-kpkg --rootcmd fakeroot --initrd --revision=custom.001 kernel_image kernel_headers
dpkg -i *.deb
User avatar
Soapm
 
Posts: 541
Joined: 2012-05-22 04:23

Re: Kernel compile and install for newbies

Postby Soapm » 2012-08-10 02:49

Ibidem wrote:Since it only disables modules, you can reconfigure the sources later to re-enable a driver, make modules, and install the modules (I've done this at least a couple times, it's not just speculation)..


Or you can use module assitant if all you want to do is add a module

http://wiki.debian.org/ModuleAssistant
User avatar
Soapm
 
Posts: 541
Joined: 2012-05-22 04:23

Re: Kernel compile and install for newbies

Postby manishthatte » 2014-05-30 21:57

I have just begun compiling my own kernel...version 3.15-rc7 for debian wheezy7.5
with local param settings.
This forum has been a tremendous help.

Hope this goes well.

Cheers !!!
Taking baby steps in Debian
User avatar
manishthatte
 
Posts: 15
Joined: 2014-05-12 02:46

Re: Kernel compile and install for newbies

Postby manishthatte » 2014-05-30 22:53

Finished. All went well till now. :)

Further steps after compiling:

1) sudo make modules_install
2) sudo make install
3) sudo depmod
4) sudo update-initramfs -c -k'(version number)'
5) Reboot
Taking baby steps in Debian
User avatar
manishthatte
 
Posts: 15
Joined: 2014-05-12 02:46

PreviousNext

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable