LoginSignup
16
14

More than 5 years have passed since last update.

[Vagrant](box作成) Windows10 Pro 64bit(日本語版)仮想マシン作成 (Packer使用)

Last updated at Posted at 2016-09-24

概要

  • Packerを使用して、Windows10 Pro 64bit(日本語版)仮想マシンのboxを作成
  • https://github.com/StefanScherer/packer-windows
    こちらのスクリプトを使用させてもらう。(ので詳しいことはちょっと...)
  • vagrant rdpリモートデスクトップ接続する。
  • (2017-01-30) packer 0.12.1にはWinRM関連にバグあるので、使わないこと.

環境

  • ホスト: Windows 10 (64bit)
  • git for windows 2.10.0 (Unix関係のツールのため.. bashとか、dos2unixとか)
  • VirtualBox 5.1.6 5.0.x と、拡張パック
  • Vagrant 1.8.5
  • Vagrant Packer 0.10.1 - zipを解凍して、vagrant.exeとおなじ、C:\HashiCorp\Vagrant\binにおく。

  • インストールDVDのISOイメージ C:\Win10_1607_Japanese_x64.iso におく。

    • https://www.microsoft.com/ja-jp/software-download/windows10ISO/ からダウンロード
      Win10_1607_Japanese_x64.iso: 日本語版(ja-JP) sha1=493aa01af9719edae702b65d4edd3e4f6f1e8c3f
    • 一応、こちらもOK。パッチ当てるとき注意。(先に確認したのはこっち)
      Win10_1607_English_x64.iso: 英語版(en-US) sha1=99fd8082a609997ae97a514dca22becf20420891

手順

  1. ツール類インストール

    • git, VirtualBox(とExtensionPack), Vagrant をインストールして、再起動
    • packer.exeは、ダウンロードして、C:\HashiCorp\Vagrant\bin\packer.exeとなるようにおく。
  2. Git Bashを実行して,bashのコマンドウィンドウを開く. (適当なとこで、右クリックして、Git Bash hereでもよい)

  3. 以下、こぴぺ、実行。

    bash上で実行
    cd /
    mkdir -p /c/vagrant/Win10
    cd /c/vagrant/Win10
    git clone https://github.com/StefanScherer/packer-windows.git
    cd packer-windows/
    git checkout 1c7339f4f328af7acc4bb814d56b130585d33d2c
    #
    # パッチ.
    sed -i -e 's/NPPR9-FWDCX-D2C8J-H872K-2YT43/<Key>W269N-WFGWX-YVC9B-4J6C9-T83GX<\/Key>/g' -e 's/Enterprise\ Evaluation/Pro/g' ./answer_files/10/Autounattend.xml
    sed -i -e '/guest_os_type/i \ \ \ \ \ \ "shutdown_timeout": "1h",'  ./windows_10.json
    sed -i -e 's/windows8srv-64/windows9-64/g' -e 's/Windows81_64/Windows10_64/g' ./windows_10.json
    #
    # 日本語版へのパッチ.
    sed -i -e 's/en-US/ja-JP/g' ./answer_files/10/Autounattend.xml
    sed -i -e 's/High\ performance/高パフォーマンス/g' -e 's/[3]/[2]/g' ./scripts/set-powerplan.ps1
    #
    git diff | cat
    #
    time packer build -force -only=virtualbox-iso -var 'iso_url=c:/Win10_1607_Japanese_x64.iso' -var 'iso_checksum_type=sha1' -var 'iso_checksum=493aa01af9719edae702b65d4edd3e4f6f1e8c3f'  ./windows_10.json
    #
    #英語版なら
    # time packer build -force -only=virtualbox-iso -var 'iso_url=c:/Win10_1607_English_x64.iso' -var 'iso_checksum_type=sha1' -var 'iso_checksum=99fd8082a609997ae97a514dca22becf20420891'  ./windows_10.json
    
  4. 待つ。

    ..
    ..
    Build 'virtualbox-iso' finished.
    
    ==> Builds finished. The artifacts of successful builds are:
    --> virtualbox-iso: 'virtualbox' provider box: windows_10_virtualbox.box
    
    real    38m58.514s
    user    0m0.000s
    sys     0m0.015s
    
    mt08@Win10host MINGW64 /c/vagrant/Win10/packer-windows (my)
    
  5. windows_10_virtualbox.box ができる。

  6. 使ってみる。

    cd /c/vagrant/Win10/
    vagrant box add --name Win10_1607_JP_x64 ./packer-windows/windows_10_virtualbox.box
    vagrant box list # 確認
    vagrant init Win10_1607_JP_x64
    vagrant up     # 起動
    vagrant rdp    # リモートデスクトップでログイン=> ユーザ名:vagrant/パスワード:vagrant
    vagrant halt   # VMの電源OFF
    

