我需要逐步指导来恢复 grub

ken*_*enn 8 grub2 disk

昨天我从磁盘中删除了两个小分区,今天它无法启动。我现在从 USB 打开我的电脑,但我无法从 chroot 安装 grub。我跑了sudo blkid,我注意到我的 ubuntu 安装分区从 sda6 移动到了 sda5。首先,我跑了sudo mount /dev/sda5 /mnt,然后 sudo grub-install --root-directory=/mnt /dev/sda5,但我得到了下面的错误。

 /usr/sbin/grub-bios-setup: warning: File system `ext2' doesn't support embedding.
 /usr/sbin/grub-bios-setup: warning: Embedding is not possible.  GRUB can only be    installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their   use is discouraged..
 /usr/sbin/grub-bios-setup: error: will not proceed with blocklists.
Run Code Online (Sandbox Code Playgroud)

你能告诉我现在该怎么办吗?

ken*_*enn 3

编辑:我的问题源于删除硬盘驱动器中的分区。

1) 如果您重新启动计算机并且卡在 grub 菜单中,那么您可以使用 Live DVD。安装 Ubuntu 操作系统安装的分区后(在我的例子中,它从 sda6 切换到 sda5)

  sudo mount /dev/sda5 /mnt

  sudo grub-install --root-directory=/mnt /dev/sda
Run Code Online (Sandbox Code Playgroud)

将修复 grub

2)如果您删除了一个分区并且尚未重新启动它(由于分区表更改而无法启动),那么您可以应用以下指南来修复它。在grub损坏之前,它安装在SDA6分区上,由于我删除了分区,分区表条目乱了,自然无法启动。

sudo fdisk -l查看消息,例如partition table entries are not in disk order您是否收到该消息来修复它;发出命令

sudo fdisk /dev/sda然后输入xf最后w

他们做什么

 x (extra functionality - experts only)
 f (fix)
 w (write to disk and exit)
Run Code Online (Sandbox Code Playgroud)

您可能会收到一条警告,指出设备正在使用中,并且将在下次启动时使用新表。

它应该修复 grub 在启动时的失败。

如果您错过了上述步骤并且想要重新安装 grub,请查看此链接https://wiki.archlinux.org/index.php/GRUB#Install_to_partition_or_partitionless_disk

编辑:

如果您收到类似消息

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
Run Code Online (Sandbox Code Playgroud)

不用担心,这只是一条警告消息,只需重新启动您的电脑,您的 grub 就会在正确的分区中被检测到。

每次在关闭计算机之前更改驱动器中的分区时,都必须运行 sudo fdisk /dev/sda 以修复分区表,否则在下次重新启动时会丢失 grub