AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1034444
Accepted
leeand00
leeand00
Asked: 2020-09-19 08:23:33 +0800 CST2020-09-19 08:23:33 +0800 CST 2020-09-19 08:23:33 +0800 CST

应用/部署/恢复映像时,bcdedit 在 Windows PE 中不起作用?

  • 772

我捕获了一个映像,我试图在不使用 Sysprep 的情况下将其还原到另一个 VM,因为我正在积极使用我想要克隆的 vm 服务器,并且我不想再次设置它,我可以但是这将是浪费时间:

从 WinPE ISO 启动原始 VM,并显示 cmd 提示符:

捕获 共享读/写:\DESKTOP-O8ESL65\wsus_img

start /w wpeinit

连接到共享

net use i: \\DESKTOP-O8ESL65\wsus_img /user:someuser /password

使用以下命令捕获图像:

dism /capture-image /ImageFile:i:\install.wim /CaptureDir:C:\ /Name:"winserver_wsus2016"


不使用 Sysprep 进行还原

创建一个新的 vm 并使用 WinPE 启动它,然后在其上创建 GPT 分区:

start /w wpeinit
net use f: \\DESKTOP-O8ESL65\wsus_img
diskpart

Microsoft DiskPart version 10.0.14393.0Copyright (C) 1999-2013 Microsoft Corporation.On computer: MININT-TJ84J7UDISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> list vol  
Volume ###  Ltr  Label        Fs     Type        Size     Status     Info  
----------  ---  -----------  -----  ----------  -------  ---------  --------  
Volume 0     D   DVD_ROM      UDF    DVD-ROM      6649 MB Healthy  
Volume 1                      RAW    Partition    126 GB  Healthy      
Volume 2     C   Recovery     NTFS   Partition    450 MB  Healthy    Hidden  
Volume 3     E                FAT32  Partition    100 MB  Healthy    HiddenDISKPART> select volume 1
DISKPART> format fs="ntfs" quick label="data"
DISKPART> assign letter=g
DISKPART> list vol

Volume ###  Ltr  Label        Fs     Type        Size     Status     Info  
----------  ---  -----------  -----  ----------  -------  ---------  --------  
Volume 0     D   DVD_ROM      UDF    DVD-ROM      6649 MB Healthy  
Volume 1     G   data         NTFS   Partition    126 GB  Healthy      
Volume 2     C   Recovery     NTFS   Partition    450 MB  Healthy    Hidden  
Volume 3     E                FAT32  Partition    100 MB  Healthy    Hidden
    
DISKPART> exit

然后我运行它来应用映像,但是之后新的 VM 将无法启动:

dism /apply-image /Imagefile:f:\install.wim /index:1 /applydir:g:\

之后我无法从驱动器启动机器,所以我重复了上述步骤,然后在我读到以下命令可以用作 sysprep 的替代品后添加它:

bcdedit /set {default} device partition=c:
The boot configuration data store could not be opened.
The system cannot find the file specified.

bcdedit /set {default} osdevice partition=c:
The boot configuration data store could not be opened.
The system cannot find the file specified.

bcdedit /set {bootmgr} device partition=c:
The boot configuration data store could not be opened.
The system cannot find the file specified.

但是这些命令在 WinPE 中不起作用。我什至从 G:\Windows\System32\bcdedit.exe 尝试过,但仍然收到相同的消息。

我想设置 Windows 引导加载程序,以便 vm 可以启动并且我可以创建第二个 WSUS 服务器。我在想也许我需要做一个 runas,但由于我在 WinPE 中,我会以什么用户身份运行命令?我还在 bcdedit.exe 上找到了一些文档,但我是 GPT 分区和 UEFI 的新手,所以我不知道如何继续。

hyper-v boot-loader gpt windows-server-2016 bcdedit
  • 1 1 个回答
  • 861 Views

