Upgrading to CentOS 7.7

CentOS

CentOS 7.7 has just been released a few days ago and with any luck CentOS 8 will be released next week. I decided to quickly upgrade one of my dedicated servers from CentOS 7.6 to CentOS 7.7.

Confirm CentOS Version

Just a couple of steps to check what CentOS release we’re running:

root@s2:~ # cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

There should also be a package reflecting CentOS release already installed on your system. This package will be upgraded along with the rest of the OS when we’re stepping up to CentOS 7.7:

root@s2:~ # rpm -qa | grep centos-release
 centos-release-7-6.1810.2.el7.centos.x86_64

Check Available CentOS Upgrades

yum command has the check-update option for verifying if any packages are available for updating:

root@s2:~ # yum check-update

This will return a rather long list. To be super-sure we’ll actually get the CentOS 7.7 upgrade, look for the same centos-release package:

root@s2:~ # yum check-update | grep centos-release
 centos-release.x86_64                    7-7.1908.0.el7.centos           base

Upgrade CentOS 7.6 to CentOS 7.7

We need the yum update command here. After you run it it will resolve dependencies and report something like this, prompting for your confirmation:

Transaction Summary
===============================================================
Install    3 Packages (+25 Dependent packages)
Upgrade  406 Packages
Total download size: 577 M
Is this ok [y/d/N]:

Sounds about right! We’ll press Y and let the server download and apply all the updates…

On my hosting it took about 1min to download all the packages!

Transaction Summary
===============================================================
Install    3 Packages (+25 Dependent packages)
Upgrade  406 Packages
Total download size: 577 M
Is this ok [y/d/N]:
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Updating   : libgcc-4.8.5-39.el7.x86_64                                                                                                       1/841
 Installing : urw-base35-fonts-common-20170801-10.el7.noarch                                                                                   2/841
 Updating   : 1:grub2-common-2.02-0.80.el7.centos.noarch                                                                                       3/841
 Updating   : centos-release-7-7.1908.0.el7.centos.x86_64                                                                                      4/841
 Updating   : langtable-0.0.31-4.el7.noarch                                                                                                    5/841
 Updating   : libreport-filesystem-2.1.11-43.el7.centos.x86_64                                                                                 6/841
...
yum-plugin-fastestmirror.noarch 0:1.1.31-52.el7                           yum-utils.noarch 0:1.1.31-52.el7
 Replaced:
   urw-fonts.noarch 0:2.4-16.el7
 Complete!

It took less than 10 min to apply all the package updates, so the only things left are to capture current kernel version before and after the reboot:

root@s2:/ # uname -a
Linux s2 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Now let’s reboot:

root@s2:/ # shutdown -r now

… and confirm that we’re running newer Linux Kernel and sporting the CentOS 7.7 release now:

greys@s2:~ $ uname -a
Linux s2 3.10.0-1062.1.1.el7.x86_64 #1 SMP Fri Sep 13 22:55:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Hmmm. This does look a bit conservative! It’s 3.10 branch of Linux kernel whereby desktop releases are sporting Linux Kernel 5.x already.

Anyway, that’s server s2 upgraded to CentOS 7.7 successfully!

We’re certainly running the CentOS 7.7 release now:

greys@s2:~ $ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

See Also




How To: Remove Old Kernels in CentOS

CentOS-linux-logo.pngFor dedicated servers and virtual machines that you keep upgrading in-place, you will eventually reach the situation where there’s a number of old kernel packages installed. That’s because when you’re updating OS packages and get new kernel installed, the old ones are not auto-removed – allowing you to fall back if there are issues with the latest kernel.

How To List Old Kernels in CentOS/Red Hat Linux

rpm -q command comes to the resque! just run it for the kernel packages:

root@centos:~ # rpm -q kernel
kernel-3.10.0-327.28.3.el7.x86_64
kernel-3.10.0-327.36.3.el7.x86_64
kernel-3.10.0-693.21.1.el7.x86_64
kernel-3.10.0-957.5.1.el7.x86_64

You can use the uname command to verify the current kernel you’re running:

root@centos:~ # uname -a
Linux centos.ts.fm 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

How To Remove Old Linux Kernels in CentOS

There’s actually a special command for doing this, but it’s probably not installed by default. It’s part of the yum-utils package that you may have to install like this first:

root@centos:~ # yum install yum-utils

Now that it’s installed, we’ll use the package-cleanup command. It takes the number of most recent kernels that you want to keep. So if you want to keep just the currently used kernel, the number should be 1. I recommend you keep 2 kernels – current and the one before it, so the count should be 2.

Just to be super sure, the package-cleanup -oldkernels command will ask you if you’re positive about removing the listed kernel packages before progressing:

root@centos:~ # package-cleanup --oldkernels --count=2
Loaded plugins: fastestmirror, langpacks
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-327.28.3.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-327.36.3.el7 will be erased
--> Finished Dependency Resolution
epel/x86_64/metalink | 22 kB 00:00:00

Dependencies Resolved

===============================================================
Package Arch Version Repository Size
=============================================================== 
Removing:
kernel x86_64 3.10.0-327.28.3.el7 @centos-updates 136 M
kernel x86_64 3.10.0-327.36.3.el7 @updates 136 M

Transaction Summary
=============================================================== 
Remove 2 Packages

Installed size: 272 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : kernel.x86_64 1/2
Erasing : kernel.x86_64 2/2
Verifying : kernel-3.10.0-327.36.3.el7.x86_64 1/2
Verifying : kernel-3.10.0-327.28.3.el7.x86_64 2/2

Removed:
kernel.x86_64 0:3.10.0-327.28.3.el7 kernel.x86_64 0:3.10.0-327.36.3.el7

Complete!

… and yes, don’t worry to be left without any Linux kernels! I checked, and specifying count=0 will not result in the package-cleanup killing your operating system:

root@centos:~ # package-cleanup --oldkernels --count=0
Loaded plugins: fastestmirror, langpacks
Error should keep at least 1 kernel!

That’s it for today. Hope you enjoyed the article!

See Also




yum: List and Install Software Groups

yum-group-list.jpg

yum package manager, and dnf package manager in later Red Hat Linux versions, is quite a capable tool. In addition to expertly resolving dependencies when installing and removing individual software packages (RPMs), yum can also be used to manage whole package groups.

List software groups with yum

Here’s how to get a list of available software groups and also get an indication of which groups you already have installed in your RHEL:

[root@rhel8 ~]# yum group list
Updating Subscription Management repositories.
Updating Subscription Management repositories.
Last metadata expiration check: 0:02:40 ago on Tue 29 Jan 2019 18:38:39 EST.
Available Environment Groups:
Custom Operating System
Server
Installed Environment Groups:
Minimal Install
Workstation
Available Groups:
.NET Core Development
RPM Development Tools
Container Management
Smart Card Support
Scientific Support
Security Tools
Development Tools
System Tools
Headless Management
Network Servers
Legacy UNIX Compatibility
Graphical Administration Tools

Install a software group with yum

Simply using the entries from the list in previous section, you can install software groups like shown below.

IMPORTANT: because these are descriptive names and they have multiple words in mostt group’s names, you must use quotes:

