package-cleanup --oldkernels

General support questions
Post Reply
GioMBG
Posts: 59
Joined: 2012/02/27 00:28:14
Location: Conthey Suisse
Contact:

package-cleanup --oldkernels

Post by GioMBG » 2018/05/14 22:02:51

hi All,
in the little boot situation,
the GOOD CentOS advise me that I can't perform an Yum update and save me from another crash where I have not been informed :

Code: Select all

Totale 95 MB/s | 270 MB  00:00:02     
Running transaction check
Running transaction test
Transaction check error:
  installing package kernel-3.10.0-862.2.3.el7.x86_64 needs 2MB on the /boot filesystem
Riepilogo errori
----------------
Requisiti disco:
  Servono almeno altri 2MB sul filesystem /boot.
partition situation default boot it seems little as ever...

Code: Select all

[root@machine ~]# df -l
File system    1K-blocchi     Usati  Disponib. Uso% Montato su
/dev/md2       2078435544 572297384 1400536728  30% /
devtmpfs         32773264         0   32773264   0% /dev
tmpfs            32799180         0   32799180   0% /dev/shm
tmpfs            32799180    106964   32692216   1% /run
tmpfs            32799180         0   32799180   0% /sys/fs/cgroup
/dev/md1           498980    442095      30700  94% /boot
/dev/md3       1733211112    138852 1645007144   1% /home
tmpfs             6559840         0    6559840   0% /run/user/0
so I've googled around and i found to install

Code: Select all

yum-utils
and to edit the /etc/yum.conf that was set to 5

Code: Select all

installonly_limit=2

also I read about

Code: Select all

package-cleanup --oldkernels --count=2
but I really don't understand :
if I do this last cmd, after I can perform the yum update ?
or is SAFE to do something else before to not make problems ? . . .
always thanks
Gio

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: package-cleanup --oldkernels

Post by pjsr2 » 2018/05/15 08:10:36

Correct. The package-cleanup command removes old kernels that you no longer need.
This should free up enough space on the /boot partition. After that you can do a "yum update" to update your system.

Since you have very little free space left on /boot, I am worried that the last kernel that was installed may not have been installed correctly.
Was the last kernel that you installed, usable? During installation of a kernel package, a new image is generated. This requires temporarily additional free space on the /boot partition during the installation. If there was too little free space, the last kernel package you installed may have left you with an unusable kernel. If so, you may want to reinstall (with "yum reinstall kernel-x.y.z") after you did the "package-cleanup --oldkernels" or remove that failed kernel package.

And as usual: it is always nice to have a good backup.

desertcat
Posts: 843
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: package-cleanup --oldkernels

Post by desertcat » 2018/05/15 08:53:04

pjsr2 wrote: And as usual: it is always nice to have a good backup.
I will second this recommendation. I have always made them... especially just before a new point release. I've have never needed them, and the backups just take up space, and eventually will be off loaded or deleted. This time it was different -- I actually NEEDED the backup, as this roll-over did not go very smoothly -- OK it hosed my entire workstation -- and because I had a backup, I was able to RESTORE my computer back to 7.4. Not optimal, but I wait another week or two before I try the roll-over again.

GioMBG
Posts: 59
Joined: 2012/02/27 00:28:14
Location: Conthey Suisse
Contact:

Re: package-cleanup --oldkernels

Post by GioMBG » 2018/05/16 10:10:32

hi ,
thanks for the reply,
I agree 100 % that the space on boot is REALLY critical, but I install this CentOS image like hetzner declare as original and it seems is not like this ! :|
so now I will proceed to backup all ( of course ) and if is not too difficult I ask if there is a way to make more space to boot on this machine.
also for You, once clean old Kernels, is dangerous restart the machine without update nothing ?
or can be that the little boot should make problems in all the case ?
always thanks
Gio

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: package-cleanup --oldkernels

Post by jlehtone » 2018/05/16 10:26:20

A little info, if you please:

Code: Select all

