博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
007-Cobbler批量自动化部署Windows10和Server 2019及激活
阅读量:5844 次
发布时间:2019-06-18

本文共 16268 字,大约阅读时间需要 54 分钟。

这是坚持技术写作计划(含翻译)的第7篇,定个小目标999,每周最少2篇。

本文主要讲解通过CentOS7.6 Minimal + Cobbler 自动化安装CentOS,Ubuntu,Windows 10 和 Windows Server 2019(应该算是全网第一篇Cobbler+Win10/WinServer2019了)。

请注意,一般安装windows是用或者WDS居多,毕竟是巨硬自己家的,而且MDT还支持分布式镜像传输(主要是巨硬家的OS,动辄超过4G,万兆网卡也会卡啊)。本文不涉及到MDT或者WDS相关操作,感兴趣的可自行百度或者msdn。

准备

  •  (分别下载  和 )
  • 下载
  • 下载 

注意,adk的两个都要下载,这俩都是引导包,真正的安装程序会由这俩软件进行下载。其中WinPE需要用到5G左右的磁盘空间,简直不能忍受。。。

msdn i tell u 堪称良心站,是windows装机神站啊,不过,没有直达页面挺不爽。为了防止下错,特意截图。

安装ADK和WinPE

我已经装过,且忘记截图了,这是事后补图,只需要勾选必须的就行

安装完后,以管理员身份打开部署和映像工具环境

定制Win 10 PE

copype amd64 C:\winpeDism /mount-image /imagefile:C:\winpe\media\sources\boot.wim /index:1 /mountdir:C:\winpe\mountecho net use z: \\192.168.0.253\share >> C:\winpe\mount\Windows\System32\startnet.cmdecho z:\win\setup.exe /unattend:z:\win\win10_x64_bios_auto.xml >> C:\winpe\mount\Windows\System32\startnet.cmdDism /unmount-image /mountdir:C:\winpe\mount /commitMakeWinPEMedia /ISO C:\winpe C:\winpe\winpe_win10_amd64.iso复制代码
  1. 本地生成winpe文件目录
  2. dism 挂载 winpe的启动文件到winpe的mount目录
  3. 将启动命令硬编码写死到winpe的startnet.cmd文件里
  4. 无人值守安装
  5. 卸载winpe的挂载(一定要执行,否则直接强制删除文件夹会出一些稀奇古怪的问题)
  6. 制作win10镜像,名为 winpe_win10_amd64.iso

第三步的硬编码是无奈之举,因为要想挂载共享文件夹,必须要知道smb主机,但是这个参数又很难传递进来。

如果是U盘启动,可以写死U盘路径,大不了插上U盘后,手动改卷标(当然因为U盘挂载顺序不一致,可以通过for循环A-Z盘,挨个盘访问某个文件名,如果存在,即认为此盘是自己U盘,设置环境变量)。而网上说的,startnet.cmd调用另外一个bat,多是基于这个原理。

而如果PXE要达到跟上述要求,动态设置smb主机,要么写死域名,然后劫持或者配置域名,加上bat文件,在winpe启动时,通过startnet.cmd下载,并执行。要么找办法,看看能不能在启动时,传入参数(目前我还没找到),当然还可以用MDT方案,看着比PXE+无人应答文件简单很多。

配置Cobbler Server

导入Cobbler

使用WinScp 等工具,将 winpe_win10_amd64.iso 上传到 Cobbler 服务器上

[root@localhost ~]# cobbler distro add --name=windows_10_x64 --kernel=/var/lib/tftpboot/memdisk --initrd=/root/winpe_win10_amd64.iso --kopts="raw iso"[root@localhost ~]# touch /var/lib/cobbler/kickstarts/winpe.xml[root@localhost ~]# cobbler profile add --name=windows_10_x64 --distro=windows_10_x64 --kickstart=/var/lib/cobbler/kickstarts/winpe.xml复制代码

创建自动应答文件

直接从  通过简单配置后,下载即可(只支持简单操作,比如,装系统,格式化磁盘,设置密码等)。当然也可以使用 【Windows系统映像管理器】,不过挺难用的,具体用法可以参考 。也可以通过MDT简化操作。

但是如果使用直接生成的,有点问题,即使页面设置了安装语言,但是仍旧需要手动选择,经过多方研究,发现

主要卡在UILanguage和Inputlocale上,全写zh-CN无效。

en-US
0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}
zh-CN
zh-CN
zh-CN
zh-CN
复制代码

另外就是安装密钥,统一替换为 VK7JG-NPHTM-C97JM-9MPGT-3V66T

下面是我的应答文件,仅做参考。

en-US
0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}
zh-CN
zh-CN
zh-CN
zh-CN
en-US
0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}
zh-CN
zh-CN
zh-CN
zh-CN
1
Primary
100
true
2
Primary
true
NTFS
1
1
0x27
true
NTFS
C
2
2
0
true
0
2
false
true
AnJia
AnJia
VK7JG-NPHTM-C97JM-9MPGT-3V66T
1
Primary
100
true
2
Primary
true
NTFS
1
1
0x27
true
NTFS
C
2
2
0
true
0
2
false
true
AnJia
AnJia
VK7JG-NPHTM-C97JM-9MPGT-3V66T
false
false
1
1
0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}
zh-CN
zh-CN
zh-CN
zh-CN
0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411f-A5AC-CA038EC515D7}
zh-CN
zh-CN
zh-CN
zh-CN
true
true
0
0
AnJia-PC
VK7JG-NPHTM-C97JM-9MPGT-3V66T
AnJia-PC
VK7JG-NPHTM-C97JM-9MPGT-3V66T
<div></div> true&lt;/PlainText&gt; &lt;/Password&gt; &lt;Enabled&gt;true&lt;/Enabled&gt; &lt;Username&gt;AnJia&lt;/Username&gt; &lt;/AutoLogon&gt; &lt;OOBE&gt; &lt;HideEULAPage&gt;true&lt;/HideEULAPage&gt; &lt;HideOEMRegistrationScreen&gt;true&lt;/HideOEMRegistrationScreen&gt; &lt;HideOnlineAccountScreens&gt;true&lt;/HideOnlineAccountScreens&gt; &lt;HideWirelessSetupInOOBE&gt;true&lt;/HideWirelessSetupInOOBE&gt; &lt;NetworkLocation&gt;Work&lt;/NetworkLocation&gt; &lt;SkipUserOOBE&gt;true&lt;/SkipUserOOBE&gt; &lt;SkipMachineOOBE&gt;true&lt;/SkipMachineOOBE&gt; &lt;ProtectYourPC&gt;1&lt;/ProtectYourPC&gt; &lt;/OOBE&gt; &lt;UserAccounts&gt; &lt;LocalAccounts&gt; &lt;LocalAccount wcm:action="add"&gt; &lt;Password&gt; &lt;Value&gt;&lt;/Value&gt; &lt;PlainText&gt;true&lt;/PlainText&gt; &lt;/Password&gt; &lt;Description&gt;AnJia&lt;/Description&gt; &lt;DisplayName&gt;AnJia&lt;/DisplayName&gt; &lt;Group&gt;Administrators&lt;/Group&gt; &lt;Name&gt;AnJia&lt;/Name&gt; &lt;/LocalAccount&gt; &lt;/LocalAccounts&gt; &lt;/UserAccounts&gt; &lt;RegisteredOrganization&gt;AnJia&lt;/RegisteredOrganization&gt; &lt;RegisteredOwner&gt;AnJia&lt;/RegisteredOwner&gt; &lt;DisableAutoDaylightTimeSet&gt;false&lt;/DisableAutoDaylightTimeSet&gt; &lt;FirstLogonCommands&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Description&gt;Control Panel View&lt;/Description&gt; &lt;Order&gt;1&lt;/Order&gt; &lt;CommandLine&gt;reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v StartupPage /t REG_DWORD /d 1 /f&lt;/CommandLine&gt; &lt;RequiresUserInput&gt;true&lt;/RequiresUserInput&gt; &lt;/SynchronousCommand&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Order&gt;2&lt;/Order&gt; &lt;Description&gt;Control Panel Icon Size&lt;/Description&gt; &lt;RequiresUserInput&gt;false&lt;/RequiresUserInput&gt; &lt;CommandLine&gt;reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v AllItemsIconView /t REG_DWORD /d 0 /f&lt;/CommandLine&gt; &lt;/SynchronousCommand&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Order&gt;3&lt;/Order&gt; &lt;RequiresUserInput&gt;false&lt;/RequiresUserInput&gt; &lt;CommandLine&gt;cmd /C wmic useraccount where name="AnJia" set PasswordExpires=false&lt;/CommandLine&gt; &lt;Description&gt;Password Never Expires&lt;/Description&gt; &lt;/SynchronousCommand&gt; &lt;/FirstLogonCommands&gt; &lt;TimeZone&gt;China Standard Time&lt;/TimeZone&gt; &lt;/component&gt; &lt;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"&gt; &lt;AutoLogon&gt; &lt;Password&gt; &lt;Value&gt;&lt;/Value&gt; &lt;PlainText&gt;true&lt;/PlainText&gt; &lt;/Password&gt; &lt;Enabled&gt;true&lt;/Enabled&gt; &lt;Username&gt;AnJia&lt;/Username&gt; &lt;/AutoLogon&gt; &lt;OOBE&gt; &lt;HideEULAPage&gt;true&lt;/HideEULAPage&gt; &lt;HideOEMRegistrationScreen&gt;true&lt;/HideOEMRegistrationScreen&gt; &lt;HideOnlineAccountScreens&gt;true&lt;/HideOnlineAccountScreens&gt; &lt;HideWirelessSetupInOOBE&gt;true&lt;/HideWirelessSetupInOOBE&gt; &lt;NetworkLocation&gt;Work&lt;/NetworkLocation&gt; &lt;SkipUserOOBE&gt;true&lt;/SkipUserOOBE&gt; &lt;SkipMachineOOBE&gt;true&lt;/SkipMachineOOBE&gt; &lt;ProtectYourPC&gt;1&lt;/ProtectYourPC&gt; &lt;/OOBE&gt; &lt;UserAccounts&gt; &lt;LocalAccounts&gt; &lt;LocalAccount wcm:action="add"&gt; &lt;Password&gt; &lt;Value&gt;&lt;/Value&gt; &lt;PlainText&gt;true&lt;/PlainText&gt; &lt;/Password&gt; &lt;Description&gt;AnJia&lt;/Description&gt; &lt;DisplayName&gt;AnJia&lt;/DisplayName&gt; &lt;Group&gt;Administrators&lt;/Group&gt; &lt;Name&gt;AnJia&lt;/Name&gt; &lt;/LocalAccount&gt; &lt;/LocalAccounts&gt; &lt;/UserAccounts&gt; &lt;RegisteredOrganization&gt;AnJia&lt;/RegisteredOrganization&gt; &lt;RegisteredOwner&gt;AnJia&lt;/RegisteredOwner&gt; &lt;DisableAutoDaylightTimeSet&gt;false&lt;/DisableAutoDaylightTimeSet&gt; &lt;FirstLogonCommands&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Description&gt;Control Panel View&lt;/Description&gt; &lt;Order&gt;1&lt;/Order&gt; &lt;CommandLine&gt;reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v StartupPage /t REG_DWORD /d 1 /f&lt;/CommandLine&gt; &lt;RequiresUserInput&gt;true&lt;/RequiresUserInput&gt; &lt;/SynchronousCommand&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Order&gt;2&lt;/Order&gt; &lt;Description&gt;Control Panel Icon Size&lt;/Description&gt; &lt;RequiresUserInput&gt;false&lt;/RequiresUserInput&gt; &lt;CommandLine&gt;reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" /v AllItemsIconView /t REG_DWORD /d 0 /f&lt;/CommandLine&gt; &lt;/SynchronousCommand&gt; &lt;SynchronousCommand wcm:action="add"&gt; &lt;Order&gt;3&lt;/Order&gt; &lt;RequiresUserInput&gt;false&lt;/RequiresUserInput&gt; &lt;CommandLine&gt;cmd /C wmic useraccount where name="AnJia" set PasswordExpires=false&lt;/CommandLine&gt; &lt;Description&gt;Password Never Expires&lt;/Description&gt; &lt;/SynchronousCommand&gt; &lt;/FirstLogonCommands&gt; &lt;TimeZone&gt;China Standard Time&lt;/TimeZone&gt; &lt;/component&gt; &lt;/settings&gt;&lt;/unattend&gt;复制代码<div></div> </plaintext><div></div> </password><div></div> </autologon><div></div> </component><div></div> </settings><div></div> </unattend></pre> <div></div> <p></p> <div></div> <h3 class="heading">配置samba</h3> <div></div> <p>在Cobbler上执行 </p> <div></div> <h4 class="heading">安装samba</h4> <div></div> <pre>[root@localhost ~]# yum install samba -y复制代码</pre> <div></div> <p></p> <div></div> <h4 class="heading">修改smb config</h4> <div></div> <pre>[root@localhost ~]# vi /etc/samba/smb.conf # /etc/samba/smb.conf[global]log file = /var/log/samba/log.%mmax log size = 5000security = userguest account = nobodymap to guest = Bad Userload printers = yescups options = raw [share]comment = share directory目录path = /smb/directory mask = 0755create mask = 0755guest ok=yeswritable=yes复制代码</pre> <div></div> <p></p> <div></div> <h4 class="heading">启动smb服务</h4> <div></div> <pre>[root@localhost ~]# service smb start[root@localhost ~]# systemctl enable smb复制代码</pre> <div></div> <p></p> <div></div> <h4 class="heading">挂载win10系统</h4> <div></div> <p>通过winscp等软件将&nbsp;cn_windows_10_business_edition_version_1809_updated_sept_2018_x64_dvd_84ac403f.iso 上传到cobbler服务器上,并将创建的应答文件,上传到cobbler <code>/smb/win/win10_x64_bios_auto.xml</code></p> <div></div> <pre>[root@localhost ~]# mkdir -p /smb/win[root@localhost ~]# mount -o loop,ro /tmp/cn_windows_10_business_edition_version_1809_updated_sept_2018_x64_dvd_84ac403f.iso /mnt/[root@localhost ~]# cp -r /mnt/* /smb/win[root@localhost ~]# umount /mnt/复制代码</pre> <div></div> <p></p> <div></div> <h3 class="heading">自动化安装Windows10</h3> <div></div> <p>从vmware创建一台内存4G,cpu2核,磁盘60G的空盘,win10虚拟机,然后开机。记得选BIOS,别选UEFI。<div></div></p> <div></div> <figure> <div></div> <figcaption></figcaption> <div></div> </figure> <div></div> <p></p> <div></div> <p></p> <div></div> <figure> <div></div> <figcaption></figcaption> <div></div> </figure> <div></div> <div></div> <div></div> <figure> <div></div> <figcaption></figcaption> <div></div> </figure> <div></div> <p></p> <div></div> <p>至于如何激活,参考&nbsp;&nbsp;</p> <div></div> <p></p> <div></div> <h2 class="heading">Windows Server 2019</h2> <div></div> <p>因为2019用的也是1809版本的,所以制作步骤一样的,在此不再赘述。 </p> <div></div> <h2 class="heading">参考资料</h2> <div></div> <ul> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> <li></li> <div></div> </ul> <div></div> <p></p> <div></div> <h2 class="heading">招聘小广告</h2> <div></div> <p>山东济南的小伙伴欢迎投简历啊 , 一起搞事情。</p> <div></div> <p>长期招聘,Java程序员,大数据工程师,运维工程师,前端工程师。</p> <div></div> </div><div></div> </body><div></div></html><p style="padding-top: 24px;font-size: 16px;">转载地址:http://gjqcx.baihongyu.com/</p></div> </div> <div class="more-title"> 你可能感兴趣的文章 </div> <a class="new-title" href="http://ztijx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">如何学好C#</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://utijx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">梅沙教育APP简单分析-版本:iOS v1.2.21-Nathaneko-佳钦</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://obsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">Word中如何设置图片与段落的间距为半行</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://qbsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">Firefox about</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://hbsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">Angular - - angular.element</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://gbsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">美图秀秀首页界面按钮设计(二)</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://ujsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">nginx安装及负载均衡配置</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://fjsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">JQuery this和$(this)的区别及获取$(this)子元素对象的方法</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://bjsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">tomcat不能多次startup.sh,异常时直接,分析logs目录下的日志。</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://uxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">关于分区索引与全局索引性能比较的示例</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://yxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">ASP.NET MVC学习之(5):Html.ActionLink</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://bxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">yii_wiki_145_yii-cjuidialog-for-create-new-model (通过CJuiDialog来创建新的Model)</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://cxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">431.chapter2.configure database mail</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://ixsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">同一页面中引入多个JS库产生的冲突解决方案(转)</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://sxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">C语言之指针与数组总结</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://lxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">沟通:用故事产生共鸣</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://mxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">1080*1920 下看网站很爽</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://qxsjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">topcoder srm 305 div1</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://wasjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">[转]ORACLE 异常错误处理</div> <div class="find">查看>></div> </div> </a><a class="new-title" href="http://zasjx.baihongyu.com/"> <div class="item-more" data-scroll-reveal> <div class="find-title">c/c++处理参数</div> <div class="find">查看>></div> </div> </a> </div> </div> <div class="footer"> <div> <div class="footer-main"> <div class="blog-name">喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!-- 愿君每日到此一游!</div> <div class="copyright"> 当前时间: <span>2024-12-24 20:50:30</span>&nbsp;&nbsp; 当前IP: <span>18.118.33.130</span>&nbsp;&nbsp; 联系邮箱:javaeecc@qq.com &nbsp;&nbsp;&nbsp;&nbsp;Copyright © 2020 - 2022 baihongyu.com <a style="color: #FFFFFF;" href="https://beian.miit.gov.cn" target="_blank">京ICP备2021015314号-2</a> </div> </div> <a href="http://gpt.css8.cn" target="_blank"> <div class="gpt-main-left"> 强烈建议你试试无所不能的CHAT-GPT,快点击我 </div> </a> <a href="http://gpt.css8.cn" target="_blank"> <div class="gpt-main-right"> 强烈建议你试试无所不能的CHAT-GPT,快点击我 </div> </a> </div> </div> <div> <script src="/baihongyu/js/jquery-1.8.2.js"></script> <script src="/baihongyu/js/scrollReveal.js"></script> <script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script> <script>LA.init({id: "JeQUgUJ4FtcgrGgk",ck: "JeQUgUJ4FtcgrGgk"})</script> <script> window.scrollReveal = new scrollReveal({ enter: 'left', move: '80px', over: '0.1s', reset: true, init: false }); scrollReveal.init(); </script> </div> </body> </html>