You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

查询GRUB确切位置及解决磁盘镜像复制后GRUB无法启动问题

How to Locate GRUB's Embedded Components (and Fix Your Boot Issue)

Hey there, let's tackle this GRUB rescue problem step by step. First, to find exactly where GRUB stores its extra components outside the MBR, you'll need to work from your original working VirtualBox Ubuntu Server image (since your server is stuck in rescue mode right now). Here are the methods to pinpoint those locations:

1. Check Partition Layout to Identify the Unused Gap

First, confirm where your first partition starts—this defines the gap between the MBR and the first partition where GRUB embeds its core.img:

sudo fdisk -l /dev/sda

Look for the Start value (in sectors) of your first partition (usually /dev/sda1 if it's the LVM PV). For example, if the start sector is 2048, that means:

  • MBR occupies sectors 0 (512 bytes total: bytes 0-511)
  • The gap between MBR and first partition is sectors 1 to 2047 (total 2047 sectors, ~1MB)
  • This gap is where GRUB typically stores its embedded components like core.img.

2. Use GRUB's Debug Install Output to See Exact Placement

Run a debugged grub-install command on your working system to get precise details about where GRUB installs its components:

sudo grub-install --debug /dev/sda 2>&1 | grep -E "(embed sector|core.img)"

The output will show you the exact sector range where GRUB embeds its core image. For example, you might see lines like:

embedding core.img in sectors 1-127 of /dev/sda

3. Verify the Gap Content Directly

You can extract the gap content and confirm it's GRUB-related with these commands (replace 2048 with your first partition's start sector):

# Extract the gap between MBR and first partition
sudo dd if=/dev/sda of=grub_embed.img bs=512 skip=1 count=$((2048 - 1))
# Check what's in the extracted file
file grub_embed.img

If the output mentions GRUB boot loader, that confirms this is the embedded GRUB component area.

Quick Fix for Your Server Boot Issue

Since you only copied the MBR and LVM PV, you missed this embedded GRUB data. The easiest way to fix this is:

  • Boot your server from an Ubuntu Server live USB
  • Mount your LVM root filesystem
  • Chroot into the mounted system
  • Reinstall GRUB to the server's SSD with sudo grub-install /dev/sda (replace /dev/sda with your server's SSD device)
  • Update GRUB with sudo update-grub

内容的提问来源于stack exchange,提问作者code_onkel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 07:41:51