阅读内容

如何编译debian内核

[日期:2007-09-26] 来源:Linux公社  作者:Linuxidc


7 Install The New Kernel

After the successful kernel build, you can find your kernel .deb package in the /usr/src directory.

cd /usr/src
ls -l

On my test system it was called linux-2.6.18.3-default1_2.6.18.3-default1_i386.deb. I install it like this:

dpkg -i linux-2.6.18.3-default1_2.6.18.3-default1_i386.deb

(You can now even transfer the .deb file to other Debian Sarge systems and install it there exactly the same way, which means you don't have to compile the kernel there again.)

8 Create A Ramdisk

Now we must create a ramdisk for our new kernel. Normally we do this with mkinitrd, but our new kernel uses udev instead of devfs, and you'll most likely get this error message with an mkinitrd generated ramdisk during boot-up:

mount: unknown filesystem type 'devfs'

which might lead to a kernel panic.

The new way of creating ramdisks is with mkinitrd.yaird. Backports.org has a yaird package for Debian Sarge. Before we can install it, we must install two prerequisites:

apt-get install libhtml-template-perl libparse-recdescent-perl

Then we install yaird like this:

cd /tmp
wget http://downloads.howtoforge.com/files/yaird_0.0.12-8bpo1_i386.deb
dpkg -i yaird_0.0.12-8bpo1_i386.deb

(The original yaird package was located in http://backports.org/debian/pool/main/y/yaird/, but was removed in the meantime, so I've made the package available under http://downloads.howtoforge.com/files/yaird_0.0.12-8bpo1_i386.deb.)

Before we can create the new ramdisk, we must edit the configuration file of our new kernel which you can find in the /boot directory (run

ls -l /boot

to find out). In this tutorial it's called /boot/config-2.6.18.3-default1, and in that file we must comment out the line CONFIG_DEFCONFIG_LIST (towards the beginning of the file) because otherwise mkinitrd.yaird will throw an error like this at us:

yaird error: bad value in /boot/config-2.6.18.3-default1: CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" (fatal)

So we do this:

vi /boot/config-2.6.18.3-default1

[...]# CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"[...]

Now we can finally create our ramdisk like this:

mkinitrd.yaird -o /boot/initrd.img-2.6.18.3-default1 2.6.18.3-default1

 

9 Configure The GRUB Boot Loader

Now we must configure our GRUB boot loader so that our new kernels gets booted when we restart the system. This is very easy, just run

update-grub

You can check /boot/grub/menu.lst to see if your new kernel has been added:

vi /boot/grub/menu.lst

It should look like this now (you should find two stanzas for your new kernel at the top of the kernel stnazas list):

# menu.lst - See: grub(8), info grub, update-grub(8)#            grub-install(8), grub-floppy(8),#            grub-md5-crypt, /usr/share/doc/grub#            and /usr/share/doc/grub-doc/.## default num# Set the default entry to the entry number NUM. Numbering starts from 0, and# the entry number 0 is the default if the command is not used.## You can specify 'saved' instead of a number. In this case, the default entry# is the entry saved with the command 'savedefault'.default         0## timeout sec# Set a timeout, in SEC seconds, before automatically booting the default entry# (normally the first entry defined).timeout         5# Pretty colourscolor cyan/blue white/blue## password ['--md5'] passwd# If used in the first section of a menu file, disable all interactive editing# control (menu entry editor and command-line)  and entries protected by the# command 'lock'# e.g. password topsecret#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/# password topsecret## examples## title         Windows 95/98/NT/2000# root          (hd0,0)# makeactive# chainloader   +1## title         Linux# root          (hd0,1)# kernel        /vmlinuz root=/dev/hda2 ro### Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST### BEGIN AUTOMAGIC KERNELS LIST## lines between the AUTOMAGIC KERNELS LIST markers will be modified## by the debian update-grub script except for the default options below## DO NOT UNCOMMENT THEM, Just edit them to your needs## ## Start Default Options #### default kernel options## default kernel options for automagic boot options## If you want special options for specifiv kernels use kopt_x_y_z## where x.y.z is kernel version. Minor versions can be omitted.## e.g. kopt=root=/dev/hda1 ro# kopt=root=/dev/sda1 ro## default grub root device## e.g. groot=(hd0,0)# groot=(hd0,0)## should update-grub create alternative automagic boot options## e.g. alternative=true##      alternative=false# alternative=true## should update-grub lock alternative automagic boot options## e.g. lockalternative=true##      lockalternative=false# lockalternative=false## altoption boot targets option## multiple altoptions lines are allowed## e.g. altoptions=(extra menu suffix) extra boot options##      altoptions=(recovery mode) single# altoptions=(recovery mode) single## controls how many kernels should be put into the menu.lst## only counts the first occurence of a kernel, not the## alternative kernel options## e.g. howmany=all##      howmany=7# howmany=all## should update-grub create memtest86 boot option## e.g. memtest86=true##      memtest86=false# memtest86=true## ## End Default Options ##title           Debian GNU/Linux, kernel 2.6.18.3-default1root            (hd0,0)kernel          /boot/vmlinuz-2.6.18.3-default1 root=/dev/sda1 roinitrd          /boot/initrd.img-2.6.18.3-default1savedefaultboottitle           Debian GNU/Linux, kernel 2.6.18.3-default1 (recovery mode)root            (hd0,0)kernel          /boot/vmlinuz-2.6.18.3-default1 root=/dev/sda1 ro singleinitrd          /boot/initrd.img-2.6.18.3-default1savedefaultboottitle           Debian GNU/Linux, kernel 2.6.8-2-386root            (hd0,0)kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 roinitrd          /boot/initrd.img-2.6.8-2-386savedefaultboottitle           Debian GNU/Linux, kernel 2.6.8-2-386 (recovery mode)root            (hd0,0)kernel          /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 ro singleinitrd          /boot/initrd.img-2.6.8-2-386savedefaultboot### END DEBIAN AUTOMAGIC KERNELS LIST

 

10 Reboot

Now reboot the system:

shutdown -r now

If everything goes well, it should come up with the new kernel. You can check if it's really using your new kernel by running

uname -r

This should display something like

2.6.18.3-default1

If the system doesn't start, restart it, and when you come to the GRUB boot loader menu, select your old kernel and start the system:

 

You can now try again to compile a working kernel. Don't forget to remove the two stanzas of the not-working kernel from /boot/grub/menu.lst.

上一页123456  GO
【内容导航】
第1页:如何编译debian内核 第2页:如何编译debian内核
第3页:如何编译debian内核 第4页:如何编译debian内核
第5页:如何编译debian内核 第6页:如何编译debian内核



相关资讯      
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:

L
I
N
U
X


GOOGLE搜索
Google