首页 > 代码库 > 升级与卸载Linux内核
升级与卸载Linux内核
升级linux内核
当linux服务器的内核比较旧,就需要对内核进行升级了。
[root@localhost ~]# uname -r #查看当前Linux内核版本
2.6.32-573.el6.x86_64
[root@localhost ~]# ll /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 4220560 Jul 23 2015 /boot/vmlinuz-2.6.32-573.el6.x86_64
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/mapper/VolGroup-lv_home on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sr0 on /mnt type iso9660 (ro)
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# vi base.repo
[base]
name=centos6
baseurl=file:///mnt
enabled=1
gpgcheck=0
[root@localhost boot]# yum localinstall /mnt/Packages/kernel-2.6.32-642.el6.x86_64.rpm
Loaded plugins: fastestmirror
Setting up Local Package Process
Examining /mnt/Packages/kernel-2.6.32-642.el6.x86_64.rpm: kernel-2.6.32-642.el6.x86_64
Marking /mnt/Packages/kernel-2.6.32-642.el6.x86_64.rpm as an update to kernel-2.6.32-573.el6.x86_64
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-642.el6 will be installed
--> Processing Dependency: kernel-firmware >= 2.6.32-642.el6 for package: kernel-2.6.32-642.el6.x86_64
--> Running transaction check
---> Package kernel-firmware.noarch 0:2.6.32-573.el6 will be updated
---> Package kernel-firmware.noarch 0:2.6.32-642.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================
Package Arch Version Repository Size
============================================================================
Installing:
kernel x86_64 2.6.32-642.el6 /kernel-2.6.32-642.el6.x86_64 131 M
Updating for dependencies:
kernel-firmware noarch 2.6.32-642.el6 base 28 M
Transaction Summary
============================================================================
Install 1 Package(s)
Upgrade 1 Package(s)
Total size: 159 M
Total download size: 28 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : kernel-firmware-2.6.32-642.el6.noarch 1/3
Installing : kernel-2.6.32-642.el6.x86_64 2/3
Cleanup : kernel-firmware-2.6.32-573.el6.noarch 3/3
Verifying : kernel-firmware-2.6.32-642.el6.noarch 1/3
Verifying : kernel-2.6.32-642.el6.x86_64 2/3
Verifying : kernel-firmware-2.6.32-573.el6.noarch 3/3
Installed:
kernel.x86_64 0:2.6.32-642.el6
Dependency Updated:
kernel-firmware.noarch 0:2.6.32-642.el6
Complete!
[root@localhost boot]# ll vmlinuz-*
-rwxr-xr-x. 1 root root 4220560 Jul 23 2015 vmlinuz-2.6.32-573.el6.x86_64
-rwxr-xr-x. 1 root root 4264528 May 10 13:32 vmlinuz-2.6.32-642.el6.x86_64
重启系统之后,就可以看到启动菜单多了一项。
当我们对linux内核进行升级之后,就可以卸载以前的内核版本,从而提升服务器;如果升级之后发现高版本不太稳定,也可以卸载之前升级的版本,而在安装比较稳定的linux内核版本。
卸载linux内核
[root@localhost ~]# yum remove kernel-2.6.32-573.el6.x86_64
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-573.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================
Package Arch Version Repository Size
============================================================================
Removing:
kernel x86_64 2.6.32-573.el6 @anaconda-CentOS-201508042137.x86_64/6.7 126 M
Transaction Summary
============================================================================
Remove 1 Package(s)
Installed size: 126 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : kernel-2.6.32-573.el6.x86_64 1/1
Verifying : kernel-2.6.32-573.el6.x86_64 1/1
Removed:
kernel.x86_64 0:2.6.32-573.el6
Complete!
[root@localhost ~]# ll /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 4264528 May 10 13:32 /boot/vmlinuz-2.6.32-642.el6.x86_64
本文出自 “Linux路上” 博客,请务必保留此出处http://dreamlinuxc.blog.51cto.com/5733156/1851868
升级与卸载Linux内核