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.

<think>好的,用户遇到了Maven构建错误,主要涉及无法解析`spring-boot-starter-test`和`spring-boot-starter-web`这两个依赖项的版本问题。我需要先分析错误信息,找出可能的原因,并提供解决方案。 首先,错误信息显示`Failed to read artifact descriptor`,通常是因为Maven无法找到对应的依赖版本。用户的项目可能没有正确指定Spring Boot的版本,或者父POM中没有正确配置版本管理。在之前的对话中,用户提供的common模块的pom.xml确实继承了父项目,但父项目的pom.xml可能存在版本缺失的问题。 接下来,注意到错误中提到了`version: unknown`,这表明Maven无法确定依赖的版本。这可能是因为在子模块中直接声明了这些依赖,但没有指定版本,而父POM的`dependencyManagement`部分也没有正确管理这些依赖的版本。例如,如果父项目是Spring Boot项目,应该使用`spring-boot-starter-parent`作为父POM,或者在`dependencyManagement`中导入Spring Boot的BOM(Bill of Materials),这样依赖的版本就会自动管理,无需手动指定。 另外,用户可能在父POM或子模块的依赖声明中遗漏了版本号。例如,在父POM的`dependencyManagement`里正确声明Spring Boot的版本,或者在子模块的依赖中明确指定版本号。此外,用户需要检查Maven的settings.xml文件,确保仓库配置正确,没有被网络问题或仓库地址错误所影响。 解决方案可能包括以下几个步骤:首先,确认父POM是否正确配置了Spring Boot的版本管理;其次,在子模块的依赖中要么继承父POM的版本管理,要么显式指定版本号;第三,检查网络连接和Maven仓库配置,确保能够正确下载依赖;最后,执行Maven的清理和重新构建命令,如`mvn clean install -U`,强制更新依赖。 此外,还需要提醒用户检查IDE中的Maven配置,确保使用的是正确的Maven版本和本地仓库路径。如果问题仍然存在,建议手动删除本地仓库中相关的依赖目录,然后重新构建项目,强制Maven重新下载依赖。</think>--- ### **问题分析** 您遇到的 Maven 错误主要与依赖版本解析失败有关,核心问题是:**Spring Boot 相关依赖的版本号未被正确指定**,导致 Maven 无法找到对应的依赖包。以下是分步解决方案: --- ### **1. 根本原因定位** #### **错误现象** ``` [ERROR] Failed to read artifact descriptor for org.springframework.boot:spring-boot-starter-test:jar:unknown [ERROR] Maven model problem: 'dependencies.dependency.version' for ... is missing ``` #### **直接原因** - 依赖项未声明版本号(如 `<version>` 标签缺失) - 父 POM 未通过 `<dependencyManagement>` 统一管理版本 #### **深层原因** - Maven 依赖继承机制未正确配置 - Spring Boot 父项目(或 BOM)未引入 --- ### **2. 解决方案** #### **方法 1:通过父项目统一管理版本(推荐)** 在**父项目**的 `pom.xml` 中添加 Spring Boot 版本控制: ```xml <parent> <!-- 继承 Spring Boot 官方父项目 --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.1.5</version> <!-- 根据需求选择版本 --> <relativePath/> <!-- 从仓库查找,非本地路径 --> </parent> ``` - **作用**:自动继承 Spring Boot 所有依赖的标准版本 - **验证**:子模块依赖无需写 `<version>`,例如: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> ``` #### **方法 2:手动指定版本号** 在子模块或父项目的 `<dependencies>` 中显式声明版本: ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>3.1.5</version> <!-- 需与 spring-boot-starter-web 版本一致 --> <scope>test</scope> </dependency> ``` - **缺点**:版本号分散,维护成本高 #### **方法 3:通过 BOM 管理依赖(适合多模块项目)** 在父项目的 `<dependencyManagement>` 中导入 Spring Boot BOM: ```xml <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>3.1.5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ``` - **优势**:集中管理所有 Spring Boot 相关依赖版本 --- ### **3. 验证步骤** 1. **清理本地仓库缓存** ```bash mvn dependency:purge-local-repository ``` 2. **强制更新依赖** ```bash mvn clean install -U ``` 3. **检查依赖树** ```bash mvn dependency:tree -Dincludes=org.springframework.boot ``` --- ### **4. 附加排查** #### **检查网络与仓库配置** - 确认 Maven `settings.xml` 中仓库地址可访问(如阿里云镜像) ```xml <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> ``` #### **检查 IDE 配置** - 在 IntelliJ/Eclipse 中刷新 Maven 项目 - 确保 IDE 使用的 Maven 版本与命令行一致 --- ### **5. 典型错误修复示例** 假设父项目 `xiaozhong_dianping/pom.xml` 缺少版本管理,修复后结构应类似: ```xml <project> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.1.5</version> </parent> <groupId>com.fudan</groupId> <artifactId>xiaozhong_dianping</artifactId> <version>0.0.1-SNAPSHOT</version> <modules> <module>common</module> <module>server</module> </modules> <!-- 其他配置 --> </project> ``` --- ### **总结** 通过统一管理 Spring Boot 依赖版本(推荐使用父项目继承或 BOM 导入),可彻底解决 `version:unknown` 问题。修复后,Maven 将自动解析正确的依赖版本。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值