修復EFI Bootloader實用命令,從Ghost流行不衰說起

~ 今天分享一個小技巧~

昨天看到專家朋友寫的《筆記本電腦如何在更換硬盤的同時保留正版Windows 10 系統?》,一下想到上週我也計劃著寫點相關的東西。

不過就像我在“《企業存儲技術》文章分類索引(微信公眾號專輯)”留言評論中所說,自己有些時候也是假裝有技能樹。與上面這篇的作者老師相比,我的水平要差著不少。因此今天分享的只是一個小技巧,高端讀者朋友看的時候不用太認真:)

Ghost、DISM和sysprep的相愛相殺


修復EFI Bootloader實用命令,從Ghost流行不衰說起


先給大家講個故事,我第一次看到人用Ghost是在1998年,當時的2.0版本還沒有上面這樣好看的圖形界面。後來則是因為給某小品牌PC供了幾百塊540MB硬盤,去人家生產線幫忙一起測試驗收,看到小哥用Ghost 5.0來做克隆。然後我就央求人家給拷軟盤裡帶走了:)

至於Ghost裝機紅遍中關村,似乎都是在那以後的事情。直到今天,Ghost仍保持著簡單高效的傳統,春節後我還用它給一批筆記本製作了系統鏡像母盤。

當然Ghost不是萬能的,它只管分區數據,Windows的NTFS引導記錄也能較好處理。但它不負責在跨主機克隆時生成新的用戶、計算機名等ID。因此如果不只是原封不動備份數據的話,有時需要搭配Windows自己的sysprep先把系統“初始化”一下。

如果不做sysprep直接Ghost,特別是對UEFI-GPT分區安裝的Windows系統操作時,很容易遇到下面的啟動藍屏:

修復EFI Bootloader實用命令,從Ghost流行不衰說起

如上圖,即使我在同一臺主機上,只是為了替換下系統盤而做Ghost克隆,也會出現因磁盤ID變化而找不到winload.efi啟動文件的情況。對於高手來說,這應該不算是多大的難題。

這讓我想起一位朋友——Martin首席在他之前的分享中講到過這些。Windows發展到今天,用Ghost的人還是少了,因為微軟早就準備了dism(dism++)來保存/恢復以及編輯OS的現代化方法。比如我在《為了這個“完美”版Win7鏡像,我用了一年的時間》裡面,就用到了dism和sysprep。

不過我想給dism挑點小不足——需要把系統先存成wim鏡像文件中轉下,然後再恢復(到別的盤)。在日常排錯等工作中,我有時也會有點小眾的需求,比如盤對盤直接克隆——這時還是用Ghost或者再生龍更方便點。

sysprep的工作原理也帶來個小問題,比如有的應用程序裝在了“C:\User\用戶名”文件夾下,初始化後這樣的應用就會受到影響。有時我的需求,就是想要把系統盤原汁原味克隆出來,在本機和同配置硬件上可以用就好,不需要那麼完美。

修復EFI bootloader方案:用Windows自帶命令

最近偶然在Dell技術支持網站看到一篇知識庫:《How to repair the EFI bootloader on a GPT HDD forWindows 7, 8, 8.1 and 10 on your Dell PC》(文末提供鏈接),用在上面啟動藍屏的機器上,隨手試了一下能解決問題。下面就把步驟分享給大家:

Windows10(Win7/8步驟類似)

If you dohave the Installation Media:

  1. Insert the Media (DVD/USB) in your PC and restart. 用系統安裝介質啟動
  2. Boot from the media.
  3. Select Repair Your Computer. 選擇“修復你的計算機”,或者按Shift+F10直接打開命令行窗口
  4. Select Troubleshoot.
  5. Select Advanced Options.
  6. Choose Command Prompt from the menu:
    1. Type and run the command:

diskpart 就是磁盤分區的命令

    1. Type and run the command:

sel disk 0

    1. Type and run the command:

list vol 注意是列出所有卷,然後選擇FAT文件系統的EFI系統分區(容量不大,啟動相關),分配驅動器號

  1. Verify that the EFI partition (EPS - EFI System Partition) is using the FAT32 file system. Assign a drive letter to it that is not already in use.):
    1. Type and run the command:

sel vol

    1. Type and run the command:

