编译内核 FOR DEBIAN

1188阅读 0评论2007-05-08 hb_li_520
分类:LINUX

DEBIAN

 

dom:~# cd /usr/src

dom:/usr/src# ls

dom:/usr/src# wget

tar jxvf

(注意要先安装bzip2之后才可以解压)

之后,下载grsecurity补丁。请注意,务必选择与内核版本相应的grsecurity版本。(grsecurity网站)

Wget http://www.grsecurity.org/grsecurity-2.1.10-2.6.19.2-200701222307.patch.gz

gunzip grsecurity-2.1.10-2.6.19.2-200701222307.patch.gz

 

执行以下命令将新内核打上grsecurity补丁
patch -p0 < ./
grsecurity-2.1.10-2.6.19.2-200701222307.patch

OK,切换到新内核的目录

cd inux-2.6.19.2

为了节省时间,请执行以下命令从现有内核中获得配置

make oldconfig

(我的makegcc均没有安装;都这装完成)
执行完此条命令后,会根据新老内核的差异情况,询问你一些问题,如果不确定的话请都是用默认(直接按回车)。
以上步骤完成后,执行内核配置程序
make menuconfig

dom:/usr/src/linux-2.6.19.2# make menuconfig

  HOSTCC  scripts/kconfig/lxdialog/checklist.o

In file included from scripts/kconfig/lxdialog/checklist.c:24:

scripts/kconfig/lxdialog/dialog.h:32:20: error: curses.h: No such file or directory

In file included from scripts/kconfig/lxdialog/checklist.c:24:

scripts/kconfig/lxdialog/dialog.h:97: error: expected specifier-qualifier-list before htype?

scripts/kconfig/lxdialog/dialog.h:187: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:193: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:195: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:196: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:197: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:198: error: expected ??before ??token

scripts/kconfig/lxdialog/dialog.h:200: error: expected ??before ??token

scripts/kconfig/lxdialog/checklist.c:31: error: expected ??before ??token

scripts/kconfig/lxdialog/checklist.c:59: error: expected ??before ??token

scripts/kconfig/lxdialog/checklist.c:95: error: expected ??before ??token

scripts/kconfig/lxdialog/checklist.c: In function ialog_checklist?

scripts/kconfig/lxdialog/checklist.c:116: error: INDOW?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:116: error: (Each undeclared identifier is reported only once

scripts/kconfig/lxdialog/checklist.c:116: error: for each function it appears in.)

scripts/kconfig/lxdialog/checklist.c:116: error: ialog?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:116: error: ist?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:116: warning: left-hand operand of comma expression has no effect

scripts/kconfig/lxdialog/checklist.c:129: warning: implicit declaration of function etmaxy?

scripts/kconfig/lxdialog/checklist.c:129: error: tdscr?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:130: error: EY_MAX?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:131: warning: implicit declaration of function etmaxx?

scripts/kconfig/lxdialog/checklist.c:137: error: OLS?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:138: error: INES?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:140: warning: implicit declaration of function raw_shadow?

scripts/kconfig/lxdialog/checklist.c:142: warning: implicit declaration of function ewwin?

scripts/kconfig/lxdialog/checklist.c:143: warning: implicit declaration of function eypad?

scripts/kconfig/lxdialog/checklist.c:143: error: RUE?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:145: warning: implicit declaration of function raw_box?

scripts/kconfig/lxdialog/checklist.c:146: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:146: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:147: warning: implicit declaration of function attrset?

scripts/kconfig/lxdialog/checklist.c:147: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:148: warning: implicit declaration of function vwaddch?

scripts/kconfig/lxdialog/checklist.c:150: warning: implicit declaration of function addch?

scripts/kconfig/lxdialog/checklist.c:151: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:154: warning: implicit declaration of function rint_title?

scripts/kconfig/lxdialog/checklist.c:156: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:157: warning: implicit declaration of function rint_autowrap?

scripts/kconfig/lxdialog/checklist.c:164: warning: implicit declaration of function ubwin?

scripts/kconfig/lxdialog/checklist.c:171: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:171: error: truct dialog_color?has no member named tr?

scripts/kconfig/lxdialog/checklist.c:189: warning: implicit declaration of function rint_item?

scripts/kconfig/lxdialog/checklist.c:192: warning: implicit declaration of function rint_arrows?

scripts/kconfig/lxdialog/checklist.c:195: warning: implicit declaration of function rint_buttons?

scripts/kconfig/lxdialog/checklist.c:197: warning: implicit declaration of function noutrefresh?

scripts/kconfig/lxdialog/checklist.c:199: warning: implicit declaration of function oupdate?

scripts/kconfig/lxdialog/checklist.c:202: warning: implicit declaration of function getch?

scripts/kconfig/lxdialog/checklist.c:210: error: EY_UP?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:210: error: EY_DOWN?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:220: error: ALSE?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:221: warning: implicit declaration of function crollok?

scripts/kconfig/lxdialog/checklist.c:222: warning: implicit declaration of function scrl?

scripts/kconfig/lxdialog/checklist.c:232: warning: implicit declaration of function refresh?

scripts/kconfig/lxdialog/checklist.c:293: warning: implicit declaration of function elwin?

scripts/kconfig/lxdialog/checklist.c:297: error: EY_LEFT?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:298: error: EY_RIGHT?undeclared (first use in this function)

