如何使用 Sysprep 来创建并安装可重复使用的自定义 Windows AMI?

2 分钟阅读
0

我想使用 System Preparation (Sysprep) 来捕获并安装可重复使用的自定义 Windows 亚马逊机器映像 (AMI)。

解决方法

运行 Sysprep 时,请使用以下最佳实践:

  • 请勿使用 Sysprep 为实例创建备份。
  • 请勿在生产系统上运行 Sysprep。
  • Windows Server 2016 Nano Server 不支持 Sysprep。
  • 对于 Windows Server 2008 至 Windows Server 2012 R2,请使用 EC2Config 运行 Sysprep。
  • 对于 Windows Server 2016 或 Windows 2019(LTSC 和 SAC),请使用 EC2Launch v1 运行 Sysprep。
  • 对于 Windows Server 2022 和 Windows Server 2025,请使用 EC2Launch v2 运行 Sysprep。对于 Windows 2012、2012 R2、2016(LTSC 和 SAC)或 2019(LTSC 和 SAC),您也可以使用 EC2Launch v2。

**注意:**有关详细信息,请参阅 Microsoft 网站上的 Limitations。要捕获生产系统的 Sysprep 映像,请从实例创建 AMI。然后,在隔离环境中从 AMI 启动实例。您可以捕获已启动实例的 Sysprep 映像。

使用 EC2Config 或 EC2Launch v1 或 v2 运行 Sysprep

完成以下步骤:

  1. 打开 Amazon Elastic Compute Cloud (Amazon EC2) 控制台
  2. 使用远程桌面协议 (RDP) 连接到您的 Windows 实例
  3. 选择 Windows 的 Start(开始)菜单,然后针对您使用的 Windows Server 完成以下步骤之一:
    对于 Windows Server 2008 至 Windows Server 2012 R2,打开 EC2ConfigService Settings(EC2ConfigService 设置),然后选择 Image(映像)。
    对于 Windows Server 2016 或更高版本,打开 EC2LaunchSettings
  4. 对于 Administrator Password(管理员密码),选择 Random(随机)。
  5. 选择 Shutdown with Sysprep(使用 Sysprep 关闭),然后选择 Yes(是)。
    **注意:**下次启动时必须从控制台检索新密码
  6. 打开 Amazon EC2 控制台
  7. 在导航窗格中,选择 Instances(实例)。
  8. 在实例状态更改为 stopped(已停止)后,选择实例。
  9. 对于 Actions(操作),选择 Image(映像),然后选择 Create image(创建映像)。
  10. 对于 Image name(映像名称),输入一个名称。
  11. 对于 Image description(映像描述),输入描述。
  12. 选择 Create image(创建映像)。

有关更多信息和自定义选项,请参阅使用 Windows Sysprep 创建 Amazon EC2 AMI

如果您收到错误消息,请参阅对 Amazon EC2 Windows 实例的 Sysprep 问题进行故障排除。您也可以使用 EC2Rescue for Windows Server 来收集日志文件和解决任何问题。

相关信息

为什么无法从复制的 AMI 启动 EC2 实例?