1

I have only pictures. And I can’t write the Question well.

I was starting my laptop (with Windows 10 Pro and CentOS8).

systemctl status initrd-switch-root.service

https://i.stack.imgur.com/fuGRU.jpg

https://i.stack.imgur.com/CAQ7Y.jpg

The last image Failed to Start Switch Root. And

Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.

https://i.stack.imgur.com/onWbr.jpg

Doing a ls -al /sysroot the directory is empty.

With dmesg i got:

enter image description here

any idea why this failure occurs?

And obviously, how I can solve it?

In the image, the only entry working is Rescue The CentOS entry that is above the Windows entry CentOS Linux (0-rescue-***) enter image description here

Please help.

EDIT 1:

Using solution https://unix.stackexchange.com/a/212710/117555

  1. Check dev -> ls -al /dev/s*
  2. Insert the USB stick
  3. Check Again -> ls -al /dev/s*
  4. Create Mounting Directory -> mkdir -p /mnt/logError_SwitchRoot
  5. Mount the stick -> mount /dev/sd[letter][number] /mnt/logError_SwitchRoot
  6. Copy the File -> cp /run/initramfs/rdsosreport.txt /mnt/logError_SwitchRoot
  7. Umount the stick -> umount /mnt/logError_SwitchRoot

I have now on rdsosreport.txt file on https://drive.google.com/file/d/1vMK0QAoyMZ7xTibDqn8Y_Y9nohUStN-6/view?usp=sharing

Checking the File:

    /dev/nvme0n1p1: LABEL="SYSTEM_DRV" UUID="5464-19F2" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="31ebd6ef-ec98-42c7-a57b-7855c2c9a1f3"
    /dev/nvme0n1p5: LABEL="WINRE_DRV" UUID="C2EC6975EC69651F" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="51363955-3d66-4f95-92de-732ccff36936"
    /dev/nvme0n1p6: LABEL="boot_efi" UUID="6E91-210B" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5291c15b-2f5c-42a0-b3e3-2c69f27b801b"
    /dev/nvme0n1p7: UUID="7471a525-f8c8-4a77-819e-65b40c04eaaf" TYPE="ext4" PARTUUID="13b3a31b-193f-4ef5-9076-a083cdc857de"
    /dev/nvme0n1p8: UUID="d1ee8d12-37a1-43e7-9f13-0f97544864aa" TYPE="ext4" PARTUUID="88cd29e2-3b20-44e4-bdf4-0ce02d9008d6"
    /dev/nvme0n1p9: UUID="54f24598-4a21-4875-bacd-61c060de891f" TYPE="ext4" PARTUUID="d1126852-240f-4e03-a8f3-86f769b3fd77"
    /dev/nvme0n1p10: UUID="3fc5f4f8-566b-48e2-85e1-59f5dccdcb57" TYPE="ext4" PARTUUID="b2190e39-3ee8-4a41-a156-6a866ee8ee14"
    /dev/nvme0n1p11: UUID="42640b78-ce32-403c-8705-8c12e2d02855" TYPE="swap" PARTUUID="acc07fc2-4876-42c0-9d02-b066c04cfd4f"
    /dev/sda1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="5cd547d2-a0ef-4c51-8a00-9877055342bb"
    /dev/nvme0n1: PTUUID="e24c5cda-1faa-490b-b677-7c4792194960" PTTYPE="gpt"
    /dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="b692aa4c-0d83-40f0-8707-cd0b49290b00"
    /dev/nvme0n1p3: PARTLABEL="Basic data partition" PARTUUID="72f573a8-4b1d-40ab-900c-5b2b608fa964"
    /dev/nvme0n1p4: PARTLABEL="Basic data partition" PARTUUID="50badba8-609d-4a24-b957-c8f90b8d7d80"
    /dev/sda2: PARTUUID="f704e2d2-a0b9-4fa4-9b19-cef07c8b6668"

And

BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64

EDIT 2:

