当前位置:网站首页>使用PowerCli来创建自定义ESXi ISO镜像
使用PowerCli来创建自定义ESXi ISO镜像
2022-07-28 05:23:00 【yqowen】
之前我们封装ESXi ISO镜像大多使用的是GitHub - VFrontDe/ESXi-Customizer-PS: PowerCLI script that greatly simplifies and automates the process of creating fully patched and customized VMware ESXi installation images这个项目的powershell脚本,把一些社区版驱动(比如网卡驱动,USB网卡驱动等)封装进ESXi ISO,这样安装时就可以直接识别相应的硬件了。
实际上上述脚本就是基于VMware.PowerCLI 来实现的。PowerCLI是VMware的一个非常强大的Powershell命令库,有近700 cmdlets 可以用来管理和自动化VMware很多产品(比如vSphere, vCloud Director, vRealize Operations Manager, vSAN, NSX-T, VMware Cloud Services, VMware Cloud on AWS, VMware HCX, VMware Site Recovery Manager, and VMware Horizon environments)。而PowerCLI 12.0.0版本更新中,关于ISO镜像,有如下描述:
New cmdlets for managing auto-bootstrapping and new-style depots in vSphere 7.0 have been added to theVMware.DeployAutomationandVMware.ImageBuildermodule:
New/Set/Reset-LCMClusterRuleWithTransform
Get-DepotAddons
Get-DepotBaseImages
Get-DepotComponents
Get-DepotInfo
Get-DepotVibs
New-IsoImage
New-PxeImage
我们注意到它提到了加入了New-IsoImage(通过VMware.ImageBuildermodule)。
查询相关文档,New-IsoImage Command | VMware PowerCLI Reference和Create a Custom ESXi ISO Image with PowerCLI Cmdlets (vmware.com)有很详细的使用方法。
接下来我们在Windows 11 (Windows 10同理)环境下配置下环境来学习下用法。
1. “以管理员身份运行” Windows Powershell 或者Windows Terminal。
2. Install-Module -Name VMware.PowerCLI此过程中如果有提示是否安装NuGet以及是否要从"PSGallery"安装模块请选择“是”,“全是”。视网络情况,此安装过程可能需要几分钟。
3. 设置Execution policy, Windows 默认不允许执行此类第三方脚本Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine具体详细用法可以参照Set-ExecutionPolicy (Microsoft.PowerShell.Security) - PowerShell | Microsoft Docs
4. Import-Module VMware.ImageBuilder
5. 我们先使用VMwre的官方online repo来查看有哪些Image profile
Get-DepotBaseImages -Depot https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml
查询需要几十秒:
Version Vendor Release date
------- ------ ------------
7.0.0-1.25.16324942 VMware, Inc. 06/15/2020 23:00:00
7.0.0-1.20.16321839 VMware, Inc. 06/15/2020 23:00:00
7.0.0-1.0.15843807 VMware, Inc. 03/16/2020 08:40:41
7.0.1-0.35.19324898 VMware, Inc. 02/14/2022 23:00:00
7.0.1-0.15.17168206 VMware, Inc. 11/18/2020 23:00:00
7.0.1-0.10.17119627 VMware, Inc. 11/03/2020 23:00:00
7.0.1-0.25.17325551 VMware, Inc. 12/16/2020 23:00:00
7.0.1-0.20.17325020 VMware, Inc. 12/16/2020 23:00:00
7.0.1-0.30.17551050 VMware, Inc. 02/03/2021 23:00:00
7.0.1-0.0.16850804 VMware, Inc. 09/04/2020 16:33:22
7.0.2-0.0.17867351 VMware, Inc. 04/28/2021 23:00:00
7.0.2-0.15.18295176 VMware, Inc. 08/23/2021 23:00:00
7.0.2-0.20.18426014 VMware, Inc. 08/23/2021 23:00:00
7.0.2-0.25.18538813 VMware, Inc. 09/13/2021 23:00:00
7.0.2-0.30.19290878 VMware, Inc. 02/14/2022 23:00:00
7.0.3-0.20.19193900 VMware, Inc. 01/17/2022 23:00:00
7.0.3-0.30.19482531 VMware, Inc. 03/28/2022 23:00:00
7.0.3-0.35.19482537 VMware, Inc. 03/28/2022 23:00:00
其实-Depot这个参数也是可以指向一个本地的离线包(非ISO),比如:
Get-DepotBaseImages -Depot C:\CustomImage\VMware-ESXi-7.0U3c-19193900-depot.zip
Version Vendor Release date
------- ------ ------------
7.0.3-0.20.19193900 VMware, Inc. 01/17/2022 23:00:00
类似的还有Get-DepotAddons 和 Get-DepotComponents
比如可以查询社区版网卡驱动包:
Get-DepotComponents -Depot C:\CustomImage\Net-Community-Driver_1.2.7.0-1vmw.700.1.0.15843807_19480755.zip

