Emil CHERICHES

Emil CHERICHES

Removing old kernels

August 6, 2014 Emil C
No Comments

On Debian/Ubuntu we would need to search for installed kernel packages, something like this:

root@server:~# dpkg --list |grep linux-image
ii  linux-image-3.2.0-23-generic         3.2.0-23.36                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-56-generic         3.2.0-56.86                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-57-generic         3.2.0-57.87                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-58-generic         3.2.0-58.88                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-59-generic         3.2.0-59.90                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-60-generic         3.2.0-60.91                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-61-generic         3.2.0-61.93                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-63-generic         3.2.0-63.95                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-64-generic         3.2.0-64.97                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-65-generic         3.2.0-65.99                                      Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-3.2.0-67-generic         3.2.0-67.101                                     Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii  linux-image-server                   3.2.0.67.79                                      Linux kernel image on Server Equipment.

Then we would want to see which kernel we are running:

root@server:~# uname -a
Linux imi01 3.2.0-61-generic #93-Ubuntu SMP Fri May 2 21:31:50 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Then we would remove all linux-image packages except for the exact version running and the latest one (theese may differ if you are running a mission critical server and you have not restarted since the laste upgrade).

root@imi01:~# apt-get remove --purge linux-image-3.2.0-23-generic linux-image-3.2.0-56-generic linux-image-3.2.0-57-generic linux-image-3.2.0-58-generic linux-image-3.2.0-59-generic linux-image-3.2.0-60-generic linux-image-3.2.0-63-generic linux-image-3.2.0-64-generic linux-image-3.2.0-65-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-image-3.2.0-23-generic* linux-image-3.2.0-56-generic* linux-image-3.2.0-57-generic* linux-image-3.2.0-58-generic* linux-image-3.2.0-59-generic*
  linux-image-3.2.0-60-generic* linux-image-3.2.0-63-generic* linux-image-3.2.0-64-generic* linux-image-3.2.0-65-generic*
0 upgraded, 0 newly installed, 9 to remove and 0 not upgraded.
After this operation, 1,349 MB disk space will be freed.
Do you want to continue [Y/n]?

On RHEL/CentOS it is even more simple, we need to install yum-utils

[root@server ~]# yum install yum-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirrors.linux.ro
 * epel: ftp.ines.lug.ro
 * extras: centos-mirror.cyberhost.ro
 * updates: centos.mirrors.linux.ro
base                                                                                        | 1.1 kB     00:00
epel                                                                                        | 3.7 kB     00:00
extras                                                                                      | 2.1 kB     00:00
updates                                                                                     | 1.9 kB     00:00
updates/primary_db                                                                          | 536 kB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.16-21.el5.centos set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package                   Arch                   Version                               Repository            Size
===================================================================================================================
Installing:
 yum-utils                 noarch                 1.1.16-21.el5.centos                  base                  74 k

Transaction Summary
===================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 74 k
Is this ok [y/N]:

then we run the following command, that takes care of everything:

[root@server ~]# package-cleanup --oldkernel
Setting up yum
I will remove the following 3 kernel related packages:
kernel-2.6.18-371.8.1.el5
kernel-2.6.18-371.1.2.el5
kernel-2.6.18-371.el5
Is this ok [y/N]:

For more information about package-cleanup utility check Fedora Documentation.

linux CentOSdebianubuntu
Previous Post

RHEL (CentOS) - changing Apache's MPMs

Next Post

Per site custom CSS

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts
  • Flash Tasmota on the Sonoff Mini – Linux user experience
  • DokuWiki a simple solution to sorting documentation
  • I discovered Wireguard
  • Using Let’s Encrypt with CentOS (for now)
  • Let’s Encrypt is Trusted
Categories
  • from the web
  • just blog
  • linux
    • Mail Server Series
  • News
  • phones
  • Phones & Tablets
  • programing
  • security
  • Smart Home
  • Tips & Tricks
  • Uncategorized
  • Web development
  • Windows
Blogroll
  • cheriches.fr
Subscribe by Email
Recent Posts
  • Flash Tasmota on the Sonoff Mini – Linux user experience
  • DokuWiki a simple solution to sorting documentation
  • I discovered Wireguard
  • Using Let’s Encrypt with CentOS (for now)
  • Let’s Encrypt is Trusted
Categories
  • from the web (3)
  • just blog (1)
  • linux (23)
    • Mail Server Series (7)
  • News (1)
  • phones (1)
  • Phones & Tablets (2)
  • programing (1)
  • security (2)
  • Smart Home (1)
  • Tips & Tricks (15)
  • Uncategorized (3)
  • Web development (1)
  • Windows (1)
Blogroll
  • cheriches.fr
Tags cloud
adb ADS aircrack-ng Android Apache apt-get CentOS Chrome ClamAV Cluster CSS Debconf debian DKIM Dovecot EasyRSA EPEL Firefox Firewall GNOME High Availability iptables KVM linux MariaDB Milter MySQL Nginx php Postfix Postfix Admin Proxy_ARP Python release Roundcube Samba SELinux Sonoff SpamAssassin ssh Tasmota ubuntu VRRP windows Youtube
Recent Comments
  • Frank on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Andrew Schott on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Emil C on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Andrew Schott on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
  • Emil C on Dedicated Mail Server Hosting Multiple Domains – Step 3 – Postfix and Dovecot
Proudly powered by WordPress | Theme: Fmi by Forrss.
Manage Cookie Consent
We use cookies to optimize our website and our service.
Functional cookies Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}