I found some pictures of my installation (5 July 2020 15:05, for my reference)!

DATA
    /home
    nvme0n1p8

SYSTEM /boot/efi nvme0n1p6

/var
nvme0n1p10

/
nvme0n1p9

/boot
nvme0n1p7

swap
nvme0n1p11

Here my info (After the restart)

[root@centos /]# lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,UUID,MOUNTPOINT
NAME         MAJ:MIN RM   SIZE RO FSTYPE   UUID                                 MOUNTPOINT
loop0          7:0    0  29.8M  1 squashfs                                      /var/lib/snapd/snap/snapd/8140
loop1          7:1    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1754
loop2          7:2    0  29.9M  1 squashfs                                      /var/lib/snapd/snap/snapd/8542
loop3          7:3    0    55M  1 squashfs                                      /var/lib/snapd/snap/core18/1880
loop4          7:4    0    97M  1 squashfs                                      /var/lib/snapd/snap/core/9665
loop5          7:5    0  62.1M  1 squashfs                                      /var/lib/snapd/snap/gtk-common-themes/1506
nvme0n1      259:0    0   477G  0                                               
├─nvme0n1p1  259:1    0   260M  0 vfat     5464-19F2                            
├─nvme0n1p2  259:2    0    16M  0                                               
├─nvme0n1p3  259:3    0 115.7G  0                                               
├─nvme0n1p4  259:4    0   104G  0                                               
├─nvme0n1p5  259:5    0  1000M  0 ntfs     C2EC6975EC69651F                     
├─nvme0n1p6  259:6    0     1G  0 vfat     6E91-210B                            /boot/efi
├─nvme0n1p7  259:7    0     1G  0 ext4     7471a525-f8c8-4a77-819e-65b40c04eaaf /boot
├─nvme0n1p8  259:8    0   174G  0 ext4     d1ee8d12-37a1-43e7-9f13-0f97544864aa /home
├─nvme0n1p9  259:9    0    32G  0 ext4     54f24598-4a21-4875-bacd-61c060de891f /
├─nvme0n1p10 259:10   0    24G  0 ext4     3fc5f4f8-566b-48e2-85e1-59f5dccdcb57 /var
└─nvme0n1p11 259:11   0    24G  0 swap     42640b78-ce32-403c-8705-8c12e2d02855 [SWAP]
[root@centos /]# 

I have this list...

/tmp/nvme0n1p6/:
total 16
drwxr-xr-x 4 root root 4096 Jan  1  1970 .
drwxr-xr-x 6 root root  120 Jun 11 02:11 ..
drwxr-xr-x 4 root root 4096 Jul  5  2020 EFI
-rwxr-xr-x 1 root root 4096 Jan  1  1980 FSCK0000.REC
drwxr-xr-x 2 root root 4096 Jul 22  2020 System Volume Information

/tmp/nvme0n1p6/EFI: total 16 drwxr-xr-x 4 root root 4096 Jul 5 2020 . drwxr-xr-x 4 root root 4096 Jan 1 1970 .. drwxr-xr-x 2 root root 4096 Jul 5 2020 BOOT drwxr-xr-x 3 root root 4096 Aug 23 2020 centos

/tmp/nvme0n1p6/EFI/BOOT: total 1544 drwxr-xr-x 2 root root 4096 Jul 5 2020 . drwxr-xr-x 4 root root 4096 Jul 5 2020 .. -rwxr-xr-x 1 root root 1211224 May 7 2020 BOOTX64.EFI -rwxr-xr-x 1 root root 356800 May 7 2020 fbx64.efi

/tmp/nvme0n1p6/EFI/centos: total 5360 drwxr-xr-x 3 root root 4096 Aug 23 2020 . drwxr-xr-x 4 root root 4096 Jul 5 2020 .. -rwxr-xr-x 1 root root 134 May 7 2020 BOOTX64.CSV drwxr-xr-x 2 root root 4096 Apr 14 2020 fonts -rwxr-xr-x 1 root root 5502 Jul 5 2020 grub.cfg -rwxr-xr-x 1 root root 0 Aug 23 2020 grubenv -rwxr-xr-x 1 root root 1877384 Apr 14 2020 grubx64.efi -rwxr-xr-x 1 root root 1160136 May 7 2020 mmx64.efi -rwxr-xr-x 1 root root 1205152 May 7 2020 shimx64-centos.efi -rwxr-xr-x 1 root root 1211224 May 7 2020 shimx64.efi

/tmp/nvme0n1p6/EFI/centos/fonts: total 8 drwxr-xr-x 2 root root 4096 Apr 14 2020 . drwxr-xr-x 3 root root 4096 Aug 23 2020 ..

/tmp/nvme0n1p6/System Volume Information: total 8 drwxr-xr-x 2 root root 4096 Jul 22 2020 . drwxr-xr-x 4 root root 4096 Jan 1 1970 ..

And this another List

/tmp/nvme0n1p7/:
total 360344
dr-xr-xr-x 7 root   root      4096 Aug 11  2020 .
drwxr-xr-x 7 root   root       140 Jun 11 02:17 ..
-rw-r--r-- 1 root   root       166 Dec  4  2019 .vmlinuz-4.18.0-147.el8.x86_64.hmac
-rw-r--r-- 1 root   root       172 Jun 10  2020 .vmlinuz-4.18.0-193.6.3.el8_2.x86_64.hmac
drwxrwxrwx 2 nobody 65534     4096 Sep  7  2020 System Volume Information
-rw------- 1 root   root   3838259 Dec  4  2019 System.map-4.18.0-147.el8.x86_64
-rw------- 1 root   root   3910484 Jun 10  2020 System.map-4.18.0-193.6.3.el8_2.x86_64
-rw------- 1 root   root   4654688 Jul  7  2020 System.map-5.7.8-1.el8.elrepo.x86_64
-rw------- 1 root   root   4714527 Aug  2  2020 System.map-5.8.0-1.el8.elrepo.x86_64
-rw-r--r-- 1 root   root    184613 Dec  4  2019 config-4.18.0-147.el8.x86_64
-rw-r--r-- 1 root   root    187643 Jun 10  2020 config-4.18.0-193.6.3.el8_2.x86_64
-rw-r--r-- 1 root   root    197087 Jul  7  2020 config-5.7.8-1.el8.elrepo.x86_64
-rw-r--r-- 1 root   root    201589 Aug  2  2020 config-5.8.0-1.el8.elrepo.x86_64
drwxr-xr-x 2 root   root      4096 Jul  5  2020 efi
drwx------ 2 root   root      4096 Apr 14  2020 grub2
-rw------- 1 root   root  71713525 Jul  5  2020 initramfs-0-rescue-fb78af0a9247484aad9831a10a928084.img
-rw------- 1 root   root  49320247 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64.img
-rw------- 1 root   root  18223920 Jul  6  2020 initramfs-4.18.0-147.el8.x86_64kdump.img
-rw------- 1 root   root  49864041 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64.img
-rw------- 1 root   root  18642820 Jul  6  2020 initramfs-4.18.0-193.6.3.el8_2.x86_64kdump.img
-rw------- 1 root   root  50414753 Jul 15  2020 initramfs-5.7.8-1.el8.elrepo.x86_64.img
-rw------- 1 root   root  50395127 Aug 11  2020 initramfs-5.8.0-1.el8.elrepo.x86_64.img
drwxr-xr-x 3 root   root      4096 Jul  5  2020 loader
drwx------ 2 root   root     16384 Jul  5  2020 lost+found
-rwxr-xr-x 1 root   root   8106744 Jul  5  2020 vmlinuz-0-rescue-fb78af0a9247484aad9831a10a928084
-rwxr-xr-x 1 root   root   8106744 Dec  4  2019 vmlinuz-4.18.0-147.el8.x86_64
-rwxr-xr-x 1 root   root   8913656 Jun 10  2020 vmlinuz-4.18.0-193.6.3.el8_2.x86_64
-rwxr-xr-x 1 root   root   8558528 Jul  7  2020 vmlinuz-5.7.8-1.el8.elrepo.x86_64
-rwxr-xr-x 1 root   root   8742176 Aug  2  2020 vmlinuz-5.8.0-1.el8.elrepo.x86_64