6. 接下来创建一个自定义镜像的Spec (json格式):
{
"base_image": {
"version": "7.0.3-0.35.19482537"
},
"components": {
"Net-Community-Driver": "1.2.7.0-1vmw.700.1.0.15843807"
}
}
7. 利用前面查询到的离线包,驱动文件和spec文件来制作自定义镜像:
New-IsoImage -Depots "c:\CustomImage\VMware-ESXi-7.0U3c-19193900-depot.zip" , "c:\CustomImage\Net-Community-Driver_1.2.7.0-1vmw.700.1.0.15843807_19480755.zip" -SoftwareSpec "c:\CustomImage\spec.json" -Destination "c:\CustomImage\ESXi-70U3c-custom.iso"
PS: 此方法尝试封装USB NIC Flings时会报错,是该驱动的一个小bug,估计后续会修复。
New-IsoImage : Error retrieving file for VIB 'VMW_bootbank_vmkusb-nic-fling_1.8-3vmw.703.0.15.51233328':
("<zipfile.ZipExtFile name='vib20/vmkusb-nic-fling/VMW_bootbank_vmkusb-nic-fling_1.8-3vmw.703.0.15.51233328.vib'
mode='r' compress_type=deflate>", "Error opening file object for VIB
'VMW_bootbank_vmkusb-nic-fling_1.8-3vmw.703.0.15.51233328': Expected value '[]' for attribute 'swplatforms', but found
value '[<vmware.esximage.Vib.SoftwarePlatform object at 0x0000015A1ECEBB08>]'.").
边栏推荐
- Self attention learning notes
- Reinforcement learning -- SARS in value learning
- Model Inversion Attacks that Exploit Confidence Informati on and Basic Countermeasures 阅读心得
- 深度学习(自监督:SimSiam)——Exploring Simple Siamese Representation Learning
- Convolutional neural network
- On low resolution face recognition in the wild:comparisons and new technologies
- 深度学习(自监督:MoCo v2)——Improved Baselines with Momentum Contrastive Learning
- Deep learning (II) into machine learning and deep learning programming
- Overview of unconstrained low resolution face recognition I: data sets for low resolution face recognition
- TensorFlow2.1基本概念与常见函数
猜你喜欢

深度学习——Pay Attention to MLPs

Deep learning - metaformer is actually what you need for vision

深度学习——MetaFormer Is Actually What You Need for Vision

一、语音合成与自回归模型

Deep learning (II) into machine learning and deep learning programming

D2SC-GAN:基于双深浅通道生成对抗网络的课堂场景低分辨率人脸识别

Paper reading notes of field low resolution face recognition based on selective knowledge extraction

Neural network learning

Pytorch deep learning single card training and multi card training

51单片机独立按键联动数码管LED蜂鸣器
随机推荐
Solution to the crash after setting up a cluster
基于直方图修改的可逆数字水印方法
Automatic scheduled backup of remote MySQL scripts
Overview of unconstrained low resolution face recognition III: homogeneous low resolution face recognition methods
三、OpenVINO实战:图像分类
What should we pay attention to when making template application of wechat applet?
TensorFlow2.1基本概念与常见函数
Using neural network to predict the weather
Building neural network based on tensorflow
5、 Video processing and GStreamer
Self attention learning notes
Differences between processes and threads
Construction of redis master-slave architecture
Deep learning (self supervised: Moco V3): An Empirical Study of training self supervised vision transformers
Deep learning (II) into machine learning and deep learning programming
Tornado first met
Why is the kotlin language not popular now? What's your opinion?
《On Low-Resolution Face Recognition in the Wild:Comparisons and New Techniques》低分辨率人脸识别论文解读
Protecting Against DNN Model Stealing Attacks 论文阅读心得
速查表之转MD5