Compile kernel as a normal user

I just heard this trick from my friend, rae.
It is quite easy:
  1. make a dir, cd into it
  2. cp /boot/config .config (suppose you use "make install" to install kernel, :-D)
  3. make -C /usr/src/linux O=$PWD oldconfig, (and optionally make menuconfig to tweak a little bit)
  4. make && sudo make modules_install && sudo make install
The trick is on step 3, ;)

PS: However, there is a problem with this approach.
My original intention is to avoid touching the sources in /usr/src/linux and running as root.
But in fact, before you emerge kernel modules such as x11-drm, you still have to run 'make modules_prepare' in /usr/src/linux as root. Even I have used this command:
sudo env KBUILD_OUTPUT=/home/zhangle/build emerge x11-drm
What's worse, the hints given in the output of the above command can't solve the problem:
* Found kernel source directory:
* /usr/src/linux
* Found kernel object directory:
* /home/zhangle/build
* Found sources for kernel version:
* 2.6.17-suspend2-r4
* Please verify that your /usr/src/linux symlink is pointing
* to your current kernel sources, and that you did run:
* # make dep


Renquan said…

很多内核相关的ebuild编译需要设置KBUILD_OUTPUT,但实际上这个值可以从/lib/modules/$(uname -r)/build这个符号链接上读出来,希望写ebuild时首先看一下这个值,在KBUILD_OUTPUT没有设置时不要简单的报警退出。

Popular posts from this blog

Ripple's XRP: Giving the Third-Largest Cryptocurrency a Second Look

Illinois Is Venezuela and the Solution Is Cryptocurrency