Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centos, rhel, oracle: remove previous kernels to minimize image size #1052

Merged
merged 1 commit into from
Jun 5, 2018

Conversation

ceetav
Copy link
Contributor

@ceetav ceetav commented May 23, 2018

yum update keeps several kernel versions installed at the same time by default (installonly_limit).
So, bento/centos-6.9 image v201803.24.0 has two installed kernels: kernel-2.6.32-696.el6.x86_64 and kernel-2.6.32-696.23.1.el6.x86_64 .
Removal of the unused one would reduce the image size by about 50 megs.

  1. The proposal is to delete via package-cleanup from yum-utils, which probably should take care for kernel-uek in the Oracle Linux.

  2. Alternative approach could be direct manipulation:

    unused_kernels=("`rpm -q kernel kernel-uek | grep -v "\`uname -r\`"`")
    if [ ${#unused_kernels[@]} -gt 0 ]; then yum remove -y ${unused_kernels[@]}; fi

bento/centos-6.9 v201803.24.0 kernels

[vagrant@localhost ~]$ rpm -qi kernel
Name        : kernel                       Relocations: (not relocatable)
Version     : 2.6.32                            Vendor: CentOS
Release     : 696.el6                       Build Date: Tue 21 Mar 2017 07:56:16 PM UTC
Install Date: Sat 24 Mar 2018 02:35:41 PM UTC      Build Host: c1bm.rdu2.centos.org
Group       : System Environment/Kernel     Source RPM: kernel-2.6.32-696.el6.src.rpm
Size        : 137522245                        License: GPLv2
Signature   : RSA/SHA1, Thu 23 Mar 2017 03:02:10 PM UTC, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.kernel.org/
Summary     : The Linux kernel
Description :
The kernel package contains the Linux kernel (vmlinuz), the core of any
Linux operating system.  The kernel handles the basic functions
of the operating system: memory allocation, process allocation, device
input and output, etc.

Name        : kernel                       Relocations: (not relocatable)
Version     : 2.6.32                            Vendor: CentOS
Release     : 696.23.1.el6                  Build Date: Tue 13 Mar 2018 11:01:52 PM UTC
Install Date: Sat 24 Mar 2018 02:36:48 PM UTC      Build Host: x86-01.bsys.centos.org
Group       : System Environment/Kernel     Source RPM: kernel-2.6.32-696.23.1.el6.src.rpm
Size        : 139542045                        License: GPLv2
Signature   : RSA/SHA1, Wed 14 Mar 2018 02:39:08 PM UTC, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.kernel.org/
Summary     : The Linux kernel

`yum update` keeps several kernel versions installed at the same time (installonly_limit).
Removing previous kernels drops the image size by about 50 megs.
@cheeseplus
Copy link
Contributor

This looks slick and we'll just need to run it through some light tests to make sure nothing breaks but I think this'll get merged post ChefConf :D

@cheeseplus cheeseplus merged commit 95709b6 into chef:master Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants