habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

1 min read

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel update error. With details as below:

Message from syslogd@myserver_hostname at Aug 16 14:18:39 ...
 dracut:dracut: creation of /boot/initramfs-3.10.0-1160.119.1.el7.x86_64.img failed
/sbin/dracut: line 1670: cpio: command not found
dracut: creation of /boot/initramfs-3.10.0-1160.119.1.el7.x86_64.img failed
mkinitrd failed
ERROR: installing kernel-3.10.0-1160.119.1.el7.x86_64: no space left for creating initramfs. Clean up /boot partition and re-run '/usr/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --install 3.10.0-1160.119.1.el7.x86_64'
warning: %posttrans(kernel-3.10.0-1160.119.1.el7.x86_64) scriptlet failed, exit status 1
Non-fatal POSTTRANS scriptlet failure in rpm package kernel-3.10.0-1160.119.1.el7.x86_64
Centos failed update kernel

After reading the error in detail, it seems that the error occurred because the “cpio” package was not/has not been installed. Or it could be that the “cpio” installation package is damaged. So it cannot copy the latest kernel update results into the /boot system.

Then the second error, I found to be asked to “Clean up /boot partition”. and re-run “/usr/sbin/new-kernel-pkg …”

To solve this problem, what I did was as follows.

Install/reinstall cpio.

The error written is clear, that “yum update kernel” cannot be successful because it is considered that the “cpio” package does not exist. To overcome this, install/reinstall the package.

yum reinstall cpio
ls -al /usr/bin/cpio

Clean up /boot partition and re-run ‘/usr/sbin/new-kernel-pkg’

To clean up /boot partition, follow the steps below.

Install yum-utils

yum install yum-utils

Clean Some Old Kernel

Before clean kernel, show list of kernel.

rpm -q kernel

Now we can clean some old kernel packages, to be on the safe side I would recommend keeping the --count argument to at least 2:

package-cleanup --oldkernels --count=2

This is pretty much it, you can then go ahead and update your kernel as normal:

yum -y update kernel kernel-headers

Please note that you would need to reboot your server in order for the change to take effect.

Re-run /usr/sbin/new-kernel-pkg

If still get error, re-run /usr/sbin/new-kernel-pkg manually.

/usr/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --install YOUR_KERNEL_UPDATE_VERSION_IN_ERROR_MESSAGE

Example:

/usr/sbin/new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --install 3.10.0-1160.119.1.el7.x86_64

Wait a moment. After install finish and no error, plase “reboot”.

habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox