修复EFI Bootloader实用命令,从Ghost流行不衰说起

小编:迷魂雪 更新时间:2022-08-25

~ 今天分享一个小技巧~

昨天看到专家朋友写的《笔记本电脑如何在更换硬盘的同时保留正版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。如果您想在这个公众号上分享自己的技术干货,也欢迎联系我:)

尊重知识,转载时请保留全文。感谢您的阅读和支持!