Cobblerは、Linuxの世界でインストールサーバーとして使用できるツールであり、1つ以上のLinuxディストリビューションに基づいて多くのネットワークインストールスクリプトを作成します。 FreeBSD、VMware、Xen、およびNexentaのインストールもサポートされています。
彼の助けを借りて、さまざまなWindowsディストリビューション(XP、2003、7、8、2008、2012)から独自のネットワークインストールスクリプトを柔軟かつ普遍的に作成したいと思います。
cobblerを設定してLinuxをインストールする方法については、公式ウェブサイト
https://cobbler.imtqy.comに詳しく記載されてい
ます 。 ここでは、Windowsに関する問題に対するソリューションのバージョンに焦点を当てます。
独自のネットワークインストールスクリプトを作成するための主な問題は、Linuxで必要なWindowsブートファイルを準備することでした。 cobblerのpost-triggerが
cobbler sync
コマンドで起動されると、私にとって必要なバイナリの生成が発生します。
- 一部のファイルは、バイナリ内のある行を直接別の行に直接置き換えることにより、標準ファイルから作成されます。
- bootmgr.exeファイルを変更する過程で、PEファイルのチェックサムが変更されるため、再計算する必要があります。 トリガーはpython-pefileでこれを行います。
- hivexは、BCDブート情報レジストリの作成に使用されました。
- 画像を操作する-wimlib
- Windows応答ファイルは、Windowsのバージョン、アーキテクチャ(32ビットまたは64ビット)、インストールプロファイルなどに応じて、条件付きコード生成のすべての機能を使用するcobblerテンプレートを使用して生成されます。
- wimイメージの開始スクリプト(startnet.cmd)およびOSのインストール後に実行されるスクリプト(post_install.cmd)もテンプレートから生成されます。
私の場合、応答ファイルは主にWindowsのバージョンに基づいて生成され、プロファイル名に基づいて生成されることはほとんどありません。 つまり 私は、Windowsの各バージョンの応答ファイルで指定できるインストールオプションを最も適切で、ほとんどの場合使用することを自分で選択しました。
主な作業は、インストールオプションの構成、追加ソフトウェアのインストールなどです。 スクリプトにあります。これは、Windowsをインストールし、インストール時に既にpost_install.cmdスクリプトをダウンロードする場合のcobblerプロファイル(win.ks)のキックスタートファイルとして指定します。 ダウンロード時のCobblerは、win.ksテンプレートに基づいてコードを動的に生成します。 そして、このテンプレートでは、ほとんどのコードはすでにプロファイル名に基づいて生成されています。
その結果、ほとんどの場合、デバッグ中にインストールスクリプトを変更するには、サーバー上のwin.ksテキストファイルを編集してインストールを再開するだけで十分です。
各シナリオで変更する必要のあるファイルの論理関係を簡素化することにより、Xpおよび2003のネットワークインストールを次のように概略的に表すことができます。
pxeboot.n12 → setupldr.exe → winnt.sif → post_install.cmd profile_name
Windos 7以降の場合:
pxeboot.n12 → bootmgr.exe → BCD → winpe.wim → startnet.cmd → autounattended.xml → post_install.cmd profile_name
もちろん、PXEメニューの項目から、プロファイル名をパラメーターとしてpost_install.cmdスクリプトを実行する短い方法ではありません。 さらに、このスクリプトは、このプロファイルに対応するキックスタートサーバーコブラーも取得して実行する必要があります。
さて、まず最初に
cobbler 2.6.9とその動作に必要なすべてのものはすでにインストール、設定されており(たとえば、iptables、SElinux)、Linuxのインストールで素晴らしい仕事をしていると信じています。
必要なものをすべてインストールします。
hivexを直接使用するのは便利ではありません-
ここ (良いインストールオプションですが、tftpログ分析を使用するので気に入らなかったのですが、バイナリを調整する必要はありません)標準BCDに必要な変更を加える既製のスクリプト(bcdedit.pl) 。 実際、これはWindowsユーティリティのbcdeditに代わるものです。 Perlで書かれており、アーカイブからそれを抽出し、/ usr / local / binに配置し、事前に変更してあります。
# diff -c bcdedit.pl.orig bcdedit.pl *** bcdedit.pl.orig --- bcdedit.pl
追加された行はコマンドに似ています:
bcdedit -set {bootmgr} nointegritychecks Yes
サーバーのtftpディレクトリで、Windowsディストリビューションを格納するフォルダーを作成します。
ここで、各ディストリビューションのディレクトリを作成し、そのコンテンツをそこにコピーします。
私にとってはこのように見えます:
Xpや2003などのレアリティをインストールする予定がある場合ブートファイルの準備
配布WinXp_EN-i386、WinXp_RU-i386、およびWin2K3-Server_EN-x64のあるディレクトリで、次のコマンドを実行します。
[root@is WinXp_EN-i386]
Xpを使用した配布ディレクトリ内:
[root@is WinXp_EN-i386]
2003年以降の配布ディレクトリ:
[root@is Win2K3-Server_EN-x64]
RISを構成する
ris-linuxが必要になります。 私のディストリビューションでは、次のようになっています。
RISがWin 7のインストールに干渉しないように、/ usr / share / ris-linux / binlsrv.pyファイル内の1行をコメントアウトする必要があります。
# diff binlsrv.py.orig binlsrv.py 571c571 < p = p + chr(252) + chr(len('boot\\bcd')) + 'boot\\bcd' --- > #p = p + chr(252) + chr(len('boot\\bcd')) + 'boot\\bcd'
tftpdログ、RISに必要なBCDを伝える機能を分析せずに、簡単な方法を見つけることはできませんでした。 そのため、オフにしました。
フォルダー/ var / lib / tftpboot / winos / infを作成し、必要な32ビットネットワークカードドライバーのすべての.infファイルをコピーして、コマンドを実行します。
32ビットXpと64ビットServer 2003を同時に提供するにはRISが必要です。これを行うには、別のポートでサービスの別のインスタンスを作成します。
# diff ris-linuxd ris-linuxd64 2c2 < # ris-linuxd service. --- > # ris-linuxd64 service. 6c6 < BINLSRV_INFPATH=/var/lib/tftpboot/winos/inf --- > BINLSRV_INFPATH=/var/lib/tftpboot/winos/inf64 9c9 < BINLSRV_OPTS= --- > BINLSRV_OPTS=--port=4012 12c12 < BINLSRV_LOGFILE=/var/log/ris-linuxd.log --- > BINLSRV_LOGFILE=/var/log/ris-linuxd64.log 15c15 < BINLSRV_PIDFILE=/var/run/ris-linuxd.pid --- > BINLSRV_PIDFILE=/var/run/ris-linuxd64.pid
systemdでris-linuxサービスを書き換える手間はありませんでしたが、誰もそれを必要としません。
フォルダー/ var / lib / tftpboot / winos / inf64を作成し、そこに必要な64ビットネットワークカードドライバーのすべての.infファイルをコピーして、コマンドを実行します。
/usr/share/ris-linux/infparser.py /var/lib/tftpboot/winos/inf64
サービスをオンにして開始します。
さらに、Win2K3-Server_EN-x64ブートローダーのポートを、64ビットRISをポイントしたポートに変更する必要があります。
これは、ris-linuxパッケージのmodldr.pyユーティリティを使用して実行できます。
ユーティリティ操作が失敗した場合、スクリプトのテキストmodldr.pyで次の行を置き換えます。
ppattern = re.compile(r'\x6a\x04\x68(..)\x00\x00\xff\x35', re.DOTALL)
行ごと:
ppattern = re.compile(r'\x6a\x64\x68(..)\x00\x00\xff\x35', re.DOTALL)
サンバの準備
2つのフォルダーをパブリックにするためにSambaが必要です インストール時に使用する最小限の権限を持つユーザーを作成します。 私が持っている:インストール/インストール
ネットワークインストール用のファイルの準備Win 7、8、2008、2012
Win 7、8、2008、2012の状況は、Xpよりもはるかに悪いです。 ここでバイナリを掘り下げるのはそれほど簡単ではありません。その中のチェックサムを数える必要があります。
ここでの自動インストール用の応答ファイルも、XML形式で、より現代的な外観になっています。 たとえば、ディスクをパーティションに分割する方法などを指定できるなど、多くの改善点があります。しかし、軟膏には大きなハエもあります。応答ファイルの名前がスタートアップスクリプトに縫い込まれ、実際にインストールが開始されます。 次に、スクリプト自体がwimイメージに配線されます。
つまり バイナリの修正には依然として大きな不便があり、さらに、あるディストリビューションに基づいたインストールシナリオごとに、開始スクリプト内の応答ファイルの名前のみが同じイメージの別のものとは異なる個別のwimイメージを用意する必要があります。
ディストリビューションのあるディレクトリに、次のファイルを配置する必要があります。
- pxeboot.n12
- bootmgr.exe
- ブート/ bcd
- boot / boot.sdi
- ブート/フォントとそれに設定されたフォント
Cobblerテンプレートの作成
tftpのファイル名変換ルールを作成します。
tftpのcobblerテンプレートで変換ルールを指定します。
Windowsセクションの/var/lib/cobbler/distro_signatures.jsonファイルにバージョン情報を追加して、cobblerメタデータを介してテンプレートで使用できるようにします。
Windowsインストールをセットアップする際、テンプレートから応答ファイルとインストール後スクリプトを生成することにより、cobblerを介してLinuxをインストールする主な利点を維持することができました。
Windows用のテンプレートの構成には、次のファイルが含まれます。
- post_inst_cmd.template-OSインストール後に実行されるスクリプトテンプレート
- win.ks-Windows用kiskstart linuxの投稿セクションの役割を果たす
- win_sif.template-応答ファイルのテンプレート
- startnet.template-wimイメージでスクリプトテンプレートを開始
- winpe7.template-Win 7およびWin 2008サーバーのwimファイル
- winpe8.template-Win 8およびWin 2012サーバーのwimファイル
Post_inst_cmd.templateおよびwin.ksテンプレート
Windowsのインストール後に実行するスクリプトのテンプレートを作成します(バージョンに関係なく)。
スクリプトには、起動時にパラメーターとしてプロファイル(インストールオプション)cobblerの名前が渡されます。
テンプレートに関する簡単な説明:ディストリビューションの各ディレクトリには、フォルダー$ OEM $ / $ 1 / TMPがあり、wget.exe、todos.exe、dll'kiを実行する必要があります。 より正確には、それらは1つのフォルダーにあり、他のフォルダーは単なるシンボリックリンクです。
- OSをインストールすると、これらのファイルはC:\ TMPにコピーされます。
- Snipet win_wait_network_onlineは、ネットワークの準備が整うまで待機し、cobblerがインストールされているサーバーのIPアドレスをpingします。
スニペットファイルの内容/ var / lib / cobbler /スニペット/ my / win_wait_network_online :wno10 set n=0 :wno20 ping @@http_server@@ -n 3 set exit_code=%ERRORLEVEL% IF %exit_code% EQU 0 GOTO wno_exit set /an=n+1 IF %n% lss 30 goto wno20 pause goto wno10 :wno_exit
スクリプトが生成されると、cobblerメタデータの変数名@@ http_server @@は、cobblerがインストールされているサーバーの実際のIPアドレスに置き換えられます。
- 次に、wget.exeがキックスタートファイルをダウンロードします。 Linuxキックスタートとは異なり、これには.cmdファイルが含まれていますが、win.ksテンプレートからcobblerサーバーによってオンザフライで生成されます。
- このファイルの名前は変更され、Windowsテキストファイル形式に変換され、通常のcmdスクリプトとして実行されます。
- C:\ TMPでスクリプトを実行した後、その取得に使用されたファイルとスクリプト自体も削除されます。
wgetでダウンロードし、キックスタートLinuxのインストール後の部分の役割を果たすファイルは、簡略化された形式では次のようになります。
ファイルの内容/var/lib/cobbler/kickstarts/win.ks # cat /var/lib/cobbler/kickstarts/win.ks $SNIPPET('my/win_wait_network_online') set n=0 :mount_y net use y: \\@@http_server@@\Public /user:install install set exit_code=%ERRORLEVEL% IF %exit_code% EQU 0 GOTO mount_z set /an=n+1 IF %n% lss 20 goto mount_y PAUSE goto mount_y set n=0 :mount_z net use z: \\@@http_server@@\winos /user:install install set exit_code=%ERRORLEVEL% IF %exit_code% EQU 0 GOTO mount_exit set /an=n+1 IF %n% lss 20 goto mount_z PAUSE goto mount_z :mount_exit if exist %systemdrive%\TMP\stage.dat goto flag005 echo 0 > %systemdrive%\TMP\stage.dat $SNIPPET('my/win_check_virt') #if $distro_name in ( 'WinXp_EN-i386', 'WinXp_RU-i386', 'Win2K3-Server_EN-x64' ) z:\Drivers\wsname.exe /N:$DNS /NOREBOOT #else REM pause #end if echo Windows Registry Editor Version 5.00 > %systemdrive%\TMP\install.reg echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce] >> %systemdrive%\TMP\install.reg echo "DD"="C:\\TMP\\install.cmd" >> %systemdrive%\TMP\install.reg $SNIPPET('my/win_install_drivers') #if $distro_name == 'Win2K3-Server_EN-x64' start /wait z:\Win2K3-Server_EN-x64\cmpnents\r2\setup2.exe /q /a /sr start /wait y:\Windows\Win2003\IE8-WindowsServer2003-x64-ENU.exe /passive /update-no /norestart if %virt% equ NO REG IMPORT y:\Windows\Win2003\vm.reg #end if REG IMPORT %systemdrive%\TMP\install.reg net use Y: /delete net use Z: /delete %systemdrive%\TMP\sleep.exe 10 exit :flag005 for /f "tokens=*" %%i in (%systemdrive%\TMP\stage.dat) do set stage=%%i echo 1 > %systemdrive%\TMP\stage.dat REG IMPORT %systemdrive%\TMP\install.reg if %stage% neq 0 goto flag010 net use Y: /delete net use Z: /delete shutdown -r -f -t 5 exit :flag010 if %stage% gtr 1 goto flag020 echo 2 > %systemdrive%\TMP\stage.dat $SNIPPET('my/winzip') $SNIPPET('my/winrar') $SNIPPET('my/win_install_chrome') $SNIPPET('my/win_install_ffox') $SNIPPET('my/win_install_adacr') $SNIPPET('my/win_install_jdk7-x86') $SNIPPET('my/win_install_jdk7-x86_64') $SNIPPET('my/win_install_UltraVNC') #if $distro_name in ( 'WinXp_EN-i386', 'WinXp_RU-i386', 'Win2K3-Server_EN-x64' ) $SNIPPET('my/win_install_office_2007_ru') #else if $distro_name in ( 'Win7_RU-x64', 'Win2012-Server_RU-x64', 'Win8_RU-x64' ) $SNIPPET('my/win_install_office_2010_ru') #else $SNIPPET('my/win_install_office_2010_en') #end if Title Cleaning Temp files DEL "%systemroot%\*.bmp" >nul 2>&1 DEL "%systemroot%\Web\Wallpaper\*.jpg" >nul 2>&1 DEL "%systemroot%\system32\dllcache\*.scr" >nul 2>&1 DEL "%systemroot%\system32\*.scr" >nul 2>&1 DEL "%AllUsersProfile%\Start Menu\Windows Update.lnk" >nul 2>&1 DEL "%AllUsersProfile%\Start Menu\Set Program Access and Defaults.lnk" >nul 2>&1 DEL "%AllUsersProfile%\Start Menu\Windows Catalog.lnk" >nul 2>&1 DEL "%systemdrive%\Microsoft Office*.txt" >nul 2>&1 net user aspnet /delete >nul 2>&1 REM %systemdrive%\TMP\sleep.exe 60 net use Y: /delete net use Z: /delete shutdown -r -f -t 30 RD /S /Q %systemdrive%\DRIVERS\ >nul 2>&1 if not defined stage DEL /F /Q %systemdrive%\post_install.cmd DEL /F /S /Q %systemdrive%\TMP\*.* exit
ここでは、コードを乱雑にしないためにスニペットが使用されています。 ハイパーバイザーのチェックを実行し、ディストリビューションとプロファイルに応じて、このソフトウェアまたはそのソフトウェアがインストールされているかどうかに応じて、必要なドライバーをインストールします。
Win_sif.templateテンプレート
これは、すべてのバージョンのウィンドウの応答ファイルが作成される単一のテンプレートです。 他のテンプレートと同様に、すべてのcobblerメタ変数を使用できます。
$ arch、$ distro_name、$ profile_nameなど。
ファイルの内容/var/lib/tftpboot/winos/win_sif.template
#else if $distro_name in ( 'Win7_RU-x64', 'Win7_EN-x64', 'Win2k8-Server_EN-x64', 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64', 'Win8_RU-x64' ) <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> #if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <servicing> <package action="configure"> <assemblyIdentity name="Microsoft-Windows-ServerCore-Package" version="6.3.9600.16384" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" /> <selection name="IIS-WebServerRole" state="true" /> <selection name="Microsoft-Hyper-V" state="true" /> <selection name="Microsoft-Hyper-V-Offline" state="true" /> <selection name="Microsoft-Hyper-V-Online" state="true" /> <selection name="Microsoft-Hyper-V-Management-Clients" state="true" /> <selection name="Microsoft-Hyper-V-Management-PowerShell" state="true" /> <selection name="VmHostAgent" state="true" /> <selection name="FailoverCluster-FullServer" state="true" /> <selection name="FailoverCluster-PowerShell" state="true" /> <selection name="FailoverCluster-CmdInterface" state="true" /> <selection name="MultipathIo" state="true" /> <selection name="ServerManager-Core-RSAT-Role-Tools" state="true" /> <selection name="RSAT-Hyper-V-Tools-Feature" state="true" /> <selection name="ServerManager-Core-RSAT" state="true" /> <selection name="ServerMediaFoundation" state="true" /> <selection name="Remote-Desktop-Services" state="true" /> <selection name="IIS-WebServer" state="true" /> <selection name="IIS-ApplicationDevelopment" state="true" /> <selection name="IIS-CommonHttpFeatures" state="true" /> <selection name="IIS-HealthAndDiagnostics" state="true" /> <selection name="IIS-Performance" state="true" /> <selection name="IIS-Security" state="true" /> <selection name="IIS-WebServerManagementTools" state="true" /> </package> </servicing> #end if <settings pass="windowsPE"> <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> #if $distro_name in ( 'Win7_RU-x64', 'Win2012-Server_RU-x64', 'Win8_RU-x64' ) <InputLocale>0409:00000409;0419:00000419</InputLocale> <SystemLocale>ru-RU</SystemLocale> <UILanguage>ru-RU</UILanguage> <UILanguageFallback>ru-RU</UILanguageFallback> <UserLocale>ru-RU</UserLocale> #else <InputLocale>0409:00000409</InputLocale> <SystemLocale>en-US</SystemLocale> <UILanguage>en-US</UILanguage> <UILanguageFallback>en-US</UILanguageFallback> <UserLocale>en-US</UserLocale> #end if </component> <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <DiskConfiguration> <WillShowUI>OnError</WillShowUI> <Disk wcm:action="add"> <CreatePartitions> <CreatePartition wcm:action="add"> <Order>1</Order> <Extend>true</Extend> <Type>Primary</Type> </CreatePartition> </CreatePartitions> <DiskID>0</DiskID> <WillWipeDisk>true</WillWipeDisk> </Disk> </DiskConfiguration> <ImageInstall> <OSImage> <InstallFrom> <Credentials> <Domain></Domain> </Credentials> <MetaData wcm:action="add"> <Key>/IMAGE/NAME</Key> #if $profile_name == 'IOS' <Value>Windows8_VmVare_MacOS_xCode</Value> #else if $distro_name in ( 'Win7_RU-x64', 'Win7_EN-x64' ) <Value>Windows 7 PROFESSIONAL</Value> #else if $distro_name in ( 'Win2k8-Server_EN-x64' ) <Value>Windows Server 2008 R2 SERVERENTERPRISE</Value> #else if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <Value>Windows Server 2012 R2 SERVERDATACENTER</Value> #else if $distro_name in ( 'Win8_RU-x64' ) <Value>Windows 8.1 Pro</Value> #else if $distro_name in ( 'Win8_EN-x64' ) <Value>Windows 8.1 Enterprise</Value> #end if </MetaData> </InstallFrom> <InstallTo> <DiskID>0</DiskID> <PartitionID>1</PartitionID> </InstallTo> </OSImage> </ImageInstall> <UserData> <ProductKey> #if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <Key>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</Key> #end if <WillShowUI>Never</WillShowUI> </ProductKey> <AcceptEula>true</AcceptEula> <FullName>User</FullName> <Organization>My Organization</Organization> </UserData> <EnableFirewall>false</EnableFirewall> </component> <component name="Microsoft-Windows-PnpCustomizationsWinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <DriverPaths> #if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64', 'Win8_RU-x64' ) <PathAndCredentials wcm:action="add" wcm:keyValue="1"> <Path>\\@@http_server@@\WINOS\Drivers\CHIPSET\Win8</Path> </PathAndCredentials> #else <PathAndCredentials wcm:action="add" wcm:keyValue="1"> <Path>\\@@http_server@@\WINOS\Drivers\CHIPSET\5520\Vista</Path> </PathAndCredentials> <PathAndCredentials wcm:action="add" wcm:keyValue="2"> <Path>\\@@http_server@@\WINOS\Drivers\CHIPSET\C200\WIN7</Path> </PathAndCredentials> #end if <PathAndCredentials wcm:action="add" wcm:keyValue="3"> #if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64', 'Win8_RU-x64' ) <Path>\\@@http_server@@\WINOS\Drivers\NIC\Win8</Path> #else <Path>\\@@http_server@@\WINOS\Drivers\NIC</Path> #end if </PathAndCredentials> #if $distro_name in ( 'Win7_RU-x64', 'Win7_EN-x64', 'Win2k8-Server_EN-x64' ) <PathAndCredentials wcm:action="add" wcm:keyValue="4"> <Path>\\@@http_server@@\WINOS\Drivers\ACPI\64\WIN7</Path> </PathAndCredentials> #end if <PathAndCredentials wcm:action="add" wcm:keyValue="5"> <Path>\\@@http_server@@\WINOS\Drivers\Storage\64</Path> </PathAndCredentials> <PathAndCredentials wcm:action="add" wcm:keyValue="6"> #if $distro_name in ( 'Win8_RU-x64' ) <Path>\\@@http_server@@\WINOS\Drivers\Virt\Win8</Path> #else if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <Path>\\@@http_server@@\WINOS\Drivers\Virt\2012</Path> #else if $distro_name in ( 'Win2k8-Server_EN-x64' ) <Path>\\@@http_server@@\WINOS\Drivers\Virt\2008</Path> #else <Path>\\@@http_server@@\WINOS\Drivers\Virt\Win7</Path> #end if </PathAndCredentials> </DriverPaths> </component> </settings> <settings pass="offlineServicing"> <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <EnableLUA>false</EnableLUA> </component> </settings> <settings pass="specialize"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ComputerName>*</ComputerName> <RegisteredOrganization>My Organization</RegisteredOrganization> <RegisteredOwner>Instructor</RegisteredOwner> #if $distro_name == 'Win7_RU-x64' <ProductKey>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</ProductKey> #else if $distro_name == 'Win7_EN-x64' <ProductKey>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</ProductKey> #else if $distro_name == 'Win2k8-Server_EN-x64' <ProductKey>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</ProductKey> #else if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <ProductKey>XXXXX-XXXXX-XXXXX-XXXXX-XXXXX</ProductKey> #end if </component> <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Identification> <JoinWorkgroup>WORKGROUP</JoinWorkgroup> </Identification> </component> <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <fDenyTSConnections>false</fDenyTSConnections> </component> <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <FirewallGroups> <FirewallGroup wcm:action="add" wcm:keyValue="EnableRemoteDesktop"> <Active>true</Active> <Group>Remote Desktop</Group> <Profile>all</Profile> </FirewallGroup> </FirewallGroups> </component> <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <UserAuthentication>0</UserAuthentication> </component> </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <OOBE> <ProtectYourPC>3</ProtectYourPC> <NetworkLocation>Work</NetworkLocation> </OOBE> <UserAccounts> <AdministratorPassword> <Value>XXXX</Value> <PlainText>false</PlainText> </AdministratorPassword> <LocalAccounts> <LocalAccount wcm:action="add"> <Password> <Value>XXXXX</Value> <PlainText>false</PlainText> </Password> <Name>User</Name> <Group>Administrators</Group> </LocalAccount> </LocalAccounts> <DomainAccounts> <DomainAccountList wcm:action="add"> <Domain>WORKGOUP</Domain> <DomainAccount wcm:action="add"> <Name>Domain Admins</Name> <Group>Administrators</Group> </DomainAccount> <DomainAccount wcm:action="add"> <Name>User</Name> <Group>Administrators</Group> </DomainAccount> </DomainAccountList> </DomainAccounts> </UserAccounts> <TimeZone>Central Asia Standard Time</TimeZone> <RegisteredOrganization>My Organization</RegisteredOrganization> <RegisteredOwner>User</RegisteredOwner> <FirstLogonCommands> <SynchronousCommand wcm:action="add"> <RequiresUserInput>false</RequiresUserInput> <Order>1</Order> <CommandLine>cmd /C wmic useraccount where "name='user'" set PasswordExpires=FALSE</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <RequiresUserInput>false</RequiresUserInput> <Order>2</Order> <CommandLine>c:\post_install.cmd @@profile_name@@</CommandLine> </SynchronousCommand> </FirstLogonCommands> <AutoLogon> <Password> <Value>XXXX</Value> <PlainText>false</PlainText> </Password> <Enabled>true</Enabled> <Domain>WORKGOUP</Domain> <Username>User</Username> <LogonCount>10000</LogonCount> </AutoLogon> </component> </settings> #if $distro_name in ( 'Win7_RU-x64', 'Win7_EN-x64' ) <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows 7 professional.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> #else if $distro_name in ( 'Win2k8-Server_EN-x64' ) <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverenterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> #else if $distro_name in ( 'Win2012-Server_EN-x64', 'Win2012-Server_RU-x64' ) <cpi:offlineImage cpi:source="wim:c:/netboot/install.wim#Windows Server 2012 R2 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> #else if $distro_name in ( 'Win8_RU-x64' ) <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows 8.1 Pro.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> #end if </unattend> #end if
ここで重要なのは、プロファイル名をパラメーターとして使用してスクリプトを開始する行です。- Xp、2003用
[GuiRunOnce] "%Systemdrive%\post_install.cmd @@profile_name@@"
- 7、8、2008、2012
<SynchronousCommand wcm:action="add"> <RequiresUserInput>false</RequiresUserInput> <Order>2</Order> <CommandLine>c:\post_install.cmd @@profile_name@@</CommandLine> </SynchronousCommand>
Startnet.templateテンプレート
開始スクリプトがwimイメージ用に形成されるテンプレート。- ネットワークスタックを初期化した後、スクリプトはDHCPサーバーのIPアドレスを検出します(sambaを含むcobblerもあります)。
- 必要なSambaネットワークリソースがマウントされます。
- プロファイルの応答ファイル名($ kernel_options [“ sif”])はcobblerメタデータから取得されます。
- DNSサーバーに照会することにより、DNSにインストールされているコンピューターの名前を見つけて、応答ファイルに入力します。
- この応答ファイルを使用してインストールを開始します。
ファイルの内容/var/lib/cobbler/kickstarts/startnet.template wpeinit ping 127.0.0.1 -n 10 >nul md \tmp cd \tmp ipconfig /all | find "DHCP Server" > dhcp ipconfig /all | find "IPv4 Address" > ipaddr FOR /F "eol=- tokens=2 delims=:" %%i in (dhcp) do set dhcp=%%i FOR %%i in (%dhcp%) do set dhcp=%%i FOR /F "eol=- tokens=2 delims=:(" %%i in (ipaddr) do set ipaddr=%%i net use y: \\%dhcp%\Public /user:install install net use z: \\%dhcp%\WINOS\@@distro_name@@ /user:install install set exit_code=%ERRORLEVEL% IF %exit_code% EQU 0 GOTO GETNAME echo "Can't mount network drive goto EXIT :GETNAME y:\windows\bind\nslookup.exe %ipaddr% | find "name =" > wsname for /f "eol=- tokens=2 delims==" %%i in (wsname) do echo %%i > ws for /f "eol=- tokens=1 delims=." %%i in (ws) do set wsname=%%i FOR %%i in (%wsname%) do set wsname=%%i #set $unattended = "set UNATTENDED_ORIG=Z:\\sources\\" + $kernel_options["sif"] $unattended set UNATTENDED=X:\tmp\autounattended.xml echo off FOR /F "tokens=1 delims=!" %%l in (%UNATTENDED_ORIG%) do ( IF "%%l"==" <ComputerName>*</ComputerName>" ( echo ^<ComputerName^>%wsname%^<^/ComputerName^>>> %UNATTENDED% ) else ( echo %%l>> %UNATTENDED% ) ) echo on :INSTALL set n=0 z:\sources\setup.exe /unattend:%UNATTENDED% set /an=n+1 ping 127.0.0.1 -n 5 >nul IF %n% lss 20 goto INSTALL :EXIT
Winpe7.templateおよびwinpe8.templateテンプレート
Win 7およびWin 8の統合されたドライバーを使用したネットワークインストールの標準イメージ。コマンドで、cobbler sync
それらは各プロファイルに示されている場所にコピーされます。そのようなコピーはそれぞれマウントされ、startnet.templateテンプレートに基づいて作成された開始スクリプトがそこにコピーされ、同期後のトリガーで分解されます。Linuxでwimイメージを使用するには、wimlib を使用しますが、これを使用するには、ntfs-3gパッケージをインストールする必要があります。したがって、私のように、libvirtの制御下でLinuxコンテナーlxcにcobblerをインストールする場合、行ドメイン定義をxmlで記述する必要があります。 <hostdev mode='capabilities' type='misc'> <source> <char>/dev/fuse</char> </source> </hostdev>
配布およびプロファイル定義を作成する
cobblerで配布定義を作成します。
ここでは、カーネルはダミーです。PXEは、このpxeboot.n12に基づいて作成されたファイルをコマンドでロードしますcobbler sync
。/var/lib/tftpboot/winos/add_ram.datは架空のinitrdでもありますが、それはあなたが何かをすり抜けることができるという意味です-そうでなければ、ディストリビューションを作成できません。cobblerでプロファイル定義を作成します。
Win8_RU-x64配布キットに基づいて、2つのテストインストールオプションのプロファイルを作成します。
win.ksでは、次のような構造を挿入できます。
プロファイル内のファイル名は実際のものであり、このディストリビューションの/etc/tftpd.rulesで定義されているテンプレートと一致する必要があります。ファイル自体はまだ存在していません。それらはコマンドが実行されたときにトリガーによって作成されcobbler sync
ます。PXEブートメニューテンプレート
Cobblerはデフォルトでリストの形式でメニューを作成しますが、より便利にするためにもう少し作業する必要があります。何らかの理由で、cobbler開発者は、テンプレートからpxeメニューを生成するときに、http_server変数の値をserver.example.org
構成ファイルから取得するのではなく、固定値に設定します。これはWindowsメニュー項目に干渉しませんが、Linuxの場合、この値を使用して、キックスタートファイルの場所を指定できます。これを修正します。
/etc/cobbler/pxe/pxedefault.templateファイルから $pxe_menu_items
削除して、代わりに独自の何かを描くことができます: menu begin Linux MENU TITLE Linux label Fedora-latest-x86_64 MENU INDENT 5 MENU LABEL Fedora-latest-x86_64 kernel /images/Fedora-22-x86_64/vmlinuz append initrd=/images/Fedora-22-x86_64/initrd.img ks.device=bootif ks.sendmac lang=en text ks=http://@@http_server@@/cblr/svc/op/ks/profile/Fedora-latest-x86_64 ipappend 2 label returntomain menu label Return to ^main menu. menu exit menu end menu begin Windows MENU TITLE Windows label Win8-test1 MENU INDENT 5 MENU LABEL Win8-test1 kernel /winos/Win8_RU-x64/win81b.0 label Win8-test2 MENU INDENT 5 MENU LABEL Win8-test2 kernel /winos/Win8_RU-x64/win81c.0 label returntomain menu label Return to ^main menu. menu exit menu end
すべてをまとめる
テンプレートから、ブートファイル、スクリプト、ダウンロード用のwimイメージを作成し、すべて適切な場所に配置します。これを行うために、ポスト同期でcobblerトリガーを使用することにしました。ファイルの内容/usr/lib/python2.7/site-packages/cobbler/modules/sync_post_wingen.py import distutils.sysconfig import sys import os import traceback import cexceptions import os import re import xmlrpclib import pefile import cobbler.module_loader as module_loader import cobbler.utils as utils import cobbler.config as config import cobbler.templar as templar template_dir = "/var/lib/tftpboot/winos/" sif_template_name = template_dir + "win_sif.template" post_inst_cmd_template_name = template_dir + "post_inst_cmd.template" startnet_template_name = template_dir + "startnet.template" wim7_template_name = template_dir + "winpe7.template" wim8_template_name = template_dir + "winpe8.template" wimlib = "/usr/bin/wimlib-imagex" wimlib_mount = wimlib + " mountrw" wimlib_umount = wimlib + " unmount" mount_point = "/mnt/wim" bcdedit = "/usr/local/bin/bcdedit.pl" plib = distutils.sysconfig.get_python_lib() mod_path="%s/cobbler" % plib sys.path.insert(0, mod_path) def register():
これは、Cobbler APIを使用した通常のPythonスクリプトです。その作業のために、pefileを使用してbootmgr.exeのチェックサムを再計算し、bcdedit.plでBCDとwimlibライブラリを変更してイメージをマウントし、テンプレートから作成されたstartnet.cmdファイルをWindows / System32フォルダーにコピーします。コマンドを実行します。
次に、ネットワーク経由でインストールする仮想マシンを作成するか、通常のコンピューターでリセット、F12ボタン(またはこれらの目的のためにBIOSに書き込まれたもの)を押し、メニューで目的の項目を選択し、LinuxとWindowsの両方の自動ネットワークインストールをお楽しみください。必要に応じて、win.ksで条件付きコード生成を使用してスクリプトを変更します。このファイルのヘッダーには、最初にインストールオプションに必要な一般的な部分があり、次に長いif / elseがあります。
重複したコードまたは論理的に閉じたコードはスニペットでレンダリングされます。不足しているもの
- Windowsディストリビューションのインポートは機能しません。Microsoftは新しいバージョンをそれほど頻繁にリリースしないので、あなたはそれを生き残ることができます。
- WindowsディストリビューションのISOイメージの作成は機能しません(確認することさえしませんでした)。
- PXE cobbler Windows .
- , /etc/tftpd.rules. , .