/tmp/nvme0n1p7/System Volume Information: total 12 drwxrwxrwx 2 nobody 65534 4096 Sep 7 2020 . dr-xr-xr-x 7 root root 4096 Aug 11 2020 .. -rw-rw-rw- 1 nobody 65534 76 Sep 7 2020 IndexerVolumeGuid

/tmp/nvme0n1p7/efi: total 8 drwxr-xr-x 2 root root 4096 Jul 5 2020 . dr-xr-xr-x 7 root root 4096 Aug 11 2020 ..

/tmp/nvme0n1p7/grub2: total 8 drwx------ 2 root root 4096 Apr 14 2020 . dr-xr-xr-x 7 root root 4096 Aug 11 2020 .. lrwxrwxrwx 1 root root 25 Apr 14 2020 grubenv -> ../efi/EFI/centos/grubenv

/tmp/nvme0n1p7/loader: total 12 drwxr-xr-x 3 root root 4096 Jul 5 2020 . dr-xr-xr-x 7 root root 4096 Aug 11 2020 .. drwx------ 2 root root 4096 Aug 11 2020 entries

/tmp/nvme0n1p7/loader/entries: total 28 drwx------ 2 root root 4096 Aug 11 2020 . drwxr-xr-x 3 root root 4096 Jul 5 2020 .. -rw-r--r-- 1 root root 395 Jul 5 2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf -rw-r--r-- 1 root root 323 Jul 5 2020 fb78af0a9247484aad9831a10a928084-4.18.0-147.el8.x86_64.conf -rw-r--r-- 1 root root 353 Jul 6 2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf -rw-r--r-- 1 root root 356 Jul 15 2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf -rw-r--r-- 1 root root 356 Aug 11 2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf

/tmp/nvme0n1p7/lost+found: total 20 drwx------ 2 root root 16384 Jul 5 2020 . dr-xr-xr-x 7 root root 4096 Aug 11 2020 ..

How I know what is /sysroot?

I haven't /boot/efi mounted, neither /boot directory!

How I can mount /boot/efi?

grub commands aren't working!

EDIT 3:

To solve this problem

# grub2-editenv list
grub2-editenv: error: invalid environment block.
# grub2-editenv set
grub2-editenv: error: invalid environment block.
# 

I follow https://access.redhat.com/solutions/5622731

# mv /boot/grub2/grubenv /boot/grub2/grubenv.bak
# grub2-set-default 1
# grub2-editenv list
saved_entry=1
# grub2-editenv set
#

EDIT 4:

https://www.golinuxcloud.com/update-grub2-grubby-grub2-editenv-rhel-8/ Checking https://www.techbrown.com/change-default-grub-entries-timeout-centos-rhel/ Works for me

# grub2-editenv - set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro"

After Restart

[root@centos /]# grub2-editenv list
saved_entry=1
boot_success=1
kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet 
[root@centos /]# 

EDIT 5:

[root@centos /]# grub2-editenv list
saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64
boot_success=1
kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet 
boot_indeterminate=1
[root@centos /]# 

For me this line is strange :

saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64

EDIT 6:

