我無法進入我的 CentOS 8,無法切換 root,’/sysroot'
我只有圖片。而且我不能很好地寫出問題。
我正在啟動我的筆記型電腦(使用
Windows 10 Pro
andCentOS8
)。
systemctl status initrd-switch-root.service
https://i.stack.imgur.com/fuGRU.jpg
https://i.stack.imgur.com/CAQ7Y.jpg
最後一張圖
Failed to Start Switch Root
。和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
做一個**
ls -al /sysroot
**目錄是空的。我
dmesg
得到了:知道為什麼會發生這種故障嗎?
很明顯,我該如何解決呢?
在圖像中,唯一有效的條目是 Rescue Windows 條目上方的 CentOS 條目
CentOS Linux (0-rescue-***)
請幫忙。
編輯 1:
使用解決方案https://unix.stackexchange.com/a/212710/117555
- 檢查開發->
ls -al /dev/s*
- 插入 U 盤
- 再次檢查->
ls -al /dev/s*
- 創建掛載目錄 ->
mkdir -p /mnt/logError_SwitchRoot
- 安裝棒->
mount /dev/sd[letter][number] /mnt/logError_SwitchRoot
- 複製文件->
cp /run/initramfs/rdsosreport.txt /mnt/logError_SwitchRoot
- 解除安裝棍子->
umount /mnt/logError_SwitchRoot
我現在在https://drive.google.com/file/d/1vMK0QAoyMZ7xTibDqn8Y_Y9nohUStN-6/view?usp=sharing
rdsosreport.txt
上存檔檢查文件:
/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"
和
BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64
編輯 2:
我找到了一些我的安裝圖片(2020 年 7 月 5 日 15:05,供我參考)!
DATA /home nvme0n1p8 SYSTEM /boot/efi nvme0n1p6 /var nvme0n1p10 / nvme0n1p9 /boot nvme0n1p7 swap nvme0n1p11
這是我的資訊(重啟後)
[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 /]#
我有這個清單…
/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 ..
這是另一個列表
/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 ..
我怎麼知道 /sysroot 是什麼?
我沒有
/boot/efi
掛載,也沒有 /boot 目錄!如何掛載/boot/efi?
grub 命令不起作用!
編輯 3:
為了解決這個問題
# grub2-editenv list grub2-editenv: error: invalid environment block. # grub2-editenv set grub2-editenv: error: invalid environment block. #
我關注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 #
編輯 4:
https://www.golinuxcloud.com/update-grub2-grubby-grub2-editenv-rhel-8/ 檢查https://www.techbrown.com/change-default-grub-entries-timeout-centos-rhel/ 有效為了我
# grub2-editenv - set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro"
重啟後
[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 /]#
編輯 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 /]#
對我來說,這條線很奇怪:
saved_entry=fb78af0a9247484aad9831a10a928084-4.18.0-193.14.2.el8_2.x86_64
編輯 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 /]#
明顯有問題!!!該
/efi/EFI/centos/grubenv
文件不存在,/boot/grub2/grubenv
似乎格式錯誤。
根據此連結https://bugzilla.redhat.com/show_bug.cgi?id=1435435 物理文件必須位於/efi/EFI/centos/grubenv
並且符號連結/boot/grub2/grubenv
應指向/efi/EFI/centos/grubenv
.如何創建
/efi/EFI/centos/grubenv
文件,而不直接編輯它?和
[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 /]#
我複製到測試:
# cp /boot/grub2/grubenv /boot/efi/EFI/centos/
條目沒有出現?
我按照這個連結
# 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 /]#
並按照這個答案https://stackoverflow.com/a/64637392
我列出所有
# grubby --info=ALL
我查看一個特定的
# grubby --info 0
檢查我的預設設置
[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 /]#
我試圖用 #
grubby --args amd_iommu=on --update-kernel=/boot/vmlinuz-$(uname -r)
和 with更改預設值,grubby --args amd_iommu=on --update-kernel 2
但它不起作用(使用# grubby --info DEFAULT
)!審查 0 個條目
[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 /]#
並遵循https://unix.stackexchange.com/a/394889/400726
按標題選擇:
[root@centos /]# grub2-editenv - set saved_entry='Red Hat Enterprise Linux (5.12.10-1.el8.elrepo.x86_64) 8.4 (Ootpa)' [root@centos /]#
顯然它改變了。
[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 /]#
重新啟動,但它也不起作用!
審查
[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 /]#
文件已更改,不一樣!
[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 /]#
我在嘗試
[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 /]#
我更喜歡符號連結(但是,我了解情況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 /]#
有什麼解決辦法嗎?
[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 /]#
編輯 7
記住最初的符號連結問題,我需要修復。
這裡我們有 DEFAULT Entry… 作為複制的結果。
[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 /]#
我需要測試更改,但首先我需要檢查所有條目。
[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 /]#
現在,我嘗試更改條目。
[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 /]#
(以前不起作用),現在使用替代方式。
[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 /]#
已解決:
Finally, after restart the changes works!!!
總結一下:
- 您在啟動時進入緊急模式
- 報告的錯誤是:
Failed to switch root: Specified switch root path '/sysroot' does not seem to be an OS tree. os-release file is missing.
- 表示
rdsosreport.txt
實際上沒有安裝任何東西/sysroot
,並且/proc/cmdline
只有一個核心啟動選項:BOOT_IMAGE=(hd1,gpt7)/vmlinuz-5.8.0-1.el8.elrepo.x86_64
.從
rdsosreport.txt
資訊來看,似乎應該至少列出root=UUID=54f24598-4a21-4875-bacd-61c060de891f
或root=/dev/nvme0n1p9
列出類似的內容,以辨識實際的根文件系統。但根本沒有root=
選擇。這表明了一個相對簡單的引導載入程序問題,除非還有其他問題。RHEL/CentOS 8 將此資訊儲存在一個
grubenv
文件中,在像您這樣的 UEFI 系統中,/boot/efi/EFI/centos/grubenv
當所有文件系統都已安裝到其正常位置時,該文件將位於該文件中。該文件應包含如下行:kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro
您不應
grubenv
直接編輯文件,而應使用grub2-editenv
命令:grub2-editenv list
查看設置並grub2-editenv set "kernelopts=root=UUID=54f24598-4a21-4875-bacd-61c060de891f ro"
進行設置。但是要達到可以使用的地步,
grub2-editenv
您首先需要啟動並執行作業系統。當 GRUB 菜單出現時,使用箭頭鍵移動到與您希望使用的核心相對應的行(可能是第一行或第三行)。然後按
E
而不是按Enter
。將顯示引導條目以供編輯。找到以 開頭的行linux /vmlinuz-...
,將游標移動到該行的末尾,然後鍵入空格和root=/dev/nvme0n1p9
。(您也可以使用 UUID 形式,但這樣更難正確輸入。)然後查看螢幕底部以找到將啟動修改條目的擊鍵(如果我沒記錯的話是
Control
+ )。X
如果這可行,您的系統應該可以正常啟動到 CentOS - 僅在這一次。要永久解決該問題,您需要
grubenv
按照上述方法修復該文件。