rpm -q kernel | sed "/$(uname -r)/ s/$/ ACTIVE/"
* the rpm lists installed 'kernel' packages
* $(uname -r) gives version of currently running kernel as a string to the sed
* the sed appends word " ACTIVE" to name of currently running kernel package

The output tells us what you have and hence what you can get rid of first.

GioMBG
Posts: 59
Joined: 2012/02/27 00:28:14
Location: Conthey Suisse
Contact:

Re: package-cleanup --oldkernels

Post by GioMBG » 2018/05/16 11:12:49

hi jlehtone,
REALLY thanks for your reply,

Code: Select all

[root@machine ~]# rpm -q kernel | sed "/$(uname -r)/ s/$/ ACTIVE/"
kernel-3.10.0-693.2.2.el7.x86_64
kernel-3.10.0-693.5.2.el7.x86_64
kernel-3.10.0-693.11.1.el7.x86_64
kernel-3.10.0-693.17.1.el7.x86_64
kernel-3.10.0-693.21.1.el7.x86_64 ACTIVE
[root@adamus ~]#
so I will do an:

Code: Select all

package-cleanup --oldkernels
before make the machine update with yum I would like to restart,
or is better to verify something else ?
thanks

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: package-cleanup --oldkernels

Post by jlehtone » 2018/05/16 11:28:31

You are running the latest kernel and therefore that is presumably properly installed.

The "package-cleanup --oldkernels" will leave the two latest kernels. In other words it will do

Code: Select all

yum remove kernel-3.10.0-693.2.2.el7.x86_64 kernel-3.10.0-693.5.2.el7.x86_64 kernel-3.10.0-693.11.1.el7.x86_64
It should be perfectly safe to remove those old kernels.

If one would be running one of the old kernels, then it would be kept and one would have three, "two latest and the current", after cleanup.

The "package-cleanup --oldkernels" does a bit more though; it removes also kernel-devel etc packages for kernel versions that do not remain installed.

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: package-cleanup --oldkernels

Post by pjsr2 » 2018/05/16 11:36:03

Your /boot partition is 500 MB. 500 MB is the default size and should be sufficient.

The command "uname -a" shows you the version of the kernel that is currently running.

The command "rpm -q -a kernel" shows you all the installed kernel packages.

Then when you run

Code: Select all

sudo package-cleanup --oldkernels --count=2
the package-cleanup command will show you the list of kernel packages it is going to remove. You have to confirm that with yes or no before it proceeds, so you are completely in control. The important thing is that the kernel package of your current kernel is not removed.

After the removal of the old and unneeded kernels, it is safe to reboot your machine.

Do you have kdump enabled? (You can see this from "systemctl status kdump").
If you don't need kernel dump, you can disable kdump and remove any initramfs*kdump.img files from your /boot partition.
That could free up some additional space.

On my system, which keeps 5 kernel versions installed, approximately 300 MB is used on /boot and /boot has 200 MB free space.

If the "package-cleanup --oldkernels" did not result in sufficient free space on /boot, then as a last resort compare the contents of the /boot partition with that on another Linux machine and check if there are files that do not belong in the /boot partition. Now think carefully before you remove any of those, before you remove any file you don't recognize.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: package-cleanup --oldkernels

Post by TrevorH » 2018/05/16 11:55:42

If you don't need kernel dump, you can disable kdump and remove any initramfs*kdump.img files from your /boot partition.
And if you don't know what kdump is, then you probably don't need it nor will you miss it.
Your /boot partition is 500 MB. 500 MB is the default size and should be sufficient.
Actually it was the default size but in one of the earlier 7.x point releases, Redhat changed it to 1GB for RHEL.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

GioMBG
Posts: 59
Joined: 2012/02/27 00:28:14
Location: Conthey Suisse
Contact:

Re: package-cleanup --oldkernels

Post by GioMBG » 2018/05/16 13:46:52

ok !
after safe control that I don't go to delete any needed kernel I've run

Code: Select all

