|
发表于 2006-12-8 09:26:39
|
显示全部楼层
6 Build The Kernel
To build the kernel, execute these two commands:
[php]
make-kpkg clean
fakeroot make deb-pkg
[/php]
Now be patient, the kernel compilation can take some hours, depending on your kernel configuration and your processor speed.
7 Install The New Kernel
After the successful kernel build, you can find your kernel .deb package in the /usr/src directory.
[php]
cd /usr/src
ls -l
[/php]
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:
[php]
dpkg -i linux-2.6.18.3-default1_2.6.18.3-default1_i386.deb
[/php]
(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:
[php]
apt-get install libhtml-template-perl libparse-recdescent-perl
[/php]
Then we install yaird like this:
[php]
cd /tmp
wget http://downloads.howtoforge.com/files/yaird_0.0.12-8bpo1_i386.deb
dpkg -i yaird_0.0.12-8bpo1_i386.deb
[/php]
(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
[php]
ls -l /boot
[/php]
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:
[php]
vi /boot/config-2.6.18.3-default1
[/php]
[...]
# CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
[...]
Now we can finally create our ramdisk like this:
[php]
mkinitrd.yaird -o /boot/initrd.img-2.6.18.3-default1 2.6.18.3-default1
[/php]
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
[php]
update-grub
[/php]
You can check /boot/grub/menu.lst to see if your new kernel has been added:
[php]
vi /boot/grub/menu.lst
[/php]
It should look like this now (you should find two stanzas for your new kernel at the top of the kernel stnazas list):
## 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 colours
color 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-default1
root (hd0,0)
kernel /boot/vmlinuz-2.6.18.3-default1 root=/dev/sda1 ro
initrd /boot/initrd.img-2.6.18.3-default1
savedefault
boot
title 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 single
initrd /boot/initrd.img-2.6.18.3-default1
savedefault
boot
title Debian GNU/Linux, kernel 2.6.8-2-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.8-2-386 root=/dev/sda1 ro
initrd /boot/initrd.img-2.6.8-2-386
savedefault
boot
title 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 single
initrd /boot/initrd.img-2.6.8-2-386
savedefault
boot
### END DEBIAN AUTOMAGIC KERNELS LIST
10 Reboot
Now reboot the system:
[php]
shutdown -r now
[/php]
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
[php]
uname -r
[/php]
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. |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|