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
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”.