[root@centos /]# ls -al /boot/efi/EFI/centos/
total 5820
drwx------. 3 root root    4096 Jun 11 13:50 .
drwx------. 4 root root    4096 Nov 16  2020 ..
-rwx------. 1 root root     134 Jul 31  2020 BOOTX64.CSV
drwx------. 2 root root    4096 Mar  2 16:03 fonts
-rwx------. 1 root root    5502 Jul  5  2020 grub.cfg
-rwx------. 1 root root       0 Aug 23  2020 grubenv.bak
-rwx------. 1 root root 2285336 Mar  2 16:03 grubx64.efi
-rwx------. 1 root root 1162400 Jul 31  2020 mmx64.efi
-rwx------. 1 root root 1238416 Jul 31  2020 shimx64-centos.efi
-rwx------. 1 root root 1244496 Jul 31  2020 shimx64.efi
[root@centos /]# ls -al /boot/grub2/
total 20
drwx------. 2 root root 4096 Jun 12 22:20 .
dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..
-rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg
-rw-------. 1 root root 1024 Jun 12 22:20 grubenv
lrwxrwxrwx. 1 root root   25 Apr 14  2020 grubenv.bak -> ../efi/EFI/centos/grubenv
[root@centos /]# cat /boot/grub2/grubenv
# GRUB Environment Block
saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64
boot_success=1
kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet 
boot_indeterminate=1
#################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#

enter image description here

Obviously something wrong!!! The /efi/EFI/centos/grubenv file does not exist and /boot/grub2/grubenv seems that is malformed.

According to this link https://bugzilla.redhat.com/show_bug.cgi?id=1435435 The physical file must be located in /efi/EFI/centos/grubenv and a symlink /boot/grub2/grubenv should be pointing to /efi/EFI/centos/grubenv.

How to create the /efi/EFI/centos/grubenv file, without editing it directly?

And

[root@centos /]# awk -F\' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg
Windows Boot Manager (on /dev/nvme0n1p1)
System setup
[root@centos /]#

[root@centos /]# awk -F' '/^menuentry/ {print $2}' /boot/efi/EFI/centos/grub.cfg Windows Boot Manager (on /dev/nvme0n1p1) System setup [root@centos /]#

[root@centos /]# grub2-mkconfig -o /boot/grub2/grub.cfg.bck Generating grub configuration file ... Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi Adding boot menu entry for EFI firmware configuration done [root@centos /]#

[root@centos /]# awk -F' '/^menuentry/ {print $2}' /boot/grub2/grub.cfg.bck Windows Boot Manager (on /dev/nvme0n1p1) System setup [root@centos /]#

I copied to test:

# cp /boot/grub2/grubenv /boot/efi/EFI/centos/

The entries not appearing?

I follow this link

# ls -al /boot/loader/entries
total 36
drwx------. 2 root root 4096 Jun 11 13:57 .
drwxr-xr-x. 3 root root 4096 Jul  5  2020 ..
-rw-r--r--. 1 root root  395 Jul  5  2020 fb78af0a9247484aad9831a10a928084-0-rescue.conf
-rw-r--r--. 1 root root  358 Jun 11 11:36 fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64.conf
-rw-r--r--. 1 root root  353 Jul  5  2020 fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64.conf
-rw-r--r--. 1 root root  336 Jun 11 13:57 fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64.conf
-rw-r--r--. 1 root root  366 Jun 11 12:05 fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64.conf
-rw-r--r--. 1 root root  356 Jul 15  2020 fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64.conf
-rw-r--r--. 1 root root  356 Aug 11  2020 fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64.conf
[root@centos /]#

And following this answer https://stackoverflow.com/a/64637392

I list all # grubby --info=ALL

I view a specific # grubby --info 0

Check what was my default

[root@centos /]# grubby --info DEFAULT
index=3
kernel="/boot/vmlinuz-4.18.0-305.3.1.el8.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-4.18.0-305.3.1.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8"
id="fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64"
[root@centos /]#

I was trying to change the default with # grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r) and with grubby --args amd_iommu=on --update-kernel 2 But it does not work (using # grubby --info DEFAULT)!

Reviewing 0 Entry

[root@centos /]# grubby --info 0
index=0
kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"
[root@centos /]#

And following https://unix.stackexchange.com/a/394889/400726

Selecting by title:

[root@centos /]# grub2-editenv - set saved_entry='Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)'
[root@centos /]# 

