Linux内核升级之制作initrd.img及其new-kernel-pkg(.sh)使用

本文详细介绍了如何在Linux系统中升级内核,包括从源码复制bzImage和System.map文件、使用new-kernel-pkg脚本创建initrd-2.6.32.6.img,以及更新GRUB和LILO配置。同时,文章提供了new-kernel-pkg.sh脚本的源代码,帮助理解其工作原理。
摘要由CSDN通过智能技术生成

1、从编译好的源码中拷贝bzImage和System.map文件到/boot目录,并重命名。

# cp linux-2.6.32.6/arch/i386/boot/bzImage /boot/vmlinuz-2.6.32.6

# cp linux-2.6.32.6/System.map /boot/System.map-2.6.32.6

 

注意:

1)、vmlinuz和System.map的全名(包括版本号)一定要正确,要不new-kernel-pkg的脚本无法找到上述文件!

2)、编译过程中执行:make bzImage, make modules, make modules_install(拷贝*.ko文件到/lib/modules/2.6.32.6目录下)

 

2、执行命令制作initrd-2.6.32.6.img

# new-kernel-pkg --mkinitrd --depmod --install 2.6.32.6

 

3、/boot目录文件

 

4、new-kernel-pkg脚本

 

 

#!/bin/bash

#

# new-kernel-pkg

# Invoked upon installation or removal of a kernel package, the following

# tasks are/can be done here:

# creation/removal of initrd

# run of depmod/removal of depmod generated files

# addition/removal of kernel images from grub/lilo configuration (via grubby)

#

# Copyright 2002-2008 Red Hat, Inc.  All rights reserved.

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; either version 2 of the License, or

# (at your option) any later version.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program.  If not, see <http://www.gnu.org/licenses/>.

#

 

PATH=/sbin:/bin:$PATH

 

lilo=/sbin/lilo

 

# some defaults that are sane for most arches

kernelName=vmlinuz

 

if [ -x ./grubby ]; then

    grubby=./grubby

else

    grubby=/sbin/grubby

fi

 

[ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel

 

cfgGrub=""

cfgLilo=""

runLilo=""

grubConfig=""

 

ARCH=$(uname -m)

 

if [ $ARCH = 'ia64' ]; then

    liloConfig=/boot/efi/EFI/redhat/elilo.conf

    bootPrefix=/boot/efi/EFI/redhat

    liloFlag=elilo

    isx86=""

elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then

    liloConfig=/etc/yaboot.conf

    bootPrefix=/boot

    lilo=/sbin/ybin

    liloFlag=yaboot

    runLilo="yes"

    isx86=""

elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then

    liloConfig=/etc/silo.conf

    bootPrefix=/boot

    liloFlag=silo

    lilo=/sbin/silo

    isx86=""

elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then

    liloConfig=/etc/zipl.conf

    bootPrefix=/boot

    liloFlag=zipl

    lilo=/sbin/zipl

    runLilo="yes"

    isx86=""

else

    # this leaves i?86 and x86_64

    liloConfig=/etc/lilo.conf

    grubConfig=$(readlink -f /etc/grub.conf 2>/dev/null)

    bootPrefix=/boot

    liloFlag=lilo

    isx86="yes"

fi

 

mode=""

version=""

initrd=""

dracut=""

initrdfile=""

moddep=""

verbose=""

makedefault=""

package=""

mbkernel=""

mbargs=""

adddracutargs=""

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值