その他

  • -only=virtualbox-iso-only=vmware-isoにすると、VMWareのboxが作成できた.

変更点メモ

git-diff

git-diff
diff --git a/answer_files/10/Autounattend.xml b/answer_files/10/Autounattend.xml
index d4d26c5..944d7f8 100644
--- a/answer_files/10/Autounattend.xml
+++ b/answer_files/10/Autounattend.xml
@@ -46,7 +46,7 @@
                 -->

                 <!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx -->
-                <ProductKey>NPPR9-FWDCX-D2C8J-H872K-2YT43
+                <ProductKey><Key>W269N-WFGWX-YVC9B-4J6C9-T83GX</Key>
                     <WillShowUI>Never</WillShowUI>
                 </ProductKey>
             </UserData>
@@ -61,7 +61,7 @@
                     <InstallFrom>
                         <MetaData wcm:action="add">
                             <Key>/IMAGE/NAME</Key>
-                            <Value>Windows 10 Enterprise Evaluation</Value>
+                            <Value>Windows 10 Pro</Value>
                         </MetaData>
                     </InstallFrom>
                 </OSImage>
@@ -69,13 +69,13 @@
         </component>
         <component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
             <SetupUILanguage>
-                <UILanguage>en-US</UILanguage>
+                <UILanguage>ja-JP</UILanguage>
             </SetupUILanguage>
-            <InputLocale>en-US</InputLocale>
-            <SystemLocale>en-US</SystemLocale>
-            <UILanguage>en-US</UILanguage>
-            <UILanguageFallback>en-US</UILanguageFallback>
-            <UserLocale>en-US</UserLocale>
+            <InputLocale>ja-JP</InputLocale>
+            <SystemLocale>ja-JP</SystemLocale>
+            <UILanguage>ja-JP</UILanguage>
+            <UILanguageFallback>ja-JP</UILanguageFallback>
+            <UserLocale>ja-JP</UserLocale>
         </component>
     </settings>
     <settings pass="offlineServicing">
diff --git a/scripts/set-powerplan.ps1 b/scripts/set-powerplan.ps1
index 65ee32c..16195a5 100644
--- a/scripts/set-powerplan.ps1
+++ b/scripts/set-powerplan.ps1
@@ -1,6 +1,6 @@
 Try {
-  $HighPerf = powercfg -l | %{if($_.contains("High performance")) {$_.split()[3]}}
-  $CurrPlan = $(powercfg -getactivescheme).split()[3]
+  $HighPerf = powercfg -l | %{if($_.contains("高パフォーマンス")) {$_.split()[[2]]}}
+  $CurrPlan = $(powercfg -getactivescheme).split()[[2]]
   if ($CurrPlan -ne $HighPerf) {powercfg -setactive $HighPerf}
 } Catch {
   Write-Warning -Message "Unable to set power plan to high performance"
diff --git a/windows_10.json b/windows_10.json
index d01c8ea..94803d6 100644
--- a/windows_10.json
+++ b/windows_10.json
@@ -13,7 +13,8 @@
       "winrm_password": "vagrant",
       "winrm_timeout": "2h",
       "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
-      "guest_os_type": "windows8srv-64",
+      "shutdown_timeout": "1h",
+      "guest_os_type": "windows9-64",
       "disk_size": "{{user `disk_size`}}",
       "vnc_port_min": 5900,
       "vnc_port_max": 5980,
@@ -49,7 +50,8 @@
       "winrm_password": "vagrant",
       "winrm_timeout": "2h",
       "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
-      "guest_os_type": "Windows81_64",
+      "shutdown_timeout": "1h",
+      "guest_os_type": "Windows10_64",
       "guest_additions_mode": "disable",
       "disk_size": "{{user `disk_size`}}",
       "floppy_files": [

システムのプロパティ

  • "ライセンス認証されていません。"

Vagrant-box-Win10JP.png

16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14