1 个回答

  • Voted
  1. Best Answer
    leeand00
    2020-09-23T07:01:26+08:002020-09-23T07:01:26+08:00

    好的,所以我能够让事情重新开始,但只有在遵循微软网站上的手册之后。

    首先,我开始阅读Capture and Apply a Windows .wim file,它链接到另一个关于 GPT 分区结构以及如何使用脚本(命名)创建它的文档( CreatePartitions-UEFI.txt ) ,当我再次返回原始文件时记录说明我们要运行的说明,然后应用映像,最后将一些文件复制到 GPT 分区;见下文:diskpartCreatePartions-UEFI.txtdiskpart /s CreatePartitions-UEFI.txt

    1.创建分区:

    所以首先我需要连接所有 UNC 驱动器以从中提取图像,这是我首先做的。

    说明如下,它们首先创建要在我们启动到 WindowsPE 后使用的脚本来创建分区:

    rem == CreatePartitions-UEFI.txt ==
    rem == These commands are used with DiskPart to
    rem     create four partitions
    rem     for a UEFI/GPT-based PC.
    rem     Adjust the partition sizes to fill the drive
    rem     as necessary. ==
    select disk 0
    clean 
    convert gpt
    rem == 1. System partition ==============
    create partition efi size=100
    rem     ** NOTE: For Advanced Format 4Kn drives, 
    rem            change this value to size = 260 **
    format quick fs=fat32 label="System"
    assign letter="S"
    rem == 2. Microsoft Reserved (MSR) partition ==============
    rem == 3. Windows partition ==============
    rem ==     a. Create the Windows partition ==============
    rem ==     b. Create space for the recovery tools ===
    rem           ** Update this size to match the size of 
    rem               the recovery tools (winre.wim)
    rem               plus some free space.
    shrink minimum=650
    rem ===     c. Prepare the Windows partition ==============
    format quick fs=ntfs label="Windows"
    assign letter="W"
    rem === 4. Recovery tools partition ==============
    create partition primary
    format quick fs=ntfs label="Recovery Tools"
    assign letter="R"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    list volume
    exit
    

    CreatePartitions-UEFI.txt

    接下来,我们必须使用 Windows PE 启动 PC,并在 cmd 提示窗口中运行以下命令来创建分区:

    DiskPart /s F:\CreatePartitions-UEFI.txt
    

    2.更改电源方案

    所以在恢复图像时它不会进入睡眠状态......

    call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
    

    3.应用图像:

    然后从外部 UNC 共享应用我之前捕获的图像dism(其中 F:\ 是 UNC 共享):

    dism /apply-image /Imagefile:F:\images\install.wim /index:1 /applydir:W:\
    

    5. 使用引导文件设置分区:

    W:\Windows\System32\bcdboot W:\Windows /s S:
    

    6. 使用 Windows 恢复环境设置分区:

    6.1 从 ??? 添加 Windows 恢复环境

    尝试安装 Windows 恢复映像,文档说它应该在W:\Windows\System32\Recovery\Winre.wim但它不存在,所以我从旧的 Windows 10 安装中抢救它并通过我的 UNC 共享复制它(但我仍然不知道从哪里得到它是正式的,或者如果它是微软改变了他们的工作方式,并且从未更新过文档......请告诉我你是否知道这个问题的答案......)

    md R:\Recovery\WindowsRE
    xcopy /h W:\Windows\System32\Recovery\Winre.wim R:\Recovery\WindowsRE
    

    6.2 恢复工具的注册位置

    我还注册了 Windows 恢复工具的位置并且它有效:

    W:\Windows\System32\Reagentc /Setreimage /Path R:\Recovery\WindowsRE /Target W:\Windows
    

    6.3 验证镜像配置

    W:\Windows\System32\Regentc /Into /Target W:\Windows
    

    7. 重新启动到 Windows Server 2016 并执行 sysprep 会执行的操作?

    我将 vm 重新启动到 Windows Server 并在短时间内能够在没有 sysprep 的情况下对机器进行通用化,至少这就是它所说的在这里我得到了在重新启动后运行的以下命令:

    bcdedit /set {default} device partition=c:
    bcdedit /set {default} osdevice partition=c:
    bcdedit /set {bootmgr} device partition=c:
    

    概括

    一切都解决了,但是如果我没有从旧的 Windows 10 安装中检索 winre.wim 文件的来源,我仍然有点困惑,有人知道吗?

    • 0

相关问题

  • Hyper-V 企业许可 - 包含的 CAL 是否应用于每个 VM 或每个 VM?[复制]

  • Hyper-V 和 Drobo Pro

  • 小型企业的服务器虚拟化/RAID 配置

  • 交换服务器 2003 在 hyper-v 上

  • 在同一台机器上将域控制器作为 1 个 VM 和一个 RODC 作为另一个 VM 运行,它会工作吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve