Chinaunix首页 | 论坛 | 博客
  • 博客访问: 173629
  • 博文数量: 47
  • 博客积分: 992
  • 博客等级: 准尉
  • 技术积分: 565
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-08 21:57
文章分类

全部博文(47)

文章存档

2019年(1)

2018年(1)

2017年(1)

2014年(6)

2013年(1)

2012年(2)

2011年(35)

我的朋友

分类: LINUX

2011-06-09 18:05:33

LinuxAdmin110609: fedora kernel的install过程注记


Email:    zcatt@163.com
Blog    http://zcatt.blog.chinaunix.net
 
声明
仅限学习交流,禁止商业用途。转载需注明出处。

版本记录
Date        Ver        Note
2011-06-09    0.1        Draft.  zcatt, Beijing

环境: fedora 12, kernel 2.6.31.5

在执行完 all , modules和modules_install后,

  1. make all modules modules_install

可以使用安装kernel到boot了. 注意install过程需要mkinitrd这个package, 应当yum install安装先.

  1. make install

在kernel脚本arch/x86/boot/Makefile中, 是这样定义install target的. 就是调用install.sh

  1. install:
  2.     sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
  3.         System.map "$(INSTALL_PATH)"

而arch/x86/boot/install.sh如下. 继而调用/sbin/installkernel

  1. #!/bin/sh
  2. #
  3. # This file is subject to the terms and conditions of the GNU General Public
  4. # License. See the file "COPYING" in the main directory of this archive
  5. # for more details.
  6. #
  7. # Copyright (C) 1995 by Linus Torvalds
  8. #
  9. # Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
  10. #
  11. # "make install" script for i386 architecture
  12. #
  13. # Arguments:
  14. # $1 - kernel version
  15. # $2 - kernel image file
  16. # $3 - kernel map file
  17. # $4 - default install path (blank if root directory)
  18. #

  19. verify () {
  20. if [ ! -f "$1" ]; then
  21.      echo "" 1>&2
  22.      echo " *** Missing file: $1" 1>&2
  23.      echo ' *** You need to run "make" before "make install".' 1>&2
  24.      echo "" 1>&2
  25.      exit 1
  26. fi
  27. }

  28. # Make sure the files actually exist
  29. verify "$2"
  30. verify "$3"

  31. # User may have a custom install script

  32. if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
  33. if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi

  34. # Default install - same as make zlilo

  35. if [ -f $4/vmlinuz ]; then
  36.    mv $4/vmlinuz $4/vmlinuz.old
  37. fi

  38. if [ -f $4/System.map ]; then
  39.     mv $4/System.map $4/System.old
  40. fi

  41. cat $2 > $4/vmlinuz
  42. cp $3 $4/System.map

  43. if [ -x /sbin/lilo ]; then
  44.     /sbin/lilo
  45. elif [ -x /etc/lilo/install ]; then
  46.     /etc/lilo/install
  47. else
  48.     sync
  49.     echo "Cannot find LILO."
  50. fi

installkernel会将arch/x86/boot/bzImage拷贝到/boot/vmLinuz-$KERNEL_VERSION, 而arch/x86/boot/System.map拷贝到/boot/System.map-$KERNEL_VERSION. 并建立softlink.
随后installkernel会调用
    /sbin/new-kernel-pkg --mkinitrd --depmod --install $KERNEL_VERSION
    /sbin/new-kernel-pkg --rpmposttrans $KERNEL_VERSION
完成对grub的配置. new-kernel-pkg中使用的是grubby这个工具. 配置的内容体现在/boot/grub/grub.conf中. 我机器上的grub.conf内容

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_zfkernel-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=6
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.31.mykernel)
    root (hd0,0)
    kernel /vmlinuz-2.6.31.mykernel ro root=/dev/mapper/vg_zfkernel-lv_root  LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet
    initrd /initrd-2.6.31.mykernel.img
title Fedora (2.6.31.5-127.fc12.i686.PAE)
    root (hd0,0)
    kernel /vmlinuz-2.6.31.5-127.fc12.i686.PAE ro root=/dev/mapper/vg_zfkernel-lv_root  LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet
    initrd /initramfs-2.6.31.5-127.fc12.i686.PAE.img


Locations of visitors to this page
阅读(769) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~