Recover or restore initramfs file in RHEL or CentOS 7
What if "initramfs" file is deleted or corrupted on your RHEL or CentOS 7 ?
Lets know what is initramfs image ?
The INITial RAM Disk (initrd) is an initial root file system that usually get mounted prior to when the real root file system gets available. The "initrd" image is also known as "initramfs (Initial RAM FileSystem)" from RHEL 6.x onwards. The initrd/initramfs gets bound to the kernel and loaded as part of the kernel boot procedure. The kernel then mounts this initrd/initramfs as part of the two-stage boot process to load the modules to make the real file systems available and mount's the real root file system.
Initrd/Initramfs image provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root filesystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root filesystem which was mounted from initrd/initramfs is then moved to a directory and can be subsequently unmounted.
Yes, their are chances that either you might have accidentally deleted "initramfs" file from the /boot partition or it is corrupted due to some reason.
Then boot process will get interrupted and you will see below error:
error: file '/initramfs-3.10.0-957.el7.x86_64.img' not found.
Good news is you can still recover this "initramfs" by following below steps:
Step 1 : Mount RHEL or CentOS 7 ISO image on your physical server and boot from it. In case you are using HPE Prolient server you can mount this ISO image on iLO, if this is virtual environment then mount it accordingly and reboot server or VM from ISO. Once rebooted you will see below options:
Step 2 : Scroll down and select "Troubleshooting" option from menu and PRESS "Enter"
Step 3 : Select "Rescue a CentOS system" and press ENTER:
Step 4 : Press ENTER key again to continue:
Step 5 : To continue, Type "1" and press ENTER, this will bring you to rescue mode, chroot sysimage filesystem using below command:
Looks pretty awesome, thanks!
ReplyDeleteVery helpful thanks
DeleteWow what a great blog, i really enjoyed reading this, good luck in your work. Antigen Test Ket
ReplyDeleteVery excellent blog post. I am thankful for your blog post.
ReplyDeleteodzyskiwanie danych
Thanks Ashish, Keep up the great work
ReplyDeleteThis saved the day, thank you!
ReplyDeleteis it for RHEL7 also...bcoz in RHEL7 we have rescue mode and i think we dont need to attach ISO ...we can just reboot the server and select rescue mode.
ReplyDelete