大网数据广告活动
服务器运维问答

Linux + how to clean /boot and stay only with the current kernel version files

· 52CE 我爱测

Under /boot we have the following files ( red-hat Linux version 6.6 ) cd /boot # ls -ltr drwx------ 2 root root 12288 Oct 15 2015 lost+found -rwxr-xr-x 1 root root 4152624 Oct 15 2015 vmlinuz-2.6.32-504.30.3.el6.x86_64 -rw-------…

问题原文

原帖链接 · dandan · CC BY-SA 3.0

Under /boot we have the following files ( red-hat Linux version 6.6 )

 cd /boot
 # ls -ltr

  drwx------ 2 root root    12288 Oct 15  2015 lost+found
 -rwxr-xr-x 1 root root  4152624 Oct 15  2015 vmlinuz-2.6.32-504.30.3.el6.x86_64
 -rw------- 1 root root  6084011 Oct 15  2015 initrd-2.6.32- 504.30.3.el6.x86_64kdump.img
  drwxr-xr-x 3 root root     1024 Oct 15  2015 efi
 -rw-r--r-- 1 root root   106371 Oct 15  2015 config-2.6.32-504.30.3.el6.x86_64
 -rw-r--r-- 1 root root  2546171 Oct 15  2015 System.map-2.6.32-504.30.3.el6.x86_64
 -rw-r--r-- 1 root root   200246 Oct 15  2015 symvers-2.6.32-504.30.3.el6.x86_64.gz
 -rw------- 1 root root 19360700 Oct 15  2015 initramfs-2.6.32-504.30.3.el6.x86_64.img
 -rwxr-xr-x 1 root root  4222736 Nov 23  2015 vmlinuz-2.6.32-573.12.1.el6.x86_64
 -rw-r--r-- 1 root root   107139 Nov 23  2015 config-2.6.32-573.12.1.el6.x86_64
 -rw-r--r-- 1 root root  2585672 Nov 23  2015 System.map-2.6.32-573.12.1.el6.x86_64
 -rw-r--r-- 1 root root   206008 Nov 23  2015 symvers-2.6.32-573.12.1.el6.x86_64.gz
 -rw------- 1 root root 24340354 Jul 16 03:20 initramfs-2.6.32-573.12.1.el6.x86_64.img
  drwxr-xr-x 2 root root     1024 Jul 16 03:20 grub

Because /boot size is very small, (90M size)

We want to delete the previous kernel from /boot include ALL the other files that related to this kernel

The current running kernel version

 # uname -r
 2.6.32-573.12.1.el6.x86_64

So now I want to capture all the files that are not related to the current kernel , and can be deleted from the /boot

egrep -v will do the Job

  # ls -ltr | egrep -v "2.6.32-573.12.1|lost\+found|grub|efi"

  -rwxr-xr-x 1 root root  4152624 Oct 15  2015 vmlinuz-2.6.32-504.30.3.el6.x86_64
  -rw------- 1 root root  6084011 Oct 15  2015 initrd-2.6.32-504.30.3.el6.x86_64kdump.img
  -rw-r--r-- 1 root root   106371 Oct 15  2015 config-2.6.32-504.30.3.el6.x86_64
  -rw-r--r-- 1 root root  2546171 Oct 15  2015 System.map-2.6.32-504.30.3.el6.x86_64
  -rw-r--r-- 1 root root   200246 Oct 15  2015 symvers-2.6.32-504.30.3.el6.x86_64.gz
  -rw------- 1 root root 19360700 Oct 15  2015 initramfs-2.6.32-504.30.3.el6.x86_64.img

  # rpm -qa | grep "2.6.32-504.30.3"
  kernel-2.6.32-504.30.3.el6.x86_64

so my plan is to perform the following

  1. Remove the previos kernel

    rpm –e  kernel-2.6.32-504.30.3.el6.x86_64
    
  2. Remove the following files from /boot

    rm config-2.6.32-504.30.3.el6.x86_64 
    rm System.map-2.6.32-504.30.3.el6.x86_64
    rm symvers-2.6.32-504.30.3.el6.x86_64.gz
    rm initramfs-2.6.32-504.30.3.el6.x86_64.img
    

My question:

Is my plan is risky ? , or I can be sure that my procedure is safe ?

已采纳解答

原帖链接 · cormpadre · CC BY-SA 3.0

The previous answer should work but thought i'd mention 'Yum-utils' can make this simpler

  1. Check what kernels are installed with: rpm -q kernel
  2. install yum utils: yum install yum-utils
  3. Package cleanup where count is how many kernels you want to retain: package-cleanup --oldkernels --count=2

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。