vHoge

VMwareのアレコレ備忘録。CLIでがんばるネタ多め。

ESXi のカスタムイメージを作成する

ダウンロードしたイメージで ESXi 6.7 インストールをしていると…
No Network Adapters
あら…

使っているのメインから退役した SandyBridge マシン(Core i7 2600K)。
NICオンボードで、MotherBoard は P67A-GD65 V2。
MSI P67A-GD65
で肝心の NIC チップはおなじみ Realtek 8111E ...

というわけで、8111E ドライバを仕込んだ ESXi イメージを作成する。

準備する物

  • ESXi offline bundle
    • おそらく ISO と同様に配布されている offline bundle (zip ファイル)が必要。
  • Realtek 8111E driver offline bundle
  • PowerCLI
    • VMware.ImageBuilder で作る。
    • PowerShell Core 6.0- /PowerCLI 10- 未対応(2019/3現在)。なので Windows 環境が必須…

作成手順

1. Driver の offline bundle を登録

PowerCLI でダウンロードした Driver のファイルパスを指定し、Depot として登録する。

PS C:\Windows\system32> Add-EsxSoftwareDepot D:\vsphere\net55-r8168-8.045a-napi-offline_bundle.zip

Depot Url
---------
zip:D:\vsphere\net55-r8168-8.045a-napi-offline_bundle.zip?index.xml

2. パッケージを取得

登録した Driver の Depot 内にあるパッケージを取得する。
取得した情報は後で使うので適当な変数に保存しておく。

PS C:\Windows\system32> Get-EsxSoftwarePackage

Name                     Version                        Vendor     Creation Date
----                     -------                        ------     -------------
net55-r8168              8.045a-napi                    Realtek    2018/04/16 9:...


# 適当な変数に保存
PS C:\Windows\system32> $pkg = Get-EsxSoftwarePackage

3. ESXi イメージ offline bundle を Depot 登録

ESXi 本体の Depot 登録。 手順は1と同じ。

PS C:\Windows\system32> Add-EsxSoftwareDepot D:\vsphere\update-from-esxi6.7-6.7_update01.zip

Depot Url
---------
zip:D:\vsphere\update-from-esxi6.7-6.7_update01.zip?index.xml

4. イメージプロファイルを取得

ESXi イメージからイメージプロファイルを取得。
こちらも後で使うので適当な変数に保存。

PS C:\Windows\system32> Get-EsxImageProfile

Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
ESXi-6.7.0-20181002001-stan... VMware, Inc.    2018/10/08 1... PartnerSupported
ESXi-6.7.0-20181001001s-no-... VMware, Inc.    2018/10/08 1... PartnerSupported
ESXi-6.7.0-20181002001-no-t... VMware, Inc.    2018/10/08 1... PartnerSupported
ESXi-6.7.0-20181001001s-sta... VMware, Inc.    2018/10/08 1... PartnerSupported


# 適当な変数に保存
PS C:\Windows\system32> $ip = Get-EsxImageProfile

5. イメージプロファイルを Clone し、新規のインストール用プロファイルを作成

4 で取得したイメージプロファイルを元に Driver 追加用のプロファイルを作成する。
ベースにするプロファイルは変数に配列形式で保存されているので、何番目のプロファイルを添字で指定。Name や Vendor は任意のもので可。
AcceptanceLevel は今回は Community Driver ということで "CommunitySupported"で指定。
業務用途とかであれば、デフォルト値(PartnerSupported) or higher でベンダ配布 Driver を使うようにしましょう…

PS C:\Windows\system32> New-EsxImageProfile -CloneProfile $ip[2] -Name ESXi-6.7.0-20181002001-realtek -Vendor "HomeLab" -AcceptanceLevel "CommunitySupported"

Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
ESXi-6.7.0-20181002001-realtek HomeLab         2018/10/08 1... CommunitySupported

6. イメージプロファイルに Driver パッケージを追加

5 で作成したイメージプロファイルに 2 で取得した Driver のパッケージ情報を足す。

PS C:\Windows\system32> Add-EsxSoftwarePackage -ImageProfile ESXi-6.7.0-20181002001-realtek -SoftwarePackage $pkg


Name                           Vendor          Last Modified   Acceptance Level
----                           ------          -------------   ----------------
ESXi-6.7.0-20181002001-realtek HomeLab         2019/03/16 1... CommunitySupported

7. プロファイルを ISO 出力

パッケージを追加したイメージプロファイルは ISO イメージで出力できるので出力する。

PS C:\Windows\system32> Export-EsxImageProfile -ImageProfile ESXi-6.7.0-20181002001-realtek -ExportToIso D:\vsphere\ESXi-6.7.0-20181002001-realtek.iso

あとは出力された ISO イメージを焼けば良い。
ESXiインストール成功
インストールも成功し、IP も振られ、疎通が取れる。
shell をたたいてみる。

[root@hayabusa:~] esxcli software vib list | grep net55-r8168
net55-r8168                    8.045a-napi                           Realtek  CommunitySupported  2019-03-16
[root@hayabusa:~] esxcli network nic list
Name    PCI Device    Driver  Admin Status  Link Status  Speed  Duplex  MAC Address         MTU  Description
------  ------------  ------  ------------  -----------  -----  ------  -----------------  ----  -----------------------------------------------------------------------------------------
vmnic0  0000:08:00.0  r8168   Up            Up            1000  Full    6c:62:6d:e6:ca:ee  1500  Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
[root@hayabusa:~] esxcli network nic get -n vmnic0
   Advertised Auto Negotiation: true
   Advertised Link Modes: 10BaseT/Half, 10BaseT/Full, 100BaseT/Half, 100BaseT/Full, 1000BaseT/Full
   Auto Negotiation: true
   Cable Type: Twisted Pair
   Current Message Level: 51
   Driver Info: 
         Bus Info: 0000:08:00.0
         Driver: r8168
         Firmware Version: 
         Version: 8.045.08-NAPI
   Link Detected: true
   Link Status: Up 
   Name: vmnic0
   PHYAddress: 0
   Pause Autonegotiate: false
   Pause RX: false
   Pause TX: false
   Supported Ports: TP
   Supports Auto Negotiation: true
   Supports Pause: false
   Supports Wakeon: true
   Transceiver: internal
   Virtual Address: 00:50:56:56:9a:68
   Wakeon: MagicPacket(tm)

おまけ offline bundle 出力

今回は Driver の追加だったが、VAAI プラグイン追加とかパッチ当ても同じ方法でできる。
その際、ISO のみしか残っていないとまた0から作り直しになるので、
offline bundle 形式でも出力して残しておくと良さげ。

PS C:\Windows\system32> Export-EsxImageProfile -ImageProfile ESXi-6.7.0-20181002001-realtek -ExportToBundle D:\vsphere\ESXi-6.7.0-20181002001-realtek.zip