## img文件转化为vmdk文件 以openwrt镜像为例:https://downloads.openwrt.org/releases/22.03.0-rc6/targets/x86/64/openwrt-22.03.0-rc6-x86-64-generic-squashfs-combined-efi.img.gz ```sh qemu-img convert -f raw openwrt-22.03.0-rc6-x86-64-generic-squashfs-combined-efi.img -O vmdk openwrt.vmdk ``` openwrt.vmdk文件可直接在vmware work中使用 在esxi中使用需要进行格式转换,进入esxi主机的shell ```sh vmkfstools -i openwrt.vmdk -d eagerzeroedthick openwrt-esxi.vmdk ``` ## esxi镜像封装驱动环境搭建 [esxi-customizer-ps脚本链接](https://github.com/VFrontDe-Org/ESXi-Customizer-PS) 1. 先安装python3.7.9版本及相关包 ```sh pip install six psutil lxml pyopenssl -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com ``` 2. 在以管理员运行powershell ```powershell Install-Module -Name VMware.PowerCLI # 验证安装,输出welcome to VMware PowerCLI即安装成功 Import-Module -Name VMware.PowerCLI # 进入esxi的zip镜像所在目录 # 设置安全策略(unrestricted可以运行任意脚本且不警告) Set-ExecutionPolicy Unrestricted ``` ### esxi7.0以下封装驱动 [7.0以下驱动下载](https://vibsdepot.v-front.de/wiki/index.php/List_of_currently_available_ESXi_packages) ```powershell # 把脚本和esxi的zip文件都放到同一目录下,在当前目录下新建一个目录放vib驱动文件 # 运行脚本打包镜像(.\pkg\为vib驱动文件所在的目录),打包成功后会在当前目录下生成iso镜像 .\ESXi-Customizer-PS.ps1 -izip .\ESXi670-201912001.zip -pkgDir .\pkg\ ``` ### esxi7.0以上封装驱动 [7.0以上驱动下载](https://www.diy-nas.cn/?golink=aHR0cHM6Ly9mbGluZ3Mudm13YXJlLmNvbS9mbGluZ3M/cHJvZHVjdD1FU1hp) ```powershell # 驱动和zip镜像都放到统一目录下,设置安全策略 # 导入所需要的包 Add-EsxSoftwareDepot .\ESXi800-VMKUSB-NIC-FLING-61054763-component-20826251.zip Add-EsxSoftwareDepot .\Net-Community-Driver_1.2.7.0-1vmw.700.1.0.15843807_19480755.zip Add-EsxSoftwareDepot .\nvme-community-driver_1.0.1.0-3vmw.700.1.0.15843807-component-18902434.zip Add-EsxSoftwareDepot .\VMware-ESXi-8.0b-21203435-depot.zip # 获取官方配置文件 Get-EsxImageProfile # 克隆一份到本地,ESXi-8.0b-21203435-standard是上一步获取的,name参数随意,这里设为esxi-8.0,vendor是版权声明 New-EsxImageProfile -CloneProfile ESXi-8.0b-21203435-standard -Name esxi-8.0 -Vendor cvms.cn # 如果使用了第三方包需要修改安全级别为社区 Set-EsxImageProfile -ImageProfile esxi-8.0 -AcceptanceLevel CommunitySupported # 导入驱动文件,vmkusb-nic-fling名称是驱动压缩文件内的vib20目录下的目录名称 Add-EsxSoftwarePackage -ImageProfile esxi-8.0 -SoftwarePackage vmkusb-nic-fling Add-EsxSoftwarePackage -ImageProfile esxi-8.0 -SoftwarePackage net-community Add-EsxSoftwarePackage -ImageProfile esxi-8.0 -SoftwarePackage nvme-community # 导出镜像在当前目录 Export-EsxImageProfile -ImageProfile esxi-8.0 -ExportToIso -FilePath VMware-ESXi-8.0b-21203435.iso ``` ## esxi格式化硬盘 > fdisk格式的分区esxi无法识别 ```sh # 获取磁盘分区 partedUtil getptbl /dev/disks/磁盘文件名称 # 删除原有分区 partedUtil delete /dev/disks/磁盘文件名称 1 # 删除所有分区后可以在esxi控制台新建存储了 ```