CentOS通过删除旧内核解决/boot空间不足的问题
今天想给系统升级一下,所以就运行了yum upgrade命令,结果没有升级成功,原因是我的/boot目录空间不够了
Transaction Check Error:
installing package kernel-2.6.32-220.17.1.el6.x86_64 needs 18MB on the /boot filesystem
Error Summary
-------------
Disk Requirements:
At least 18MB more space needed on the /boot filesystem.
好吧,查看了一下boot目录
[root@CC boot]# ls
config-2.6.32-131.0.15.el6.x86_64
config-2.6.32-220.13.1.el6.centos.plus.x86_64
config-2.6.32-220.13.1.el6.x86_64
config-2.6.32-220.7.1.el6.x86_64
efi
grub
initramfs-2.6.32-220.13.1.el6.centos.plus.x86_64.img
initramfs-2.6.32-220.13.1.el6.x86_64.img
initramfs-2.6.32-220.7.1.el6.x86_64.img
initrd-2.6.32-131.0.15.el6.x86_64kdump.img
lost+found
symvers-2.6.32-131.0.15.el6.x86_64.gz
symvers-2.6.32-220.13.1.el6.centos.plus.x86_64.gz
symvers-2.6.32-220.13.1.el6.x86_64.gz
symvers-2.6.32-220.7.1.el6.x86_64.gz
System.map-2.6.32-131.0.15.el6.x86_64
System.map-2.6.32-220.13.1.el6.centos.plus.x86_64
System.map-2.6.32-220.13.1.el6.x86_64
System.map-2.6.32-220.7.1.el6.x86_64
vmlinuz-2.6.32-131.0.15.el6.x86_64
vmlinuz-2.6.32-220.13.1.el6.centos.plus.x86_64
vmlinuz-2.6.32-220.13.1.el6.x86_64
vmlinuz-2.6.32-220.7.1.el6.x86_64
config-2.6.32-131.0.15.el6.x86_64
config-2.6.32-220.13.1.el6.centos.plus.x86_64
config-2.6.32-220.13.1.el6.x86_64
config-2.6.32-220.7.1.el6.x86_64
efi
grub
initramfs-2.6.32-220.13.1.el6.centos.plus.x86_64.img
initramfs-2.6.32-220.13.1.el6.x86_64.img
initramfs-2.6.32-220.7.1.el6.x86_64.img
initrd-2.6.32-131.0.15.el6.x86_64kdump.img
lost+found
symvers-2.6.32-131.0.15.el6.x86_64.gz
symvers-2.6.32-220.13.1.el6.centos.plus.x86_64.gz
symvers-2.6.32-220.13.1.el6.x86_64.gz
symvers-2.6.32-220.7.1.el6.x86_64.gz
System.map-2.6.32-131.0.15.el6.x86_64
System.map-2.6.32-220.13.1.el6.centos.plus.x86_64
System.map-2.6.32-220.13.1.el6.x86_64
System.map-2.6.32-220.7.1.el6.x86_64
vmlinuz-2.6.32-131.0.15.el6.x86_64
vmlinuz-2.6.32-220.13.1.el6.centos.plus.x86_64
vmlinuz-2.6.32-220.13.1.el6.x86_64
vmlinuz-2.6.32-220.7.1.el6.x86_64
以前更新内核后,旧内核还留在boot目录里,便于还原。现在新内核经过多天运行,很稳定,所以旧内核都可以删除了
1.查看现运行的内核版本
[root@CC boot]# uname -r
2.6.32-220.13.1.el6.centos.plus.x86_64
2.6.32-220.13.1.el6.centos.plus.x86_64
2.列出所有的内核文件
[root@CC boot]# rpm -q kernel
kernel-2.6.32-131.0.15.el6.x86_64
kernel-2.6.32-220.13.1.el6.x86_64
kernel-2.6.32-220.13.1.el6.centos.plus.x86_64
kernel-2.6.32-220.7.1.el6.x86_64
kernel-2.6.32-131.0.15.el6.x86_64
kernel-2.6.32-220.13.1.el6.x86_64
kernel-2.6.32-220.13.1.el6.centos.plus.x86_64
kernel-2.6.32-220.7.1.el6.x86_64
3.删除所有旧的内核文件
(注意不要删除当前系统正在运行的内核文件)
[root@CC boot]# rpm -e kernel-2.6.32-131.0.15.el6.x86_64
[root@CC boot]# rpm -e kernel-2.6.32-220.7.1.el6.x86_64
[root@CC boot]# rpm -e kernel-2.6.32-220.7.1.el6.x86_64
到此,旧的内核文件就安全删除
[root@CC boot]# rpm -q kernel
kernel-2.6.32-220.13.1.el6.x86_64
kernel-2.6.32-220.13.1.el6.centos.plus.x86_64
kernel-2.6.32-220.13.1.el6.x86_64
kernel-2.6.32-220.13.1.el6.centos.plus.x86_64
4.查看文件系统使用情况和文件系统被挂在的位置
[root@CC boot]# df -lh
文件系统 容量 已用 可用 已用%% 挂载点
/dev/sda2 9.7G 4.3G 4.9G 47% /
tmpfs 504M 276K 504M 1% /dev/shm
/dev/sda1 97M 47M 46M 51% /boot
/dev/sda3 4.9G 987M 3.6G 22% /home