[CentOS] Fwd: 8.2.2004 Quick recovery and fix for unbootable machines with rescue disk

Sun Aug 2 21:06:25 UTC 2020
Gregory P. Ennis <PoMec at PoMec.Net>

Hello all--
These instructions are somewhat OK but my messed up box is the only one
I've got basically to help with this problem.

Where can we find "correction" instructions using a "rescue" CD or flash
drive? I understand RedHat provided detailed instructions to supported
customers.

Thanks.

_______________________
Sent from MzK's phone.

---------- Forwarded message ---------
From: Alan McRae via CentOS <centos at centos.org>
Date: Sat, Aug 1, 2020, 19:22
Subject: [CentOS] 8.2.2004 Quick recovery and fix for unbootable machines
To: CentOS mailing list <centos at centos.org>


This is a quick recovery and fix for the machines rendered unbootable
after the grub2/shim yum update.

It is written for CentOS 8.2.2004 but similar should work for any CentOS
8 or 7 as long as you get the correct shim file,
that is, the one from the latest installation media.

I am running on an x86_64 architecture (see uname -i). Please use the
correct shim file for your architecture (shim-<arch>-15-11.el8.<arch>.rpm)

I have tested this by breaking a machine and then recovering it. It
works for me.

I hope someone finds it useful. Let me know.

Regards
Alan

HOW TO BOOT AN UNBOOTABLE MACHINE
=================================

1) Download a copy of rEFind. This is a UEFI boot manager. Burn it to a
USB key.

# wget -O refind.zip
http://sourceforge.net/projects/refind/files/0.12.0/refind-flashdrive-0.12.0.zip/download
# unzip refind.zip
# cd refind-flashdrive-0.12.0
# dd if=refind-flashdrive-0.12.0.img bs=4096 of=/dev/sdX (sdX is the
device for your USB key, this will be erased, use the whole device use
sdX not sdX1)
1800+0 records in
1800+0 records out
7372800 bytes (7.4 MB, 7.0 MiB) copied, 0.980893 s, 7.5 MB/s

2) Turn off secureboot in your UEFI hardware.

3) Boot the USB key. You should get a colourful screen with icons and a
filename below.

Use the left/right arrow keys to select the correct grubx64.efi.
Hit space to boot.

Your usual grub menu should appear and the system should boot normally.

HOW TO FIX THE PROBLEM
=====================

1) We need to downgrade the shim package. Now your system is running get
an older copy of the correct shim package for your architecture
from the CentOS installation media (e.g.
CentOS-8.2.2004-x86_64-dvd1.iso) and install it.

# mount CentOS-8.2.2004-x86_64-dvd1.iso /mnt
# cd /mnt/BaseOS/Packages
# cp shim-x64-15-11.el8.x86_64.rpm /root
# cd /root
# umount /mnt

OR

Get the package from a CentOS mirror:

# cd /root
# wget
http://ucmirror.canterbury.ac.nz/linux/CentOS/8.2.2004/BaseOS/x86_64/os/Packages/shim-x64-15-11.el8.x86_64.rpm

2) We can now reinstall the older shim package using yum. This will
downgrade the package to the working version.

# yum install shim-x64-15-11.el8.x86_64.rpm

Last metadata expiration check: 2:11:11 ago on Sun 02 Aug 2020 11:31:06
NZST.
Dependencies resolved.

===========================================================================================
=========================================================================================
  Package Architecture Version
Repository                                     Size
===========================================================================================
=========================================================================================
Downgrading:
  shim-x64 x86_64 15-11.el8
@commandline                                  647 k

Transaction Summary
===========================================================================================
=========================================================================================
Downgrade  1 Package

Total size: 647 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
   Preparing : 1/1
   Downgrading      : shim-x64-15-11.el8.x86_64 1/2
   Cleanup          : shim-x64-15-13.el8.x86_64 2/2
   Verifying        : shim-x64-15-11.el8.x86_64 1/2
   Verifying        : shim-x64-15-13.el8.x86_64 2/2
Installed products updated.

Downgraded:
shim-x64-15-11.el8.x86_64

Complete!

3) Your system should now boot normally.

4) add "exclude=shim*" to /etc/yum.conf to prevent the broken one being
reinstalled.  You should now be able to run 'yum update'. Remove the
exclude= when a proper fix becomes available.

_______________________________________________

Dear List,

I have had 6 of these problems and am on my way to the office to fix two more.

Here is what I did with an installation disc along with the advise from the posts of Johny
Hughes.  So far this has been easy to do and has worked every time.  Make sure your system
is connected to the network, and know your gateway address and a reasonable ip address of
the machine for your network.

#1. Boot to tine Install Disc and pick "Recovery Mode"

#2. You will be given several options of recover Pick #1 to Continue

#3. Use the 'chroot /mnt/sysimage' command to get into  your system

#4. Activate  your network

Find the device name you are going to use

ip link
gives you the name as in 'enp3s0' as the device

ip link set dev enpo3s0 up
activates the network card

ip address add 10.0.0.67/24 dev enp3s0
sets the card's address to 10.0.0.67 with a subnet mask of 255.255.255.0

ip route add default via 10.0.0.124
sets the gateway for your machine to 10.0.0.124

#5. Make sure you have an active domain name service

cd /etc/

vim resolv.conf

Edit the appropriate value of 
nameserver 10.0.0.124

(in my case the nameserver and gateway were the same machine)

#6. Use of Yum
yum clean all
This necessary so that you can make sure you have the latest listings

yum install shim

For Centos 7 you want shim-x64-15-8.el7.x86_64 which Johnny Hughes just released today.

When this  is installed  you will also install mokutil-15-8.el7.x86_64

#7. Exit out of recovery mode, and reboot.

This has worked for me every time.

Thanks to everyone's advice on this list and all the good work done by the Centos Team!!!!

Greg Ennis