[root@rhel8 ~]# yum group install "Development Tools"
Updating Subscription Management repositories.
Updating Subscription Management repositories.
Last metadata expiration check: 0:02:59 ago on Tue 29 Jan 2019 18:38:39 EST.
Dependencies resolved
===========================================================
Package Arch Version Repository Size
===========================================================
Installing group/module packages:
source-highlight x86_64 3.1.8-16.el8 rhel-8-for-x86_64-appstream-beta-rpms 657 k
autoconf noarch 2.69-27.el8 rhel-8-for-x86_64-appstream-beta-rpms 710 k
perl-Fedora-VSP noarch 0.001-9.el8 rhel-8-for-x86_64-appstream-beta-rpms 25 k
patchutils x86_64 0.3.4-10.el8 rhel-8-for-x86_64-appstream-beta-rpms 115 k
libtool x86_64 2.4.6-25.el8 rhel-8-for-x86_64-appstream-beta-rpms 709 k
bison x86_64 3.0.4-10.el8 rhel-8-for-x86_64-appstream-beta-rpms 688 k
flex x86_64 2.6.1-9.el8 rhel-8-for-x86_64-appstream-beta-rpms 320 k
valgrind x86_64 1:3.14.0-1.el8 rhel-8-for-x86_64-appstream-beta-rpms 11 M
pesign x86_64 0.112-25.el8 rhel-8-for-x86_64-appstream-beta-rpms 181 k
gdb x86_64 8.2-3.el8 rhel-8-for-x86_64-appstream-beta-rpms 296 k
ctags x86_64 5.8-22.el8 rhel-8-for-x86_64-appstream-beta-rpms 170 k
ltrace x86_64 0.7.91-27.el8 rhel-8-for-x86_64-appstream-beta-rpms 160 k
systemtap x86_64 4.0-0.20180830git.el8 rhel-8-for-x86_64-appstream-beta-rpms 17 k
perl-generators noarch 1.10-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 18 k
byacc x86_64 1.9.20170709-4.el8 rhel-8-for-x86_64-appstream-beta-rpms 91 k
rpm-build x86_64 4.14.2-4.el8 rhel-8-for-x86_64-appstream-beta-rpms 166 k
asciidoc noarch 8.6.10-0.5.20180627gitf7c2274.el8 rhel-8-for-x86_64-appstream-beta-rpms 216 k
automake noarch 1.16.1-6.el8 rhel-8-for-x86_64-appstream-beta-rpms 713 k
intltool noarch 0.51.0-11.el8 rhel-8-for-x86_64-appstream-beta-rpms 66 k
diffstat x86_64 1.61-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 44 k
make x86_64 1:4.2.1-9.el8 rhel-8-for-x86_64-baseos-beta-rpms 498 k
rpm-sign x86_64 4.14.2-4.el8 rhel-8-for-x86_64-baseos-beta-rpms 74 k
Installing dependencies:
perl-Thread-Queue noarch 3.13-1.el8 rhel-8-for-x86_64-appstream-beta-rpms 24 k
docbook-style-xsl noarch 1.79.2-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 1.6 M
libXaw x86_64 1.0.13-10.el8 rhel-8-for-x86_64-appstream-beta-rpms 194 k
dyninst x86_64 9.3.2-12.el8 rhel-8-for-x86_64-appstream-beta-rpms 3.7 M
gdb-headless x86_64 8.2-3.el8 rhel-8-for-x86_64-appstream-beta-rpms 3.7 M
guile x86_64 5:2.0.14-7.el8 rhel-8-for-x86_64-appstream-beta-rpms 3.5 M
graphviz x86_64 2.40.1-37.el8 rhel-8-for-x86_64-appstream-beta-rpms 1.7 M
systemtap-runtime x86_64 4.0-0.20180830git.el8 rhel-8-for-x86_64-appstream-beta-rpms 461 k
libipt x86_64 1.6.1-8.el8 rhel-8-for-x86_64-appstream-beta-rpms 50 k
perl-XML-Parser x86_64 2.44-10.el8 rhel-8-for-x86_64-appstream-beta-rpms 226 k
libdwarf x86_64 20180129-4.el8 rhel-8-for-x86_64-appstream-beta-rpms 172 k
systemtap-devel x86_64 4.0-0.20180830git.el8 rhel-8-for-x86_64-appstream-beta-rpms 2.1 M
systemtap-client x86_64 4.0-0.20180830git.el8 rhel-8-for-x86_64-appstream-beta-rpms 3.5 M
libatomic_ops x86_64 7.6.2-3.el8 rhel-8-for-x86_64-appstream-beta-rpms 38 k
docbook-dtds noarch 1.0-69.el8 rhel-8-for-x86_64-appstream-beta-rpms 377 k
nss-tools x86_64 3.39.0-1.0.el8 rhel-8-for-x86_64-appstream-beta-rpms 558 k
libbabeltrace x86_64 1.5.4-2.el8 rhel-8-for-x86_64-appstream-beta-rpms 201 k
gc x86_64 7.6.4-3.el8 rhel-8-for-x86_64-appstream-beta-rpms 109 k
xorg-x11-fonts-ISO8859-1-100dpi noarch 7.5-19.el8 rhel-8-for-x86_64-appstream-beta-rpms 1.1 M
elfutils x86_64 0.174-1.el8 rhel-8-for-x86_64-baseos-beta-rpms 340 k
patch x86_64 2.7.6-7.el8 rhel-8-for-x86_64-baseos-beta-rpms 138 k
m4 x86_64 1.4.18-7.el8 rhel-8-for-x86_64-baseos-beta-rpms 223 k
sgml-common noarch 0.6.3-50.el8 rhel-8-for-x86_64-baseos-beta-rpms 62 k
kernel-debug-devel x86_64 4.18.0-32.el8 rhel-8-for-x86_64-baseos-beta-rpms 12 M
gettext-devel x86_64 0.19.8.1-14.el8 rhel-8-for-x86_64-baseos-beta-rpms 331 k
gettext-common-devel noarch 0.19.8.1-14.el8 rhel-8-for-x86_64-baseos-beta-rpms 419 k
mokutil x86_64 1:0.3.0-9.el8 rhel-8-for-x86_64-baseos-beta-rpms 44 k
Installing weak dependencies:
gcc-gdb-plugin x86_64 8.2.1-3.3.el8 rhel-8-for-x86_64-appstream-beta-rpms 115 k

