- 第äžäžä»£ã®è»ïŒGen1ïŒãæ§ç¯ããŸãã ããã¯ãVagrantã®çŸåšã®ããŒãžã§ã³ïŒ1.7.2ïŒãããŒããã£ã¹ã¯ã®ãã©ã¡ãŒã¿ãŒã誀ã£ãŠèšå®ããŠãããšããäºå®ã«ãããã®ã§ãïŒGen2ã«ã¯ãIDEããªãã·ã§ã³ããªãããVHDãã«çœ®ãæããããŸãïŒãçŸåšãGen2ã«ã¯é¢äžããªãããšããå§ãããŸãã ãã ããæ¬åœã«å¿ èŠãªå Žåã¯ããã¡ã€ã«plugins / providers / hyperv / scripts / import_vm.ps1ãä¿®æ£ã§ããŸãã
- ããŒããã£ã¹ã¯ã®1ã€ã®ãã¡ã€ã«ã®ã¿ã䜿çšããŠãã ãããããããªããšãããã¯ã¹ãäžæããŸããïŒä»¥äžãåç §ïŒã
- äžèŠãªãœãããŠã§ã¢ïŒWindowsã³ã³ããŒãã³ããå«ãïŒãããã¯ã¹ã«ã€ã³ã¹ããŒã«ããªãã§ãã ããã ããã«ããéããªãããã°ãããããšå€ãããŒãžã§ã³ãååšããå¯èœæ§ãé«ããªããŸãã ããããžã§ãã³ã°ã®æ®µéã§ããããåŸã§è¡ãæ¹ãããæ£ç¢ºã§ãã
- Boxstarterãæ£åžžã«æ©èœããã«ã¯ãPowershellã®å¶éãç¡å¹ã«ããå¿
èŠããããŸãã
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
- ããã©ã«ãã§ã¯ãVagrantã¯SSHïŒãã·ã³ã«åŸè
ãã€ã³ã¹ããŒã«ããå¿
èŠããããŸãïŒãä»ããŠãã·ã³ã«ã¢ã¯ã»ã¹ããŸãããæè¿ã®ããŒãžã§ã³ã§ã¯Windowsãã€ãã£ãã®WinRMãããã³ã«ã䜿çšããŠåäœããããšãåŠã³ãŸããã å¿
èŠãªããšã¯ãWinRMãæ§æããããšã ãã§ãã
winrm set winrm / config / client / auth '@ {Basic = "true"}'
winrm set winrm / config / service / auth '@ {Basic = "true"}'
winrm set winrm / config / service '@ {AllowUnencrypted = "true"} - ç§ã¯éåžžãäžèŠãªãµãŒãã¹ãç¡å¹ã«ãïŒã¹ã¿ãŒãã¢ããã¢ãŒããæåã«èšå®ããŸãïŒïŒå°å·ã¹ããŒã©ãŒã¯åãã§ãïŒããã£ã¹ã¯ã€ã³ããã¯ã¹äœæãšæ¯é±ã®èªåæé©åãåé€ããŸãããã€ããŒãã€ã¶ãŒèªäœã«ãã£ãŠã¹ãã¬ãŒãžå±€ãæé©åããŸãã
- ã¹ã¯ãããã¡ã€ã«ã®ãµã€ãºãå°ãããããã®ãµã€ãºãåºå®ããŸãã
- ãã¹ãŠã®ãã°ãæ¶å»ããŸãã
wevtutil el | Foreach-Object {wevtutil cl "$ _"}
- äžèŠãªWindows Updateã³ã³ããŒãã³ããåé€ããŸãã
Dism.exe / online / Cleanup-Image / StartComponentCleanup / ResetBase
Dism.exe /ãªã³ã©ã€ã³/ Cleanup-Image / SPSuperseded - Windowsã³ã³ããŒãã³ãã®ã€ã³ã¹ããŒã©ãŒãåé€ããŸãã Get-WindowsFeatureã³ãã³ããå®è¡ãããšãäžéšã®ã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ç¶æ
=å©çšå¯èœã«ãªã£ãŠããããšãããããŸãã ããã¯éåžžããããã®ã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ã§ããããšãæå³ãããã®ããã«ã¯ãããŒã«ã«ãã£ã¹ã¯ã«çŽæ¥æ ŒçŽããããã£ãã·ã¥ã§ååã§ãã ãããã£ãŠã次ã®ã³ãã³ããå®è¡ããŠãã®ãã£ãã·ã¥ãåé€ããããšã¯çã«ããªã£ãŠããŸãã
Get-WindowsFeature |
ïŒ {$ _ãInstallState -eq 'Available'} |
Uninstall-WindowsFeature -Remove - åŸã§äŸ¿å©ã«ãªãã³ã³ããŒãã³ããããå Žåã¯ããã®ãŸãŸã«ããŠããããšããå§ãããŸãããã以å€ã®å Žåã¯ãåŸç¶ã®ã€ã³ã¹ããŒã«æã«wim-fileãžã®ãã¹ãæå®ããå¿ èŠããããŸãïŒ-Sourceãã©ã¡ãŒã¿ãŒïŒã ãã ããå¿é ããå¿ èŠã¯ãããŸããããã®ãã¡ã€ã«ã¯ã·ã¹ãã ã®ã€ã³ã¹ããŒã«å ã®ISOãã¡ã€ã«ã«ãããããŒã«ã«ããã³ãããã¯ãŒã¯ãªãœãŒã¹ã®äž¡æ¹ãã䜿çšã§ããŸãã ããã«ãäžéšã®ã³ã³ããŒãã³ãã¯ã€ã³ã¿ãŒãããããå®å šã«ã€ã³ã¹ããŒã«ãããŸã-Powershellã¯å¿ èŠãªãã¡ã€ã«èªäœãããŠã³ããŒãããŸãã
- å¿ èŠã«å¿ããŠããã£ã¹ã¯ã¯ãªãŒã³ã¢ãã-äžæãã¡ã€ã«ããã·ã¹ãã ãèªåçã«ã¯ãªãŒã³ã¢ããããããã°ã©ã ãã€ã³ã¹ããŒã«ã§ããŸãã ãã ãããã®ããã«ã¯ãDesktop-ExperienceããŒã«ãè¿œå ããå¿ èŠããããã¢ã³ã€ã³ã¹ããŒã«ã«ããsysprepã§åé¡ãçºçããŸãã ãã®ããã2ã€ã®ãªãã·ã§ã³ããããŸãããã®æ©èœããã®ãŸãŸã«ããŠãããèªäœãå Žæãé£ãå°œãããã¬ãžã¹ããªãéãããŸãïŒã€ã³ã¯ãææžãã®ãããªå¿ é ã ãäœåãªãžã£ã³ã¯ãåŒã£åŒµãããïŒããŸãã¯sysprepãæåŠããŸãããã¡ã€ã³å ã®ãã·ã³ã
- ããããã¹ãŠã®æäœã®åŸãåçVHDãã¡ã€ã«ã®ãµã€ãºã¯å€ãããŸããã å§çž®ããã«ã¯ããŸãããã©ã°ããŠããã¹ãŠã®ãã¡ã€ã«ããã£ã¹ã¯ã®å
é ã«ç§»åããå¿
èŠããããŸãã
Optimize-Volume -DriveLetter C -Defrag
- æé©ååŸãSysInternalsã®äžéšã§ããsdeleteã³ãã³ãã䜿çšããŠãã¹ãŠã®ç©ºãé åããªã»ããããããšãæãŸããã§ãã
sdelete -zcïŒ
ããã«ãããåŸã§ããå¹ççã«å§çž®ã§ããŸãã
SysprepãŠã©ãŒãã³ã°
æãäžè¬çãªã±ãŒã¹ã§ã¯ãsysprepã䜿çšããŠã¯ããŒã³äœæã®ããã«ä»®æ³ãã·ã³ãæºåããããšã¯ãããªãäžè¬çãªæé ã§ãã ãããGUIãšããŠäœ¿çšã§ããŸããCïŒ\ Windows \ System32 \ Sysprep \ sysprep
ã³ãã³ãã©ã€ã³ã¯ãç§ãã¡ã®å¥œã¿ã«ããåã£ãŠãããè¿œå ã®ãã©ã¡ãŒã¿ãŒãæå®ããããšãã§ããŸãã
CïŒ\ Windows \ System32 \ Sysprep \ sysprep / generalize / oobe /ã¢ãŒãïŒvm / shutdownãã®åŸãããã°ã©ã ã¯ãã¹ãŠã®å¿ èŠãªæäœãå®è¡ããè»ãåºããŸãã 次åã·ã¹ãã ã®é»æºãå ¥ãããšãåè¿°ã®OOBEïŒOut-of-Box ExperienceïŒã«ãªããŸã-æåã«é»æºãå ¥ãããšãã«æ°ããè³Œå ¥ããã©ããããããå ¥ã£ãŠããç¶æ ã§ãïŒéã®ã€ã³ãã³ããªãå®è¡ãããããŒã«ã«ç®¡çè ãã¹ã¯ãŒããã©ã€ã»ã³ã¹ããŒãã³ã³ãã¥ãŒã¿ãŒåãªã©ãèŠæ±ãããŸãã ãã¹ãŠã¯äœããããŸããããããŒããŒãããããããã¹ãŠãæåã§å ¥åããå¿ èŠããããŸãã 幞ããªããšã«ãããã¯ãã¹ãŠç°¡åã«èªååãããŸãã ãããè¡ãã«ã¯ãå¿çãã¡ã€ã«unattend.xmlãæºåããèµ·åãããsysprep.exeãã¡ã€ã«ã®é£ïŒCïŒ\ Windows \ System32 \ Sysprepãã©ã«ããŒïŒã«é 眮ããããã³ãã³ãã©ã€ã³ãã©ã¡ãŒã¿ãŒãšããŠãã®ãã¹ãæå®ããŸããããã«ãããå€éšã«ãã¡ã€ã«ãé 眮ã§ããŸãæåŸã®ããã¯ã¹ã«è¡šç€ºãããªãããã«ããŸãã ããã«ã€ããŠã¯è©³ãã説æããŸããããã®ããã«ã¯ãWindowsã€ã³ã¹ããŒã«ã€ã¡ãŒãžïŒããæ£ç¢ºã«ã¯ãããããã®install.wimãã¡ã€ã«ïŒãšWindows Assessment and Deployment KitïŒADKïŒïŒWindowsã·ã¹ãã ãå«ãDeployment Toolsã¢ã€ãã ã®ã¿ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒç»åãããŒãžã£ãŒïŒã ãã£ã¹ããªãã¥ãŒã·ã§ã³ãžã®ãªã³ã¯ãæ瀺ã䜿çšäŸã¯ãèšäºã®æ¬¡ã®æçµéšåã®é©åãªã»ã¯ã·ã§ã³ã«ãããŸãã
éèŠãªãã¥ã¢ã³ã¹ïŒ
- Desktop-Experienceã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ããŠããã¢ã³ã€ã³ã¹ããŒã«ããå ŽåãSysprepã¯ãšã©ãŒã§å€±æããŸãã äžã§è¿°ã¹ãããã«ããã®ã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ãããŸãŸã«ããããã€ã³ã¹ããŒã«ããªããã®2ã€ã®ãªãã·ã§ã³ããããŸãã 詳现ã«ã€ããŠã¯ã ããã°ã® Matt RockïŒBoxstarterèè ïŒãåç §ããŠãã ããã
- ããã¯ã¹ãæºåãããšããå€ãã®å Žåãäœããå€æŽããå¿ èŠããããŸããããã«ãããããã¯ã¹ãOOBEç¶æ ã«ãªãããã¹ãŠã®èšå®ãå¿çãã¡ã€ã«ã«åŸã£ãŠæž¡ãããå¿ èŠãªå€æŽãè¡ãããã·ã¹ãã ãSysprepã«ãã£ãŠå床å®è¡ãããŸãã ããã2åããçºçããªãïŒã€ãŸãã3åã®sysprepå®è¡ïŒããšã«æ³šæããŠãã ããã ããã¯ãMicrosoftã®ã©ã€ã»ã³ã¹æ©èœã«ãããã®ã§ãã ååãšããŠãã¬ãžã¹ããªã®unningãªç·šéã«ãã£ãŠãããè¡ãããšãã§ããŸãããããã¯æ¬çªç°å¢ã§ã¯ãªããäžæçãªãã·ã³ãŸãã¯ãã¹ããã·ã³ã«å¯ŸããŠã®ã¿è¡ãããšãã§ããŸãããããã£ãŠãå¿ èŠã«å¿ããŠãããã«äœæ¥ããããã«ã€ã¡ãŒãžãåçŽã«ä¿åããå¿ èŠã«å¿ããŠã³ããŒãäœæããæ°ããããŒãžã§ã³ãåå¥ã«æºåããããšããå§ãããŸãã ãããã£ãŠãåä»®æ³ãã·ã³ã¯ããã®åç¶æéå šäœã«ããã£ãŠäžåºŠã«ãåãé¢ããããŸãã
- ã³ã³ãã¥ãŒã¿ãŒåãèšå®ããªãæ¹ãè¯ã-ããã¯ã©ã³ãã ã«çæãããã®ã§ãè€æ°ã®ãã·ã³ãåæã«çºçããŠããå Žåã®æ··ä¹±ãšç«¶åãåé¿ã§ããŸãã ããã«ãæã¡äžãããšãã«ããããžã§ãã³ã°ã®æ®µéã§ã浮浪è èªèº«ãç°¡åã«ã€ã³ã¹ããŒã«ã§ããŸãã
- ããŒã«ã«ç®¡çè ã®è€éã§å®å šãªãã¹ã¯ãŒããèšå®ããŸãã ãã¡ãããå°æ¥çã«ã¯å€æŽããïŒãŸãã¯ãããã¯ããïŒããšããå§ãããŸãã ãã®ã¢ã«ãŠã³ãã¯ãããããžã§ãã³ã°æ®µéã§ãã·ã³ãäžãããšãã«å¿ èŠã«ãªããŸããVagrantããœãããŠã§ã¢ãã€ã³ã¹ããŒã«ããã·ã¹ãã ãæŽæ°ããå¿ èŠãªãã¹ãŠã®èšå®ãè¡ãã®ã¯ãã®äžã§ãã
- ãã€ããŒãã€ã¶ãŒèªäœã®ãã·ã³åïŒHyper-VãããŒãžã£ãŒã§åŒã³åºãããïŒãçãã·ã³ãã«ãªååã«å€æŽããããšããå§ãããŸã-ããã¯ãæ¡åŒµããã¯ã¹ããã®ãã·ã³ã®ååã§ãã ååãç§ã®ãã©ã€ã¢ã«ããã¯ã¹ãæŸãäžããçµæããWinda 2k12 r2 x64 syspreped with bloody winrm settings version 111 test 222 yoããšããã¿ã€ãã®ãã·ã³ãæã«å ¥ãããšããåä»ãªç¶æ³ããããŸããã
箱詰ã
Sysprepãè»ãåºããåŸãä»®æ³ãã·ã³ããã¯ã·ã³ã°ãã¡ã€ã«ã«ããã¯ããŸãã äžè¬ã«ãVagrantã«ã¯ãã®ããã®çµã¿èŸŒã¿æ©èœïŒããããžã§ãã³ã°ã³ãã³ãïŒããããŸãããçŸåšã®ãšãããHyper-Vã§ã¯æ©èœããŸããã ã ããç§ãã¡ã¯èªåã®æã§ãã¯ã·ã³ã°ãããã¯ããŸã-æããããšã¯äœããããŸãããããã¯éåžžã«ç°¡åã«è¡ãããŸãïŒ- ãã·ã³ã®ããŒããŠã§ã¢æ§æããã§ãã¯ãããŸãïŒããã»ããµã³ã¢ã®æ°ãã¡ã¢ãªãµã€ãºãããŒãåªå é äœã ãããã®ãã©ã¡ãŒã¿ãŒã¯ãæ°ããå±éããããã·ã³ã«ãããŸãïŒãã¡ãããåŸã§å€æŽããããšã劚ãããã®ã¯ãããŸããïŒã
- ããŒããã£ã¹ã¯ã®ãã¹ãŠã®ã€ã¡ãŒãžïŒã¹ãããã·ã§ããïŒãåé€ãããŸãã
- æºåå®äºãã·ã³ã¯ããã£ã¹ã¯äžã®å¥ã®ãã©ã«ããŒã«ãšã¯ã¹ããŒããããŸãã ããã¯ãããŒããã£ã¹ã¯ãã¡ã€ã«ãšãã¹ãŠã®ã¡ã¿æ å ±ã®é£ã«é 眮ããå¿ èŠããããŸãã
- ã¹ãããã·ã§ãããã¡ã€ã«ã®ãã©ã«ããŒã¯ãä»®æ³ãã·ã³ã®ãããã©ã«ããŒããåé€ãããŸããWagrantãããã€ããŒã®Hyper-Vã¯åŒãç¶ã䜿çšããŸããã
- ããã¹ããã¡ã€ã«metadata.jsonãããã«äœæãããŸãã å°ãªããšããããã«å°ãªããšã1ã€ã®ãããã€ããŒãå®çŸ©ããå¿
èŠããããŸãïŒãã®å ŽåãHyper-VïŒã ãã®ã±ãŒã¹ã®ãµã³ãã«ãã¡ã€ã«ïŒ
{
ãååãïŒãWindows2012R2ãã
ã説æãïŒãç¡æéã®ããããžã§ãã³ã°ã§sysprepãããWindows 2012 R2ããã¯ã¹ãã
ããããã€ããŒãïŒãhypervã
} - ããšã¯ããã£ã¬ã¯ããªã®å 容ãã.boxãã¡ã€ã«ãäœæããã ãã§ãã ãã®ããã«ãtarã䜿çšãããŸãïŒãªããžããªããç¡æã®7-ZipãŸãã¯bsdtarã䜿çšã§ããŸããVagrant1.7.2ã«ä»å±ã®ããŒãžã§ã³ã¯æ©èœããŸããïŒã éèŠïŒã¢ãŒã«ã€ãã«ã¯ããã·ã³ããšã¯ã¹ããŒãããããã©ã«ããŒã®å 容ã®ã¿ãå«ãŸãã芪ãã©ã«ããŒã¯å«ãŸããŸãããããã§ãªãå Žåãããã¯ã¹ã¯èªèãããŸããã ã€ãŸã å éšã®ã«ãŒãã«ã¯ããä»®æ³ããŒããã©ã€ãããã£ã¬ã¯ããªãšãä»®æ³ãã·ã³ããã£ã¬ã¯ããªãããã³metadata.jsonãã¡ã€ã«ãå¿ èŠã§ãã çµæã®ãã¡ã€ã«ã¯ãgzipïŒåã³7-Zipã䜿çšã§ããŸããäž»ãªããšã¯ãæ¢ã«.tarãã¡ã€ã«ã§å¥ã®å埩ã§è¡ãããšïŒãŸãã¯LZMAïŒããè¯ãå§çž®ãæäŸããŸãããã³ããŒã«è²»ããããæéãããé·ãè²»ããããŸãïŒ gzipãunzipïŒãæ¡åŒµåãboxã«å€æŽããŸãã ã¯ãïŒ ãã¯ã·ã³ã°ã®æºåãã§ããŸããïŒ
Vagrantããããèªåèªèº«ã«ã³ããŒããŠè¡šç€ºããã«ã¯ããã¡ã€ã«ã䜿çšããŠãã£ã¬ã¯ããªããçŽæ¥addã³ãã³ãã䜿çšããŠè¿œå ããå¿ èŠããããŸãã
vagrant box add --provider hyperv --name Win2012R2x64 Win2012R2.boxãã¹ãŠãããŸããããšãããã¯ã¹ã䜿çšå¯èœã«ãªãïŒvagrantã¯ãããïŒ VAGRANT_HOMEïŒ ã«ã³ããŒããŠè§£åããŸãïŒãvagrant box listã³ãã³ãã®åºåã«è¡šç€ºãããŸãã ååãã¢ã¯ã»ã¹ã§ããããã«ããã«ã¯ãå ±æãããã¯ãŒã¯ãã©ã€ãã«çœ®ãããšãã§ããŸãïŒããã¯ã¹ãè¿œå ããã³ãã³ãã¯ãvagrant box add --name Win2012R2x64 DïŒ\ Path \ To \ Win2012R2x64 \\ fileserver.domain.local \ boxs \ win2012r2ã®åœ¢åŒã«ãªããŸãã boxïŒãŸãã¯WebãµãŒããŒïŒlocalïŒvagrant box add --name Win2012R2x64 httpïŒ//devops.local/boxes/win2012r2.boxïŒãŸãã¯externalã ããšãã°ã httpïŒ //www.vagrantbox.es/ãŸãã¯Hashicorp Atlas㧠ã
次ã®ããŒãã§ã¯ãVMããã¯ã·ã³ã°ãã解é€ããããããžã§ãã³ã°ã䜿çšããŠVMãèªåçã«æ§æããæ¹æ³ã瀺ããŸãã