[root@machine cron]# rpm -q kernel | sed "/$(uname -r)/ s/$/ ACTIVE/"
kernel-3.10.0-693.2.2.el7.x86_64
kernel-3.10.0-693.11.1.el7.x86_64
kernel-3.10.0-693.11.6.el7.x86_64
kernel-3.10.0-693.17.1.el7.x86_64
kernel-3.10.0-693.21.1.el7.x86_64 ACTIVE
[root@machine cron]# package-cleanup --oldkernels
Plugin abilitati:fastestmirror
--> Esecuzione del controllo di transazione
---> Pacchetto kernel.x86_64 0:3.10.0-693.2.2.el7 settato per essere eliminato
---> Pacchetto kernel.x86_64 0:3.10.0-693.11.1.el7 settato per essere eliminato
---> Pacchetto kernel.x86_64 0:3.10.0-693.11.6.el7 settato per essere eliminato
---> Pacchetto kernel-devel.x86_64 0:3.10.0-693.2.2.el7 settato per essere eliminato
---> Pacchetto kernel-devel.x86_64 0:3.10.0-693.11.1.el7 settato per essere eliminato
---> Pacchetto kernel-devel.x86_64 0:3.10.0-693.11.6.el7 settato per essere eliminato
--> Risoluzione delle dipendenze completata

Dipendenze risolte

=============================================================================================================================================================================
 Package                                   Arch                                Versione                                          Repository                             Dim.
=============================================================================================================================================================================
Rimozione in corso:
 kernel                                    x86_64                              3.10.0-693.2.2.el7                                @updates                               59 M
 kernel                                    x86_64                              3.10.0-693.11.1.el7                               @updates                               59 M
 kernel                                    x86_64                              3.10.0-693.11.6.el7                               @updates                               59 M
 kernel-devel                              x86_64                              3.10.0-693.2.2.el7                                @updates                               36 M
 kernel-devel                              x86_64                              3.10.0-693.11.1.el7                               @updates                               36 M
 kernel-devel                              x86_64                              3.10.0-693.11.6.el7                               @updates                               36 M

Riepilogo della transazione
=============================================================================================================================================================================
Remove  6 Pacchetto

Dimensione installata: 285 M
Procedere [s/N]: s
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Eliminazione      : kernel-devel.x86_64                                                                                                                                1/6 
  Eliminazione      : kernel.x86_64                                                                                                                                      2/6 
  Eliminazione      : kernel-devel.x86_64                                                                                                                                3/6 
  Eliminazione      : kernel-devel.x86_64                                                                                                                                4/6 
  Eliminazione      : kernel.x86_64                                                                                                                                      5/6 
  Eliminazione      : kernel.x86_64                                                                                                                                      6/6 
  Verifica in corso : kernel-3.10.0-693.2.2.el7.x86_64                                                                                                                   1/6 
  Verifica in corso : kernel-3.10.0-693.11.6.el7.x86_64                                                                                                                  2/6 
  Verifica in corso : kernel-devel-3.10.0-693.11.6.el7.x86_64                                                                                                            3/6 
  Verifica in corso : kernel-devel-3.10.0-693.2.2.el7.x86_64                                                                                                             4/6 
  Verifica in corso : kernel-3.10.0-693.11.1.el7.x86_64                                                                                                                  5/6 
  Verifica in corso : kernel-devel-3.10.0-693.11.1.el7.x86_64                                                                                                            6/6 

Eliminato:
  kernel.x86_64 0:3.10.0-693.2.2.el7          kernel.x86_64 0:3.10.0-693.11.1.el7         kernel.x86_64 0:3.10.0-693.11.6.el7   kernel-devel.x86_64 0:3.10.0-693.2.2.el7  
  kernel-devel.x86_64 0:3.10.0-693.11.1.el7   kernel-devel.x86_64 0:3.10.0-693.11.6.el7  

Completo!
after I've check that I also have a kernel :)

Code: Select all

[root@swinger cron]# rpm -q kernel | sed "/$(uname -r)/ s/$/ ACTIVE/"
kernel-3.10.0-693.17.1.el7.x86_64
kernel-3.10.0-693.21.1.el7.x86_64 ACTIVE
safe to make this operation with You All
thanks !
Gio

Post Reply