我刚刚从 Ubuntu 12.04 升级到 14.04,但是在安装过程中 grub-install 失败了:
我继续安装,希望之后能解决 grub 问题。但是,我遇到了一些困难。我还没有重新启动我的系统,因为我担心它无法重新启动。
这是我在尝试安装 grub 时总是遇到的错误:
$ sudo grub-install /dev/mapper/isw_cjccfdbihf_Volume0p1
Installing for i386-pc platform.
grub-install: error: cannot find a GRUB drive for /dev/mapper/isw_cjccfdbihf_Volume0p1. Check your device.map.
(我也试过sudo grub-install /dev/sda
了,但它也失败了,并出现了完全相同的错误消息。)
该机器似乎使用 RAID 1 设置。以下是一些信息:
$ ls -algh /dev/mapper/
total 0
drwxr-xr-x 2 root 120 Aug 12 19:41 .
drwxr-xr-x 16 root 5.2K Aug 12 20:27 ..
crw------- 1 root 10, 236 Jul 28 10:30 control
lrwxrwxrwx 1 root 7 Aug 12 19:41 isw_cjccfdbihf_Volume0p1 -> ../dm-1
lrwxrwxrwx 1 root 7 Aug 12 19:41 isw_cjccfdbihf_Volume0p2 -> ../dm-2
lrwxrwxrwx 1 root 7 Aug 12 19:41 isw_cjccfdbihf_Volume0p5 -> ../dm-3
$ sudo grub-probe -t device /boot/grub
/dev/mapper/isw_cjccfdbihf_Volume0p1
$ sudo fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b681
Device Boot Start End Blocks Id System
/dev/sda1 2048 468514815 234256384 83 Linux
/dev/sda2 468516862 488390655 9936897 5 Extended
/dev/sda5 468516864 488390655 9936896 82 Linux swap / Solaris
Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b681
Device Boot Start End Blocks Id System
/dev/sdb1 2048 468514815 234256384 83 Linux
/dev/sdb2 468516862 488390655 9936897 5 Extended
/dev/sdb5 468516864 488390655 9936896 82 Linux swap / Solaris
Disk /dev/mapper/isw_cjccfdbihf_Volume0p1: 239.9 GB, 239878537216 bytes
255 heads, 63 sectors/track, 29163 cylinders, total 468512768 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/isw_cjccfdbihf_Volume0p1 doesn't contain a valid partition table
fdisk: unable to read /dev/mapper/isw_cjccfdbihf_Volume0p2: Inappropriate ioctl for device
特别是最后两行似乎表明了更深层次的问题。:-(
的错误信息grub-install
还提到了一个device.map文件。
$ cat /boot/grub/device.map
cat: /boot/grub/device.map: No such file or directory
我试图生成它,但它也没有帮助(错误消息没有改变):
$ sudo grub-mkdevicemap
$ cat /boot/grub/device.map
(hd0) /dev/disk/by-id/ata-WDC_WD2500AAJS-00YZCA0_WD-WCAYU7549707
(hd1) /dev/disk/by-id/ata-WDC_WD2500AAJS-00YZCA0_WD-WCAYU7501473
您对我下一步应该尝试什么有什么建议吗?非常感谢任何帮助。
更新:
$ debconf-show grub-pc
debconf: DbDriver "passwords" warning: could not open /var/cache/debconf /passwords.dat: Permission denied
* grub-pc/install_devices: /dev/disk/by-id/dm-name-isw_cjccfdbihf_Volume0
grub-pc/kopt_extracted: false
grub-pc/partition_description:
* grub2/linux_cmdline:
grub-pc/install_devices_empty: false
grub-pc/timeout: 10
grub-pc/install_devices_failed_upgrade: true
* grub2/linux_cmdline_default: quiet splash
grub-pc/postrm_purge_boot_grub: false
grub-pc/hidden_timeout: true
grub-pc/disk_description:
grub-pc/mixed_legacy_and_grub2: true
grub2/kfreebsd_cmdline_default: quiet splash
grub2/device_map_regenerated:
* grub-pc/install_devices_failed: true
grub-pc/chainload_from_menu.lst: true
grub-pc/install_devices_disks_changed:
grub2/kfreebsd_cmdline:
注意这一行:grub-pc/install_devices: /dev/disk/by-id/dm-name-isw_cjccfdbihf_Volume0
现在的内容/etc/fstab
:
proc /proc proc nodev,noexec,nosuid 0 0
/dev/mapper/isw_cjccfdbihf_Volume01 / ext4 errors=remount-ro 0 1
/dev/mapper/isw_cjccfdbihf_Volume0p5 none swap sw 0 0
2012 年的备份文件显示交换条目略有不同(Volume05 而不是 Volume0p5),这表明名称可能已更改:
# Note that this is an old file at the time the system was installed (Ubuntu 10.04 or 10.10)
# (This is also the time from which the original grub configuration is from, isn't it?!)
/dev/mapper/isw_cjccfdbihf_Volume01 / ext4 errors=remount-ro 0 1
/dev/mapper/isw_cjccfdbihf_Volume05 none swap sw 0 0
所以,也许它与“_Volume01”与“_Volume0p1”与“_Volume0”有关。/etc/fstab
说“01”,ls /dev/mapper
返回映射“0p1”、“0p2”和“0p5”(交换),最后debconf-show grub-pc
说“Volume0”。我认为这种不一致是问题的根源。
现在我想知道:
grub-pc/install_devices
输出中的行应该debconf-show grub-pc
是什么?- 如何更改 Grub 设置,以便我可以尝试不同的值?
我还刚刚注意到 grub-pc 的安装被破坏了:
$ sudo dpkg-reconfigure grub-pc
/usr/sbin/dpkg-reconfigure: grub-pc is broken or not fully installed
这是我解决问题的方法:
在安静的时刻,我有时间冒停机的风险。所以我用 Ubuntu 14.04 Live CD 重新启动了系统并重新安装了 Grub。我没有遇到问题,之后系统正常启动。
这是一般说明:https ://help.ubuntu.com/community/Grub2/Installing#via_the_LiveCD_terminal
根据记忆,以下是我在特定情况下使用的命令:
从 Live CD 启动并执行以下命令:
之后,系统重新启动。最后,我可以用
sudo apt-get install
.目前,
/etc/fstab
仍然列出/dev/mapper/isw_cjccfdbihf_Volume01
根目录。我仍然不知道这是否真的正确,但我没有尝试将其更改为/dev/mapper/isw_cjccfdbihf_Volume0p1
以确定它在重新启动后是否仍然有效。在 RAID 设置中安装 grub2 失败,因为设备命名在某种程度上随着更新而改变,但尚未重新启动的运行系统使用不同的命名方案。
失败时只需取消 grub-install 并重新启动即可。之前安装的 grub 仍然指向一个有效的内核并且可以毫无问题地引导。重新启动后,grub 安装没有任何问题。
杰出的。
grub-install
在执行命令时,我只需要更改一件事以避免出现此错误:使用上面的命令,我更改了 grub-install 命令以将 GRUB 安装到 MBR 而不是像这样的分区(删除'p1'):
否则,它真的省去了我的后顾之忧。我很感激。
没有一个答案对我有用,所以我重新启动并使用引导修复盘来解决问题。这奏效了。呼...!