终于进入ubuntu系统了
在liveCD 使用 chroot修复
这是参考:(我一步步操作的)
---------------------------
Boot your computer with a live-usb/CD in UEFI mode. I had two boot options <flash_drive> and UEFI: <flash_drive>, the second is needed to expose the efi variables in /sys/firmware/efi/ so that efibootmgr don't fail later on. Booting with the first option gives me the following error:
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
modprobe efivars did'nt work for me.
chroot into the broken system (similar to the ubuntu grub2 help but with efi specificities):
sudo mount /dev/sda2 /mnt #sda2 is my root partition
sudo mount /dev/sda1 /mnt/boot/efi #sda1 is my efi partition
for i in /dev /dev/pts /proc /sys; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/ #makes the network available after chrooting
modprobe efivars # make sure this is loaded
sudo chroot /mnt
Depending on your linux distribution, you now do different things.
For Ubuntu/Debian:
apt-get install --reinstall grub-efi-amd64
or alternatively:
apt-get install --reinstall grub-efi
update-grub
should the above give you a grub, but not a bootable one
For Fedora (up to 16, may work for others):
yum reinstall grub-efi
In the following command, you have to replace sdX with the device which has the EFI partition you want to boot from. In --part Y you have to replace the Y with the number of the EFI partition (as in /dev/sdXY).
efibootmgr -c --disk /dev/sdX --part Y
efibootmgr -v # verify a new record called Linux is there
Now type Ctrl+D to exit chroot, unmount everything and reboot:
for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done
sudo umount /mnt/boot/efi #please do this. corrupted efi partitions are not nice
sudo umount /mnt
sudo reboot
------------------------------------------
其实他还漏了一点!
grub-install --target=x86_64-efi --efi-directory=/dev/sdc1 --bootloader-id=grub --boot-directory=$esp/EFI --recheck --debug ($esp注意!!)
因为 apt-get install --reinstall grub-efi-amd64以后 不会自动安装到esp分区!!
要手动安装到这个esp分区
最终的原理还是在于efibootmgr来操作
过程中我出了点错
modprobe efivars #出错了,开机看不到启动项(但是 开机按F11已经找到ubuntu)
(这是提示:efibootmgr -c -d /dev/sdc -p 1 -w -L ubuntu -l \EFI\ubuntu\grubx64.efi ,说明启动菜单没有安装上)
---------------------
重要参考:
https://wiki.archlinux.org/index.php/GR ... IdeaCentre
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id="ubuntu" --recheck --debug
"grub-install /dev/sdc" 这种安装方法已经不行了