Apparently it changed.

[root@centos /]# grubby --info DEFAULT
index=0
kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"
[root@centos /]#

Restarting, But it doesn't work either!

Reviewing

[root@centos /]# cmp /boot/efi/EFI/centos/grubenv /boot/grub2/grubenv
/boot/efi/EFI/centos/grubenv /boot/grub2/grubenv differ: byte 38, line 2
[root@centos /]# 

The files has been changed, are different!

[root@centos /]# cat /boot/efi/EFI/centos/grubenv
# GRUB Environment Block
saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64
boot_success=0
kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet 
boot_indeterminate=0
##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#

[root@centos /]# cat /boot/grub2/grubenv

GRUB Environment Block

saved_entry=Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa) boot_success=1 kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet boot_indeterminate=1 ##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################[root@centos /]#

I was trying

[root@centos /]# rm /boot/grub2/grubenv.bak
rm: remove symbolic link '/boot/grub2/grubenv.bak'? y
[root@centos /]#
[root@centos /]# rm /boot/efi/EFI/centos/grubenv.bak
rm: remove regular empty file '/boot/efi/EFI/centos/grubenv.bak'? y
[root@centos /]#

[root@centos /]# ln -s /boot/grub2/grubenv /boot/efi/EFI/centos/grubenv ln: failed to create symbolic link '/boot/efi/EFI/centos/grubenv': Operation not permitted [root@centos /]#