scripts/kconfig/lxdialog/checklist.c:310: warning: implicit declaration of function n_key_esc?

scripts/kconfig/lxdialog/checklist.c:312: error: EY_RESIZE?undeclared (first use in this function)

make[1]: *** [scripts/kconfig/lxdialog/checklist.o] Error 1

make: *** [menuconfig] Error 2

解决以上问题要安装

apt-get install libncurse5-dev

!!!!
如果你的DebianX的话,也可以使用 make xconfig 来进行内核的配置。请自行根据实际情况进行配置,不确定的话请保持默认。
Security Options 中,选择 Grsecurity 并将其设置到 medium。然后根据grsecurity的官方推荐,请在 Security Options -> PaX -> PaX Control 中,将 MAC system integration 设置为 [None]
至此,内核的配置就算完成了。请按 ESC 多次后退出内核配置页面(在系统询问是否要保存新内核的配置时,当然要选择yes)。
执行以下命令进行新内核的生成!
make -kpkg clean
fakeroot make-kpkg --initrd --append-to-version=noobu --revision=1.0 kernel_image

为了能使用make-kpkg命令,你必须安装一个kernel-package包。安装过程如下:

#apt-get install kernel-package
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
将会安装下列额外的软件包:
  dpkg-dev
建议安装的软件包:
  debian-keyring linux-source libdb3-dev libncurses-dev docbook-utils
推荐安装的软件包:
  libc6-dev libc-dev
下列【新】软件包将被安装:
  dpkg-dev kernel-package
共升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 74 个软件未被升级。
需要下载 362kB/526kB 的软件包。
解压缩后会消耗掉 1888kB 的额外空间。
您希望继续执行吗?[Y/n]
获取:1 dapper/main kernel-package 9.001ubuntu15 [362kB]
下载 362kB,耗时 2s (169kB/s)
选中了曾被取消选择的软件包 dpkg-dev
(
正在读取数据库 ... 系统当前总共安装有 94416 个文件和目录。)
正在解压缩 dpkg-dev ( .../dpkg-dev_1.13.11ubuntu6_all.deb) ...
选中了曾被取消选择的软件包 kernel-package
正在解压缩 kernel-package ( .../kernel-package_9.001ubuntu15_all.deb) ...
正在设置 dpkg-dev (1.13.11ubuntu6) ...
正在设置 kernel-package (9.001ubuntu15) ...

安装完成后就可以看到make-kpkg命令了(在命令行输入make后连续按两次TAB键):

#make
make                         make_driver_db_cups          makeg                      
make-kpkg
makedepend                   make_driver_db_lpr           makekdewidgets             
make-memtest86+-boot-floppy

还有一个工具mkinitrd是必须的,为了能使用这个工具,你必须安装一个initrd-tools包,安装过程如下:

#apt-get install initrd-tools
正在读取软件包列表... 完成

正在分析软件包的依赖关系树... 完成
将会安装下列额外的软件包:
  cramfsprogs dash
下列【新】软件包将被安装:
  cramfsprogs dash initrd-tools
共升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 74 个软件未被升级。
需要下载 0B/139kB 的软件包。
解压缩后会消耗掉 487kB 的额外空间。
您希望继续执行吗?[Y/n]
正在预设定软件包
...
选中了曾被取消选择的软件包 dash

(
正在读取数据库 ... 系统当前总共安装有 94595 个文件和目录。)
正在解压缩 dash (
.../dash_0.5.3-1ubuntu1_i386.deb) ...
选中了曾被取消选择的软件包 cramfsprogs

正在解压缩 cramfsprogs ( .../cramfsprogs_1.1-6_i386.deb) ...
选中了曾被取消选择的软件包 initrd-tools

正在解压缩 initrd-tools ( .../initrd-tools_0.1.84ubuntu1_all.deb) ...
正在设置 dash (0.5.3-1ubuntu1) ...

正在设置 cramfsprogs (1.1-6) ...
正在设置 initrd-tools (0.1.84ubuntu1) ...

安装完成后就可以看到makeinitrd命令了(在命令行输入mki后连续按两次TAB键):

#mki
mkinitramfs  mkinitrd     mkisofs

fakeroot
的作用是在内核的生成过程中暂时性获取root权限。如果你直接是用root帐号操作的话,可以省略fakeroot。–append-to-version定义的是内核的软件包名字,类似 kernel-image-2.6.11.7-noobu 这样。而 revision定义的是软件包的版本。
现在系统会开始进行新内核的生成,屏幕上会有许多文字闪过。请注意,如果生成过程中出现错误,请执行 make clean 后,用 make menuconfig 重新配置内核。一般都是仔细看错误信息,找到出错的模块,然后将其去除。
内核顺利生成完毕后,会在/usr/src目录下产生一个 deb 包。例如 kernel-image-2.6.11.7-noobu_1.0_i386.deb
执行以下命令安装新内核!^_^
dpkg -i kernel-image-2.6.11.7-noobu_1.0_i386.deb
接着Debian会安装新内核并更新Grub的配置文件。重新启动(shutdown -r now)后将会boot到新内核。
uname -a 看一下,是不是看到新内核的名字啦?

上一篇:Debian下安装配置Subversion
下一篇:strace命令用法