1. 程式人生 > >UEFI/GPT環境下多系統安裝

UEFI/GPT環境下多系統安裝

最近買了部thinkpad,按老規矩還是安多系統,卻意外地發現情況和原來不同了,見easybcd給我的提醒:
這裡寫圖片描述

很不幸,剛剛把出廠的win10解除安裝後我就安了win10專業版,卻發現分割槽中多了些以前沒見過的東東,下圖就是分割槽助手所顯示的(再次意外地發現在win7執行得好好的Paragon Partition Manager 11啟動不了了。。)

這裡寫圖片描述

很顯然多了3個,FAT32格式的ESP,未知格式的MSR,NTFS格式的WINRE_DRV;其它分割槽是我自己分配的系統及資料區,型別GPT

UEFI/GPT知識引用:

我們的電腦想要快速開機,需要具備三個條件:第一是主機板支援UEFI,二是系統支援UEFI(Win8),最後就硬碟需要採用GPT分割槽。
GPT分割槽全名為Globally Unique Identifier Partition Table Format,即全域性唯一標示磁碟分割槽表格式。GPT還有另一個名字叫做GUID分割槽表格式,我們在許多磁碟管理軟體中能夠看到這個名字。而GPT也是UEFI所使用的磁碟分割槽格式。

GPT分割槽的一大優勢就是針對不同的資料建立不同的分割槽,同時為不同的分割槽建立不同的許可權。就如其名字一樣,GPT能夠保證磁碟分割槽的GUID唯一性,所以GPT不允許將整個硬碟進行復制,從而保證了磁碟內資料的安全性。想比與我們目前通常使用的MBR分割槽,GPT本身就有著得天獨厚的優勢

GPT分割槽的建立或者更改其實並不麻煩,但是一塊硬碟如果想從MBR分割槽轉換成GPT分割槽的話,就會丟失硬碟內的所有資料。所以我們在更改硬碟分割槽格式之前需要先將硬碟備份,然後使用Windows自帶的磁碟管理功能或者使用DiskGenius等磁碟管理軟體就可以輕鬆地將硬碟轉換成GPT(GUID)格式,轉換完成後,我們就可以真正開始系統的安裝過程了。

由easybcd的對話方塊找到了官方網頁,EasyBCD and UEFI
大意就是:

從win8開始,新型計算機上傳統的BIOS+MBR方式被UEFI韌體和引導管理器取代,這種改變對雙啟動的windows機器而言是影響巨大的;
如果windows按EFI模式啟動,那它阻止早期windows和非windows系統從BCD選單上載入,這就意味著win9x,xp,server 2003,linux ,bsd,mac都不能在BCD選單上啟動。

  • 方案1:禁止UEFI和安全啟動
    這種措施並不是關閉UEFI,而是用傳統的方式引導進入windows,但這種方式不能引用UEFI安裝的windows; 可以通過工具如Easy Recovery Essentials來使得UEFI/GPT和BIOS/MBR共存
  • 方案2:使用虛擬機器,不多說,安裝linux不原生
  • 方案3:使用GRUB2 EFI作為主引導器
    按GRUB安裝到MBR,再在GRUB選單中新增WINDOWS條目

2017/1/11 簡單實踐

首先說一下thinkpad出廠的UEFI相關選項
config-usb-usb uefi bios support : enabled
security-virtualization-intel virtual technology: disabled
security-virtualization-intel vt-d feature: disabled
security-secure boot-secure boot: enabled
startup-uefi/legacy boot: uefi only
csm support: no

管理員執行powershell, 可知系統是以UEFI啟動的
這裡寫圖片描述
我僅僅用ultraiso寫ubuntu 16.04映像到行動硬碟(順便說一下,寫完之後似乎把分割槽都搞沒了,一個完整的60G),然後在電腦啟動時按F12即進入了引導介面(奇怪的是,沒有關閉secure boot,為何可以進入非windows的引導;在下方的連結中得知從12.04開始就可以了)
這裡寫圖片描述
下面這張圖是進入ubuntu安裝分割槽時的,很顯然也識別到了3個特別的分割槽(不過不太明白為啥有這麼多空閒)
這裡寫圖片描述

由於我還不太確定GRUB安裝在哪,所以沒進行下去……

非常有用的問答連結!!

這個帖子大家談到了安裝ubuntu時,grub2放在哪個區?
結論是:只要是從UEFI模式啟動,此選項就會被忽略,installer會自動將grub2安裝到efi分割槽
https://ubuntuforums.org/showthread.php?t=2309806

grub2 bug
If you are booting in UEFI mode, grub-efi has a bug and finds the Windows install, but thinks it still is a BIOS install and creates an incorrect BIOS boot when it should be an efi chain boot entry.
grub-update fails to detect windows bootloader on a uefi system
https://bugs.launchpad.net/ubuntu/+s…b2/+bug/807801
Wrong style chain boot entry
https://bugs.launchpad.net/ubuntu/+s…2/+bug/1024383
You can use Boot-Repair to automatically create the correct entry (or convert from BIOS Ubuntu boot to UEFI boot) or manually add a UEFI chain load entry.
You can just install into your current Ubuntu, use liveCD or USB or download a full repairCD.
Boot Repair -Also handles LVM, GPT, separate /boot and UEFI dual boot.:
https://help.ubuntu.com/community/Boot-Repair
You can repair many boot issues with this or ‘Create BootInfo’ report (Other Options) & post the link it creates, so we can see your exact configuration and diagnose advanced problems.Install in Ubuntu liveCD or USB or:
Full RepairCD with Boot-Repair (for newer computers)
https://help.ubuntu.com/community/UbuntuSecureRemix

最終靠譜的建議是通過boot-repair修復

Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can’t boot Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

Boot-Repair lets you fix these issues with a simple click, which (generally reinstalls GRUB and) restores access to the operating systems you had installed before the issue.

Boot-Repair also has advanced options to back up table partitions, back up bootsectors, create a Boot-Info (to get help by email or forum), or change the default repair parameters: configure GRUB, add kernel options (acpi=off …), purge GRUB, change the default OS, restore a Windows-compatible MBR, repair a broken filesystem, specify the disk where GRUB should be installed, etc.

2017/1/13 實踐

在看完了以上鍊接後,決定開始嘗試安裝ubuntu 16.04. 為了確保萬無一失,還是關閉了快速啟動和secure boot,選擇device for booloader在/dev/sda1,也就是efi分割槽(實際上可能installer會自動選擇efi),其它情況好說
重啟之後,首先進入了grub2選單,選擇可進入ubuntu;選擇windows boot manager那一項可進入win10(奇怪,怎麼沒了boot-repair的事)

最後分割槽情況如下圖(注意ESP分割槽出現了microsoft和ubuntu,原來來沒有ubuntu的):
這裡寫圖片描述

2017/1/16

今天不知怎麼的,重啟後就直接進入了win10,grub2沒了。。
我懷疑是不是先前我執行了一條這個語句:

grub-install /dev/sdb4

這是為了想在行動硬碟上安裝grub,難道這樣就把硬碟上的grub轉移了?奇怪
無奈再次通過引導U盤安裝boot-repair,沒想到還挺奏效。修復完後顯示:
這裡寫圖片描述

重啟進入了grub2選單,不過比先前多個幾項,目前還看不懂
這裡寫圖片描述