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 ?

dandan
  • 1,021
  • 4
  • 13
  • 21

2 Answers2

2

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
cormpadre
  • 404
  • 2
  • 5
0

I think your plan is overly complicated.

The files you're suggesting to remove in step 2 are likely all owned by the relevant kernel package anyway. On my test RHEL 6 machine:

$ rpm -qf /boot/initramfs-2.6.32-573.18.1.el6.x86_64.img kernel-2.6.32-573.18.1.el6.x86_64

etc.

So step 1 should remove everything. As for what to remove, rpm -qa kernel\* will list all of the kernel packages installed. Simply grep out what doesn't match uname -r. Take care how this might affect your GRUB configuration but if you stay within the RHEL frameworks then GRUB should only reference kernels that are installed.

bodgit
  • 4,661
  • 13
  • 26