boot 错误修复方法 汇总:boot-repair,sh命令(** 笔记 **)

grub rescue的解决办法 (**)

------------------------------------------------------------------

目的

问题:为了解决 VMware强制关机时,导致 /boot 文件夹的部分文件丢失问题。

Ubuntu 在屏保后,OS 的电源按钮,只能进入 挂起 状态。

而通过 VMware的电源按钮,则进入强制关机:这是造成 /boot 异常的原因吗?

期望:只是备份和恢复 /boot 文件夹就可以了。

状态:

未解决

临时办法:

使用 redo rescue 进行整个系统备份。

特别注意:

1. boot-repair 只能作为“应急处理” 吗 ?

   下载:https://sourceforge.net/projects/boot-repair-cd/

要点:

1. 直接使用 boot-repair-disk。如果使用 Ubuntu livd cd 的 “Try Ubuntu” 启动,可能会出现如下错误:

这又要执行一批命令,太麻烦了。

------------------------------------------------------------------------

grub rescue的解决办法 (**)

  https://zhuanlan.zhihu.com/p/31996206

第(一)种方法: 

  • 敲重点!!这步往下我就进行不下去了,因为显示指令无效,其实结论是

/boot/grub/i386-pc/normal.mod的丢失,有人提供方法直接insmod normal

或者insmod /grub 找到所有.mod文件,亲测无效,放弃进入第(二)种方法。

第(二)种方法:使用Boot-Repair引导修复工具

在 VMware 中,同样无效啊??

=========================================

boot 错误修复方法 汇总:boot-repair,sh命令(** 笔记 **)

 需要在 BIOS 中,修改为 UEFI 启动。

但是,在 VMware 的 BIOS 中,似乎不能设置 UEFI 项。只能在实体机中吗?

 

特别注意:这个工具,使用的是 "标准 EFI" 文件,意味着可能会缺失许多的 boot 未崩溃前的功能。

只能作为“应急处理”?

使用其他方法,及时将最新的 /boot 目录给备份出来,这才是正确的做法?

在 boot-repair-disk lice cd 中的对应关系

gparted

Boot-Info_20211101_0551.txt

/media/lubuntu/e054f2da-ed4c-4742-b594-073a4cfbbc6a

boot-repair-4ppa125                                              [20211101_0551]

============================== Boot Info Summary ===============================

 => Grub2 (v2.00) is installed in the MBR of /dev/sda and looks at sector 2048
    of the same hard drive for core.img. core.img is at this location and
    looks for (,gpt3)/boot/grub. It also embeds following components:
    
    modules
    ---------------------------------------------------------------------------
    fshelp ext2 part_gpt biosdisk
    ---------------------------------------------------------------------------

sda1: __________________________________________________________________________

    File system:       BIOS Boot partition
    Boot sector type:  Grub2's core.img
    Boot sector info:

sda2: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /efi/BOOT/fbx64.efi /efi/BOOT/mmx64.efi
                       /efi/ubuntu/grubx64.efi /efi/ubuntu/mmx64.efi
                       /efi/ubuntu/shimx64.efi /efi/ubuntu/grub.cfg

sda3: __________________________________________________________________________

    File system:       ext4
    Boot sector type:  -
    Boot sector info:
    Operating System:  Ubuntu 22.04.3 LTS
    Boot files:        /boot/grub/grub.cfg /etc/fstab /etc/default/grub
                       /boot/grub/i386-pc/core.img


================================ 1 OS detected =================================

OS#1:   Ubuntu 22.04.3 LTS on sda3

============================ Architecture/Host Info ============================

CPU architecture: 64-bit
Live-session OS is Ubuntu 64-bit (Boot-Repair-Disk 64bit 20200604, bionic, x86_64)


===================================== UEFI =====================================

This live-session is not in EFI-mode.

a9c517741ac31962d7feb152948ad1ee   sda2/BOOT/fbx64.efi
a660182adef313615746a665966d2ccc   sda2/BOOT/mmx64.efi
5ddf997e8b025bfbc2009e85b32f60dc   sda2/ubuntu/grubx64.efi
a660182adef313615746a665966d2ccc   sda2/ubuntu/mmx64.efi
64349b3622c65f495a99dbf6102496e3   sda2/ubuntu/shimx64.efi
64349b3622c65f495a99dbf6102496e3   sda2/BOOT/BOOTX64.efi


============================= Drive/Partition Info =============================

Disks info: ____________________________________________________________________

sda    : is-GPT,    hasBIOSboot,    has---ESP,     not-usb,    not-mmc, has-os,    2048 sectors * 512 bytes

Partitions info (1/3): _________________________________________________________

sda2    : no-os,    32, nopakmgr,    no-docgrub,    nogrub,    nogrubinstall,    no-grubenv,    noupdategrub,    not-far
sda3    : is-os,    64, apt-get,    signed grub-pc grub-efi ,    grub2,    grub-install,    grubenv-ok,    update-grub,    not-far
fd0    : no-os,    32, nopakmgr,    no-docgrub,    nogrub,    nogrubinstall,    no-grubenv,    noupdategrub,    not-far

Partitions info (2/3): _________________________________________________________

sda2    : is---ESP,    part-has-no-fstab,    no-nt,    no-winload,    no-recov-nor-hid,    no-bmgr,    notwinboot
sda3    : isnotESP,    fstab-has-goodEFI,    no-nt,    no-winload,    no-recov-nor-hid,    no-bmgr,    notwinboot
fd0    : isnotESP,    part-has-no-fstab,    no-nt,    no-winload,    no-recov-nor-hid,    no-bmgr,    notwinboot

Partitions info (3/3): _________________________________________________________

sda2    : not-sepboot,    no-boot,    part-has-no-fstab,    not-sep-usr,    no---usr,    part-has-no-fstab,    std-grub.d,    sda
sda3    : not-sepboot,    with-boot,    fstab-without-boot,    not-sep-usr,    with--usr,    fstab-without-usr,    std-grub.d,    sda

### 下面的是软盘信息,不需要的?
fd0    : not-sepboot,    no-boot,    part-has-no-fstab,    not-sep-usr,    no---usr,    part-has-no-fstab,    std-grub.d,    sda

fdisk -l (filtered): ___________________________________________________________

Disk fd0: 1.4 MiB, 1474560 bytes, 2880 sectors
Disk identifier: 0x90909090
      Boot      Start        End    Sectors  Size Id Type
fd0p1      2425393296 4850786591 2425393296  1.1T 90 unknown
fd0p2      2425393296 4850786591 2425393296  1.1T 90 unknown
fd0p3      2425393296 4850786591 2425393296  1.1T 90 unknown
fd0p4      2425393296 4850786591 2425393296  1.1T 90 unknown

### ================

  
Disk sda: 32 GiB, 34359738368 bytes, 67108864 sectors
Disk identifier: 1FE7F8EC-3EB8-4A33-90E2-1B4FE3B28473
        Start      End  Sectors  Size Type
sda1     2048     4095     2048    1M BIOS boot
sda2     4096  1054719  1050624  513M EFI System
sda3  1054720 67106815 66052096 31.5G Linux filesystem
Disk zram0: 489.9 MiB, 513638400 bytes, 125400 sectors
Disk zram1: 489.9 MiB, 513638400 bytes, 125400 sectors

parted -lm (filtered): _________________________________________________________

sda:34.4GB:scsi:512:512:gpt:VMware, VMware Virtual S:;
1:1049kB:2097kB:1049kB:::bios_grub;
2:2097kB:540MB:538MB:fat32:EFI System Partition:boot, esp;
3:540MB:34.4GB:33.8GB:ext4::;
zram1:514MB:unknown:4096:4096:loop:Unknown:;
1:0.00B:514MB:514MB:linux-swap(v1)::;
sr0:923MB:scsi:2048:2048:msdos:NECVMWar VMware SATA CD00:;
2:1974kB:12.1MB:10.1MB:::esp;
zram0:514MB:unknown:4096:4096:loop:Unknown:;
1:0.00B:514MB:514MB:linux-swap(v1)::;

blkid (filtered): ______________________________________________________________

NAME   FSTYPE   UUID                                 PARTUUID                             LABEL                  PARTLABEL
fd0                                                                                                              
sda                                                                                                              
├─sda1                                               5b677115-2e6f-4e66-94a6-e8682503d7a7                        
├─sda2 vfat     BB46-7FB9                            daa9c3cb-e28d-466c-a6ac-bec4574363d0                        EFI System Partition
└─sda3 ext4     e054f2da-ed4c-4742-b594-073a4cfbbc6a 368c5571-9150-4eee-ba24-d67ab0677596                        
zram0                                                                                                            
zram1                                                                                                            

df (filtered): _________________________________________________________________

       Avail Use% Mounted on
fd0      1.4M   1% /mnt/boot-sav/fd0
sda2   505.9M   1% /mnt/boot-sav/sda2
sda3    14.6G  48% /mnt/boot-sav/sda3

Mount options: __________________________________________________________________

fd0    rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
sda2   rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
sda3   rw,relatime

===================== sda2/efi/ubuntu/grub.cfg (filtered) ======================

search.fs_uuid e054f2da-ed4c-4742-b594-073a4cfbbc6a root hd0,gpt3
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

====================== sda3/boot/grub/grub.cfg (filtered) ======================

