我需要一步一步指导恢复grub

昨天我从磁盘上删除了两个微小的部分,今天它无法启动。 我现在从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. 

你能告诉我现在该做什么吗?

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

1)如果您重新启动机器并且卡在grub菜单中,那么您可以使用实时DVD。 安装Ubuntu OS安装的分区后(在我的情况下,它从sda6切换到sda5)

  sudo mount /dev/sda5 /mnt sudo grub-install --root-directory=/mnt /dev/sda 

将修复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) 

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

它应该修复启动时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. 

不用担心,这只是一条警告信息,只需重新启动你的comp,你的grub将在正确的分区中被检测到。

每次在关闭comp之前更改驱动器中的分区时,必须运行sudo fdisk /dev/sda来修复分区表,否则最终会在下次重启时丢失grub

Boot-Repair是一个简单的工具,用于修复您在Ubuntu中可能遇到的频繁启动问题,例如在安装Windows或其他Linux发行版后无法启动Ubuntu,或者在安装Ubuntu后无法启动Windows,或者GRUB不安装时显示,某些升级会破坏GRUB等。

根据Ubuntu社区帮助,如果您不喜欢使用终端方式,可以使用Boot-repair工具恢复您的GRUB。

请在此处阅读更多内容以了解如何使用。