如何删除 CentOS 6 更新后产生的多余的内核?

Posted 佳宇博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何删除 CentOS 6 更新后产生的多余的内核?相关的知识,希望对你有一定的参考价值。

第一种方法:通过命令的方式解决多余的内核

1.首先查看当前内核的版本号:

[[email protected] ~]# uname  -a

Linux jxatei.server2.6.32-573.1.1.el6.x86_64 #1 SMP Sat Jul 25 17:05:50 UTC 2015 x86_64 x86_64x86_64 GNU/Linux

2.查询系统中全部的内核:

[[email protected] ~]# rpm  -qa|grep kernel

kernel-2.6.32-504.30.3.el6.x86_64

kernel-headers-2.6.32-573.1.1.el6.x86_64

kernel-2.6.32-573.1.1.el6.x86_64

kernel-2.6.32-504.el6.x86_64

dracut-kernel-004-388.el6.noarch

kernel-firmware-2.6.32-573.1.1.el6.noarch

3. 以上是我CentOS的内核版本号,其中红色为要删除的版本号:

[[email protected] ~]# yum  remove  kernel-2.6.32-504.30.3.el6.x86_64

Loaded plugins: fastestmirror

Setting up Remove Process

Resolving Dependencies

--> Running transaction check

---> Package kernel.x86_640:2.6.32-504.30.3.el6 will be erased

--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================

 Package                  Arch                     Version                                  Repository                  Size

=============================================================================================================================

Removing:

 kernel                   x86_64                   2.6.32-504.30.3.el6                      @updates                   124 M

Transaction Summary

=============================================================================================================================

Remove   1 Package(s)

Installed size: 124 M

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Repository base is listed more thanonce in the configuration

Repository updates is listed morethan once in the configuration

Repository extras is listed more thanonce in the configuration

Repository centosplus is listed morethan once in the configuration

Repository contrib is listed morethan once in the configuration

 Erasing:kernel-2.6.32-504.30.3.el6.x86_64  1/1                            Verifying:kernel-2.6.32-504.30.3.el6.x86_64  1/1                          Removed:

 kernel.x86_64 0:2.6.32-504.30.3.el6                                       Complete!                                            

 4.重启后就可以看到,内核被删掉了,同时多余的启动项也自动被删掉了。

   重启系统后,可以通过查看以下两个文件是否还有多余内核代码:

[[email protected] ~]#vi /boot/grub/grub.conf

[[email protected] ]# vi /boot/grub/menu.lst

第二种方法:通过修改“menu.lst”文件,删除红色部分来解决多余的内核

 [[email protected] ~]# vi  /boot/grub/menu.lst

# grub.confgenerated by anaconda

#

# Note thatyou 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 arerelative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version roroot=/dev/sda3

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS(2.6.32-573.1.1.el6.x86_64)

        root (hd0,0)

"/boot/grub/menu.lst"25L, 1368C

# grub.confgenerated by anaconda

#

# Note thatyou 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 arerelative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version roroot=/dev/sda3

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS(2.6.32-573.1.1.el6.x86_64)

        root (hd0,0)

        kernel/vmlinuz-2.6.32-573.1.1.el6.x86_64 roroot=UUID=72640132-d6de-46b4-bceb-c7fff46de559 rd_NO_LUKS  KEYBOARDTYPE=

pc KEYTABLE=usrd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet

       initrd/initramfs-2.6.32-573.1.1.el6.x86_64.img

titleCentOS (2.6.32-504.30.3.el6.x86_64)

        root (hd0,0)

   kernel /vmlinuz-2.6.32-504.30.3.el6.x86_64ro root=UUID=72640132-d6de-46b4-bceb-c7fff46de559 rd_NO_LUKS  KEYBOARDTYPE =pc KEYTABLE=us rd_NO_MDcrashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet  initrd/initramfs-2.6.32-504.30.3.el6.x86_64.img

第三种方法:通过修改”grub.cfg”文件解决多余的内核

[[email protected] ~]#vi /boot/grub/grub.conf

# grub.confgenerated by anaconda

#

# Note thatyou 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 arerelative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version roroot=/dev/sda3

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS(2.6.32-573.1.1.el6.x86_64)

        root (hd0,0)

"grub.conf"17L, 755C

# grub.confgenerated by anaconda

#

# Note thatyou 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 arerelative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version roroot=/dev/sda3

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS(2.6.32-573.1.1.el6.x86_64)

        root (hd0,0)

        kernel/vmlinuz-2.6.32-573.1.1.el6.x86_64 roroot=UUID=72640132-d6de-46b4-bceb-c7fff46de559 rd_NO_LUKS  KEYBOARDTYPE=

pc KEYTABLE=usrd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet

   initrd/initramfs-2.6.32-573.1.1.el6.x86_64.img ~

       小结,其实第二、三种方法非常相似,都是修改文件,而且内容都是一样的。sky建议,如果我们要成为Linux专家,只有多使用命令的习惯性操作。 

以上是关于如何删除 CentOS 6 更新后产生的多余的内核?的主要内容,如果未能解决你的问题,请参考以下文章

删除RedHat7.3更新后多余的内核

centos7 多个启动菜单(选项),如何删除?

[转][CentOS]开机时

CentOS7开机界面出现多个内核选项

centos7怎么升级内核到4.2

ubuntu 删除内核