Ubuntu   e054f2da-ed4c-4742-b594-073a4cfbbc6a
Ubuntu, with Linux 6.2.0-36-generic   e054f2da-ed4c-4742-b594-073a4cfbbc6a
Ubuntu, with Linux 6.2.0-26-generic   e054f2da-ed4c-4742-b594-073a4cfbbc6a
### END /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_uefi-firmware ###

========================== sda3/etc/fstab (filtered) ===========================

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=e054f2da-ed4c-4742-b594-073a4cfbbc6a /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda2 during installation
UUID=BB46-7FB9  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

======================= sda3/etc/default/grub (filtered) =======================

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US"

==================== sda3: Location of files loaded by Grub ====================

           GiB - GB             File                                 Fragment(s)
  11.880283356 = 12.756357120   boot/grub/grub.cfg                             1
  28.753894806 = 30.874259456   boot/grub/i386-pc/core.img                     1
  13.054840088 = 14.017527808   boot/vmlinuz                                   1
  16.757938385 = 17.993699328   boot/vmlinuz-6.2.0-26-generic                  1
  13.054840088 = 14.017527808   boot/vmlinuz-6.2.0-36-generic                  1
  16.757938385 = 17.993699328   boot/vmlinuz.old                               1
  11.832897186 = 12.705476608   boot/initrd.img                                1
  18.628787994 = 20.002508800   boot/initrd.img-6.2.0-26-generic               2
  11.832897186 = 12.705476608   boot/initrd.img-6.2.0-36-generic               1
  18.628787994 = 20.002508800   boot/initrd.img.old                            2

===================== sda3: ls -l /etc/grub.d/ (filtered) ======================

-rwxr-xr-x 1 root root 18683 Dec 18  2022 10_linux
-rwxr-xr-x 1 root root 43031 Dec 18  2022 10_linux_zfs
-rwxr-xr-x 1 root root 14387 Dec 18  2022 20_linux_xen
-rwxr-xr-x 1 root root 13369 Dec 18  2022 30_os-prober
-rwxr-xr-x 1 root root  1372 Dec 18  2022 30_uefi-firmware
-rwxr-xr-x 1 root root   700 May 17 05:35 35_fwupd
-rwxr-xr-x 1 root root   214 Dec 18  2022 40_custom
-rwxr-xr-x 1 root root   215 Dec 18  2022 41_custom

=========================== sda3/etc/grub.d/35_fwupd ===========================

#! /bin/sh
# SPDX-License-Identifier: LGPL-2.1+
set -e
[ -d ${pkgdatadir:?} ]
# shellcheck source=/dev/null
. "$pkgdatadir/grub-mkconfig_lib"
if [ -f /var/lib/fwupd/uefi_capsule.conf ] &&
   ls /sys/firmware/efi/efivars/fwupd-*-0abba7dc-e516-4167-bbf5-4d9d1c739416 1>/dev/null 2>&1; then
      . /var/lib/fwupd/uefi_capsule.conf
      if [ "${EFI_PATH}" != "" ] && [ "${ESP}" != "" ]; then
      echo "Adding Linux Firmware Updater entry" >&2
cat << EOF
menuentry 'Linux Firmware Updater' \$menuentry_id_option 'fwupd' {
EOF
      ${grub_probe:?}
      prepare_grub_to_access_device '`${grub_probe} --target=device \${ESP}` | sed -e "s/^/\t/"'
cat << EOF
    chainloader ${EFI_PATH}
}
EOF
      fi
fi


=============================== StdErr Messages ================================

File descriptor 63 (pipe:[46541]) leaked on lvs invocation. Parent PID 1866: /bin/bash

Suggested repair: ______________________________________________________________

The default repair of the Boot-Repair utility would reinstall the grub-efi-amd64-signed of
sda3,
using the following options:        sda2/boot/efi,
Additional repair would be performed: unhide-bootmenu-10s  use-standard-efi-file    

Blockers in case of suggested repair: __________________________________________

 The current session is in BIOS-compatibility mode. Please disable BIOS-compatibility/CSM/Legacy mode in your UEFI firmware, and use this software from a live-CD (or live-USB) that is compatible with UEFI booting mode. For example, use a live-USB of Boot-Repair-Disk-64bit (www.sourceforge.net/p/boot-repair-cd), after making sure your BIOS is set up to boot USB in EFI mode. This will enable this feature.

Confirmation request before suggested repair: __________________________________

The boot of your PC is in BIOS-compatibility/CSM/Legacy mode. You may want to retry after changing it to EFI mode.
Are you sure you want to continue anyway?

Final advice in case of suggested repair: ______________________________________


Please do not forget to make your UEFI firmware boot on the Ubuntu 22.04.3 LTS entry (sda2/efi/****/shim****.efi (**** will be updated in the final message) file) !
The boot of your PC is in BIOS-compatibility/CSM/Legacy mode. You may want to retry after changing it to UEFI mode.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值