I would have preferred a symlink (But, I undersa tood the situation https://www.linuxquestions.org/questions/suse-opensuse-60/boot-is-not-allowing-symbolic-link-creation-4175682262/#post6166967)!

[root@centos /]# cp /boot/grub2/grubenv /boot/efi/EFI/centos/
[root@centos /]#

Is there some work around?

[root@centos /]# ls -al /boot/grub2/
total 28
drwx------. 2 root root 4096 Jun 12 23:07 .
dr-xr-xr-x. 7 root root 4096 Jun 11 13:58 ..
-rw-r--r--. 1 root root 5503 Jun 11 05:01 grub.cfg
-rw-r--r--. 1 root root 6956 Jun 12 22:59 grub.cfg.bck
-rw-------. 1 root root 1024 Jun 12 22:59 grubenv
[root@centos /]#

[root@centos /]# ls -al /boot/efi/EFI/centos/ total 5824 drwx------. 3 root root 4096 Jun 12 23:09 . drwx------. 4 root root 4096 Nov 16 2020 .. -rwx------. 1 root root 134 Jul 31 2020 BOOTX64.CSV drwx------. 2 root root 4096 Mar 2 16:03 fonts -rwx------. 1 root root 5502 Jul 5 2020 grub.cfg -rwx------. 1 root root 1024 Jun 12 23:06 grubenv -rwx------. 1 root root 2285336 Mar 2 16:03 grubx64.efi -rwx------. 1 root root 1162400 Jul 31 2020 mmx64.efi -rwx------. 1 root root 1238416 Jul 31 2020 shimx64-centos.efi -rwx------. 1 root root 1244496 Jul 31 2020 shimx64.efi [root@centos /]#

EDIT 7

Remembering the original symlink problem, I need to fixed.

enter image description here

Here we have the DEFAULT Entry... as result of copy.

[root@centos /]# grubby --info DEFAULT
index=0
kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"
[root@centos /]#

I need test the changes, but first I need to check all entries.

[root@centos /]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"
index=1
kernel="/boot/vmlinuz-5.8.0-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.8.0-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.8.0-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.8.0-1.el8.elrepo.x86_64"
index=2
kernel="/boot/vmlinuz-5.7.8-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.7.8-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.7.8-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.7.8-1.el8.elrepo.x86_64"
index=3
kernel="/boot/vmlinuz-4.18.0-305.3.1.el8.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-4.18.0-305.3.1.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8"
id="fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64"
index=4
kernel="/boot/vmlinuz-4.18.0-193.14.2.el8_2.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-4.18.0-193.14.2.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.14.2.el8_2.x86_64) 8 (Core)"
id="fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64"
index=5
kernel="/boot/vmlinuz-4.18.0-193.6.3.el8_2.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-4.18.0-193.6.3.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.6.3.el8_2.x86_64) 8 (Core)"
id="fb78af0a9247484aad9831a10a928084-4.18.0-193.6.3.el8_2.x86_64"
index=6
kernel="/boot/vmlinuz-0-rescue-fb78af0a9247484aad9831a10a928084"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-0-rescue-fb78af0a9247484aad9831a10a928084.img"
title="CentOS Linux (0-rescue-fb78af0a9247484aad9831a10a928084) 8 (Core)"
id="fb78af0a9247484aad9831a10a928084-0-rescue"
[root@centos /]#

Now, I try to change the entry.

[root@centos /]# grubby --args amd_iommu=on --update-kernel 3
[root@centos /]# grubby --info DEFAULT
index=0
kernel="/boot/vmlinuz-5.12.10-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-5.12.10-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)"
id="fb78af0a9247484aad9831a10a928084-5.12.10-1.el8.elrepo.x86_64"
[root@centos /]#

(previous doesn't work), now using the alternative manner.

[root@centos /]# grub2-editenv - set saved_entry='CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8'
[root@centos /]# grubby --info DEFAULT
index=3
kernel="/boot/vmlinuz-4.18.0-305.3.1.el8.x86_64"
args="ro crashkernel=auto resume=UUID=42640b78-ce32-403c-8705-8c12e2d02855 rhgb quiet $tuned_params amd_iommu=on"
root="UUID=54f24598-4a21-4875-bacd-61c060de891f"
initrd="/boot/initramfs-4.18.0-305.3.1.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-305.3.1.el8.x86_64) 8"
id="fb78af0a9247484aad9831a10a928084-4.18.0-305.3.1.el8.x86_64"
[root@centos /]#

SOLVED:

Finally, after restart the changes works!!!

  • Can you check and see if this bug report helps? It's for RHEL 7.5, but the error message is identical. – Haxiel Sep 01 '20 at 06:03
  • @Haxiel Thanks, I was checking https://bugzilla.redhat.com/show_bug.cgi?id=1492208 and https://askbot.fedoraproject.org/en/question/112797/specified-switch-root-path-sysroot-does-not-seem-to-be-an-os-tree/. https://www.reddit.com/r/linuxquestions/comments/caf8w8/problem_with_centos_failed_to_switch_root_on_boot/

    My /sysroot is empty, And I don't know where get its content.

    –  Sep 01 '20 at 06:12
  • As far as I know, /sysroot contains the entire OS layout at boot time. A completely empty sysroot could be a serious problem. Is there something unique/custom regarding your setup? Has this configuration worked previously? – Haxiel Sep 01 '20 at 06:47
  • @Haxiel Has this configuration worked previously? Yes! It was functional! Is there something unique/custom regarding your s etup? Like what? –  Jun 11 '21 at 04:14
  • I will check this https://www.systutorials.com/setting-default-entry-in-grub2-and-grub/ –  Jun 13 '21 at 06:28
  • Your question seems to be growing out of the original scope. You originally asked a question about recovering from a failed boot. telcom has answered that query. You now seem to be trying to set the default boot entry - consider asking a separate question for this. – Haxiel Jun 13 '21 at 07:24

2 Answers2

3

To sum up:

  • you are dropping into emergency mode at boot
  • the reported error is:
Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.
  • the rdsosreport.txt indicates there is actually nothing mounted at /sysroot, and /proc/cmdline has only one kernel boot option: BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64.

From the rdsosreport.txt information, it looks like there should be at least root=UUID=54f24598-4a21-4875-bacd-61c060de891f or root=/dev/nvme0n1p9 or something similar listed, to identify the actual root filesystem. But no root= option is there at all. This suggests a relatively simple bootloader issue, unless something else is wrong too.

RHEL/CentOS 8 stores this information in a grubenv file, which in a UEFI system like yours will be at /boot/efi/EFI/centos/grubenv when all the filesystems have been mounted to their normal locations. That file should include a line like:

kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro

You should not edit the grubenv file directly, but use the grub2-editenv command instead: grub2-editenv list to view the settings, and grub2-editenv set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro" to set it.

But to get to the point where you can use grub2-editenv, you'll first need to get the OS up and running.

When the GRUB menu appears, use the arrow keys to move to the line that corresponds to the kernel you wish to use (probably either the first or the third line). Then press E instead of pressing Enter. The boot entry will be displayed for editing. Find the line that starts with linux /vmlinuz-..., move the cursor to the end of that line, and type in a space and root=/dev/nvme0n1p9. (You can use the UUID form too, but that's way harder to type in correctly.)

Then look at the bottom of the screen to find the keystroke that will boot the modified entry (Control+X if I recall correctly).

If this works, your system should boot into CentOS normally - for this time only. To permanently fix the problem, you'll need to fix the grubenv file as outlined above.

telcoM
  • 96,466
  • Did you try that while still in emergency mode, or did you succeed in getting the OS up to the normal state first? – telcoM Jun 11 '21 at 08:33
  • Did you try the instructions to edit the boot entry in the GRUB menu, at the end of my answer? What happened then? Was the systemctl status initrd-switch-root.service result still the same, or was it now different? – telcoM Jun 11 '21 at 08:39
  • I'm sorry! I made a mistake, I omitted a step... E... Already I get access to CentOS 8 again!, But when I try to use grub2-editenv listor grub2-editenv set I get grub2-editenv: error invalid environment block!!! –  Jun 11 '21 at 09:14
  • How do you identify the 54f24598-4a21-4875-bacd-61c060de891f like root? –  Jun 11 '21 at 09:21
  • Your EDIT 2 indicates the root filesystem / is nvme0n1p9, and your rdsosreport.txt gave me its UUID. If the environment block is invalid, that's probably the root cause of your troubles. You might want to view it to perhaps find clues on why it has been corrupted, then delete it (rm /boot/efi/EFI/centos/grubenv) and re-create it with grub2-editenv create /boot/efi/EFI/centos/grubenv, then use grub2-editenv set... as mentioned before to set the kernelopts variable. – telcoM Jun 11 '21 at 09:36
  • Unfortunately the# grub2-editenv - set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro" step is not working for me, as it does not save (or does not store, or does not preserve) the value, and when I restart the computer, I have to do the step of assigning the root root=/dev/nvme0n1p9 again. –  Jun 11 '21 at 16:48
  • Note that there are two possible locations for the environment file: /boot/efi/EFI/centos/grubenv for UEFI systems, and /boot/grub/grubenv for classic BIOS. Apparently Centos's grub2-editenv defaults to the classic BIOS path: make sure you specify the location for grub2-editenv set... command too. – telcoM Jun 12 '21 at 18:13
  • Thanks a lot!!! After of EDIT 7, All works again!!!! Without your help I don't think I could have done it, besides I have learned many other things !!!! Again I am very grateful!!! Maybe the question was prolonged, but I put everything I did as a reference for those who might have similar problems. It is better to have everything that can help. –  Jun 13 '21 at 16:13
0

I have exactly the same problem while kickstart the Rocky 8.6 image :

On the command line I execute following procedure :

  1. Just remount sysroot :
mount -o remount,rw /sysroot
  1. Change init file
vi /sysroot/etc/init.sh
i
#!/bin/bash
exec /sbin/init
  1. Change execute flag :
/sysroot//usr/bin/chmod ugo+x /sysroot/etc/init.sh
  1. Remount ro
mount -o remount,ro /sysroot
  1. Continue booting:
exit

Solved my problems ont the current installation. But I would loke to know why I got this error it seems to be a bug?

Noodle
  • 1