Transaction Summary
===========================================================
Install 50 Packages

Total download size: 53 M
Installed size: 193 M
Is this ok [y/N]:

That’s it for today! Will show you a few more really cool tricks with yum some other time.

See Also

 




How To Fix Corrupted Packages Database for YUM

I had a server run out of space recently, to the point that it couldn’t complete the yum update. This server ended up corrupting a yum packages database.

Here’s how corrupted YUM database looks

Correctly called rpmdb, packaged database used by YUM looks like this when it can’t be opened:

root@s3:/ # yum update
error: db5 error(11) from dbenv->open: Resource temporarily unavailable
error: cannot open Packages index using db5 - Resource temporarily unavailable (11)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

Rebuilding RPM DB

The fix is to rebuild the RPM database, like this:

root@s3:/ # rpm --rebuilddb

and just to try things, do the same yum update – it should work now:

root@s3:/backup/linux # yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.ate.info
* epel: mirror.1000mbps.com
* extras: rep-centos-fr.upress.io
* updates: centos.mirror.ate.info
Resolving Dependencies
...



How To: Use yum behind proxy

I’ve got a few RedHat and CentOS VMs running on internal network of my server, and since updating them quite regularly is a habit I thought this little piece of advice will help all of you who run VMs in a similar scenario.

To make yum command use proxy, your best best is to edit /etc/yum.conf and add your proxy server reference:

proxy=http://192.168.3.1:3128

You don’t have to restart anything but it may be a good idea to do yum clean all and then yum check-update:

[root@testvm1 ~]# yum check-update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: be.mirror.eurid.eu
* epel: epel.uni-oldenburg.de
* extras: be.mirror.eurid.eu
* updates: centosa5-msync-dvd.centos.org
base                                         | 3.7 kB 00:00
base/primary_db                              | 4.5 MB 00:01
cr                                           | 3.0 kB 00:00
cr/primary_db                                | 1.2 kB 00:00
epel                                         | 3.4 kB 00:00
epel/primary_db                              | 3.7 MB 00:00
extras                                       | 3.5 kB 00:00
extras/primary_db                            | 6.3 kB 00:00
updates                                      | 3.5 kB 00:00
updates/primary_db                           | 1.8 MB 00:01