雑木林

頭の中の整理と忘れないための確認メモ

vSphere ESXi 6でRealtek NICを動かす(ESXi-Custmizer-PS編)

前回、ESXi-Customizerを用いてESXi 6.0にRealTekNIC用のvibファイルを追加する方法を書きました。
ただ、ESXi-Customizerのページを確認すると、現在は開発が終わっており、ESXi-Customizer-PSに引き継がれていることがわかります。
そこで、今回はESXi-Customizer-PSを使ったカスタムISOの作成方法について記載します。


2017/05/23 追記
ESXi6.5の場合は以下の記事も合わせてお読みください。
vSphere ESXi 6.5でRealtek NICを動かす(ESXi-Custmizer-PS編) - 雑木林



ESXi-Customizer-PSを利用するために必要なもの

今回はVMware vSphere PowerCLI 6.0 Release 2を使ったため、Windows PowerShell 3.0以降
.NET Framework 4.5以降)が必要になってます。

前準備

Windows PowerShell 4.0のインストー

私のPC環境はWindows 7(64bit)であり、標準でWindows PowerShell 2.0がインストールされています。
そこで、動作要件を満たすために、Windows PowerShell 4.0へバージョンアップを行います。
バージョンアップを行うためには、Windows Management Framework 4.0をインストールします。
(インストールするには、Microsoft .NET Framework 4.5が必要です。)

インストールされているWindows PowerShellのバージョンは以下のコマンドで確認できます。
(PSVersionがインストールされているバージョンです。)

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Users\mobile> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2


PS C:\Users\mobile>

VMware-PowerCLIのインストー

VMware vSphere PowerCLI 6.0 Release 2をインストールします。
このとき、環境変数登録を行わないと、ESXi-Customizer-PSが正しく動作しなくなります。

環境変数未登録の場合
f:id:zokibayashi:20151102033609p:plain

環境変数を登録するには、この辺を参照しつつ、PowerShell上で以下のコマンドを実行します。

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\> #Save the current value in the $p variable.
PS C:\> $p = [Environment]::GetEnvironmentVariable("PSModulePath")
PS C:\>
PS C:\> #Add the new path to the $p variable. Begin with a semi-colon separator.
PS C:\> $p += ";C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules\"
PS C:\>
PS C:\> #Add the paths in $p to the PSModulePath value.
PS C:\> [Environment]::SetEnvironmentVariable("PSModulePath",$p)
PS C:\>

ESXi-Customizer-PSのダウンロード

ホームページからESXi-Customizer-PS-v2.4.ps1をダウンロードし、Cドライブ直下に格納します。
(便宜上C直下においてますが、特にどこでも問題ありません)


カスタムISOの作成

VMware vSphere PowerCLIからESXi-Customizer-PS-v2.4.ps1を実行してカスタムISOを作成します。
ESXi-Customizerとの違いは、ベースとなるISOを用意する必要が無いことです。
VMWareにある最新のISOからカスタムISOを作成するため、パッチ当ても少なくすることができます。
(実行途中でエラーが出ますが、無視して問題ないようです。)

ESXi5.5の場合

ESXi5.5でRealTekのドライバを組み込む場合は、5.1などで提供されていた公式ドライバを利用します。
具体的には以下のコマンドを実行します。

.\\ESXi-Customizer-PS-v2.4.ps1 -v55 -load net-r8168,net-r8169


実行例

          Welcome to VMware vSphere PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       Copyright (C) VMware, Inc. All rights reserved.


PowerCLI C:\> .\\ESXi-Customizer-PS-v2.4.ps1 -v55 -load net-r8168,net-r8169

セキュリティ警告
信頼するスクリプトのみを実行してください。インターネットから入手したスクリプト
は便利ですが、コンピューターに危害を及ぼす可能性があります。このスクリプトを信
頼する場合は、この警告メッセージが表示されないように、Unblock-File
コマンドレットを使用して、スクリプトの実行を許可してください。C:\ESXi-Customize
r-PS-v2.4.ps1 を実行しますか?
[D] 実行しない(D)  [R] 一度だけ実行する(R)  [S] 中断(S)  [?] ヘルプ
(既定値は "D"):R
"windowsize" の設定中に例外が発生しました: "ウィンドウの高さは 47 を上回ることができません。
パラメーター名:value.Height
実際の値は 50 です。"
発生場所 C:\ESXi-Customizer-PS-v2.4.ps1:106 文字:1
+ $pswindow.windowsize = $newsize
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting


Script to build a customized ESXi installation ISO or Offline bundle using the VMware PowerCLI ImageBuilder snapin
(Call with -help for instructions)

Logging to C:\Users\mobile\AppData\Local\Temp\ESXi-Customizer-PS.log ...

Running with PowerShell version 4.0 and VMware vSphere PowerCLI 6.0 Release 2 build 3056836

Connecting the VMware ESXi Online depot ... [OK]

Getting Imageprofiles, please wait ... [OK]

Using Imageprofile ESXi-5.5.0-20151004001-standard ...
(dated 10/05/2015 06:06:13, AcceptanceLevel: PartnerSupported,
For more information, see http://kb.vmware.com/kb/2133826.)

Load additional VIBs from Online depots ...
   Add VIB net-r8168 8.013.00-3vmw.510.0.0.799733 [OK, added]
   Add VIB net-r8169 6.011.00-2vmw.510.0.0.799733 [OK, added]

Exporting the Imageprofile to 'C:\\ESXi-5.5.0-20151004001-standard-customized.iso'. Please be patient ...


All done.

PowerCLI C:\>

ESXi6.0の場合

ESXi6.0でRealTekのドライバを組み込む場合は、公式ドライバは利用できないためV-Front Online Depotから必要なドライバをロードしてISOを作成します。
具体的には以下のコマンドを実行します。

.\ESXi-Customizer-PS-v2.4.ps1 -v60 -vft -load sata-xahci,net55-r8168


実行例

          Welcome to VMware vSphere PowerCLI!

Log in to a vCenter Server or ESX host:              Connect-VIServer
To find out what commands are available, type:       Get-VICommand
To show searchable help for all PowerCLI commands:   Get-PowerCLIHelp
Once you've connected, display all virtual machines: Get-VM
If you need more help, visit the PowerCLI community: Get-PowerCLICommunity

       Copyright (C) VMware, Inc. All rights reserved.


PowerCLI C:\> .\ESXi-Customizer-PS-v2.4.ps1 -v60 -vft -load sata-xahci,net55-r8168

セキュリティ警告
信頼するスクリプトのみを実行してください。インターネットから入手したスクリプトは便利ですが、コンピューターに危害を及ぼ
す可能性があります。このスクリプトを信頼する場合は、この警告メッセージが表示されないように、Unblock-File
コマンドレットを使用して、スクリプトの実行を許可してください。C:\ESXi-Customizer-PS-v2.4.ps1 を実行しますか?
[D] 実行しない(D)  [R] 一度だけ実行する(R)  [S] 中断(S)  [?] ヘルプ (既定値は "D"): R
"windowsize" の設定中に例外が発生しました: "ウィンドウの高さは 47 を上回ることができません。
パラメーター名:value.Height
実際の値は 50 です。"
発生場所 C:\ESXi-Customizer-PS-v2.4.ps1:106 文字:1
+ $pswindow.windowsize = $newsize
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting


Script to build a customized ESXi installation ISO or Offline bundle using the VMware PowerCLI ImageBuilder snapin
(Call with -help for instructions)

Logging to C:\Users\mobile\AppData\Local\Temp\ESXi-Customizer-PS.log ...

Running with PowerShell version 4.0 and VMware vSphere PowerCLI 6.0 Release 2 build 3056836

Connecting the VMware ESXi Online depot ... [OK]

Connecting the V-Front Online depot ... [OK]

Getting Imageprofiles, please wait ... [OK]

Using Imageprofile ESXi-6.0.0-20151004001-standard ...
(dated 09/24/2015 14:06:16, AcceptanceLevel: PartnerSupported,
For more information, see http://kb.vmware.com/kb/2132154.)

Load additional VIBs from Online depots ...
   Add VIB sata-xahci 1.32-1 [New AcceptanceLevel: CommunitySupported] [OK, added]
   Add VIB net55-r8168 8.039.01-napi [OK, added]

Exporting the Imageprofile to 'C:\\ESXi-6.0.0-20151004001-standard-customized.iso'. Please be patient ...


All done.

PowerCLI C:\>

ESXi-Customizer-PS-v2.4.ps1の動作

基本的な動作は以下の通りです。

  1. ESXiソフトウェアデポから最新のイメージプロファイルを入手する
  2. 必要なVIBファイルを組み込んだカスタムプロファイルを定義する
  3. カスタムプロファイルをイメージ(ISO)として出力する

使い勝手は非常に良いですが、公式以外のVIBを組み込むときは少し注意が必要かもですね。