assign letter=:

    1. Type and run the command:

exit

  1. In order to repair the boot record:
    1. Type and run the command:

cd /d :\EFI\Microsoft\Boot\ 進入這個目錄運行下面修復命令

    1. Type and run the command:

bootrec /FixBoot

修復EFI Bootloader實用命令,從Ghost流行不衰說起

如上圖,接下來的命令有一點需要注意:最後h(EPS盤符):All之間不要有空格,否則運行失敗。

If you do nothave the Installation Media: 如果沒有恢復盤,也可以嘗試進入當前系統盤的恢復命令行。當然像我上面這樣嚴重的啟動問題,只能用U盤/光盤了。


  1. Restart your PC
  2. Tap rapidly on the <F8> key once the PC has turned on, but before the Windows Splash Screen appears.

Be awarethis may take several attempts. The timing for this option was shortenedsignificantly from that in Windows 7.

  1. Select Repair your computer from the menu that appears.
  2. Select Command Prompt from the Advanced Options tab in the Troubleshoot screen:
    1. Type and run the command:

diskpart 這一段和前面重複,可以跳過去了

    1. Type and run the command:

sel disk 0

    1. Type and run the command:

list vol

  1. Verify that the EFI partition (EPS) is using the FAT32 file system and assign a drive letter to it that is not already in use:
    1. Type and run the command:

sel vol

    1. Type and run the command:

assign letter=:

    1. Type and run the command:

exit

  1. In order to repair the boot record:
    1. Type and run the command:

cd /d :\EFI\Microsoft\Boot\

    1. Type and run the command:

bootrec /FixBoot

The next step is the sameacross all the operating systems:

  1. Rebuild the BCD store.
  2. First run the command below to back up the old BCD:

ren BCD BCD.old 這一步是要備份並重建BCD文件

  1. Now recreate it using this command:

bcdboot c:\Windows /l en-us /s : All 就是要去掉最後All前面的空格

Note:If you are creating boot entries on an attached USB Flash or other externaldrive, add /fbetween the : and the ALL. Remember that the is replaced with the letter of the drive that youare booting from. (e.g., C:\, D:\)


修復EFI Bootloader實用命令,從Ghost流行不衰說起

執行完這一步,重啟Win10就恢復正常了,和Ghost克隆之前的磁盤一樣使用。



How to repair your MBR (Master Boot Record)下面這段英文是針對MBR磁盤修復的,我沒有做實驗,供大家參考。

These steps apply to anylegacy drive used as a boot drive on any recent Windows Operating system.

  1. Use the
    F12 key at the Dell Splash screen to enter the boot menu. It lets you boot from the Windows installation media or a bootable disc or flash drive.
  2. Click on the Repair your Computer link at the bottom of the Install Now screen.
  3. Click on Troubleshoot
  4. Select Command Prompt
  5. Enter the following three commands in turn, following each by pressing the Enter key:

bootrec /fixmbr

bootrec /fixboot

bootrec /rebuildbcd

  1. Restart the PC with the installation media removed to check if the repair worked

雖然本文的小技巧可能使用場合不多,但還是發出來給大家參考下。我們平時懶得解決的一些小問題,有時候微軟等OS和硬件廠商早就準備好了相關工具/方案。在下面的原始鏈接裡可以選中文,不過個別命令中的空格會出問題,所以大家還是以英文為準吧。

不知是否有朋友在Windous Server系統上試過?

資料來源

《How to repair the EFI bootloader on a GPT HDD forWindows 7, 8, 8.1 and 10 on your Dell PC》

https://www.dell.com/support/article/zh-cn/sln300987/how-to-repair-the-efi-bootloader-on-a-gpt-hdd-for-windows-7-8-8-1-and-10-on-your-dell-pc?lang=en


文章ID: SLN300987

上次修改日期: 05/07/2020 05:58 AM


注:本文只代表作者個人觀點,與任何組織機構無關,如有錯誤和不足之處歡迎在留言中批評指正。進一步交流技術,可以加我的QQ/微信:490834312。如果您想在這個公眾號上分享自己的技術乾貨,也歡迎聯繫我:)

尊重知識,轉載時請保留全文。感謝您的閱讀和支持!


分享到:


相關文章: