PXE无人值守安装WIN10

应用场景:数据中心新增机器时,不需要每次将系统镜像拷贝到U盘、管理机等媒体介质中安装,配合IPMI远程管理,可完成远程快速重装操作系统等操作。

PXE无人值守工作流程图.png

  1. 部署DHCP服务器
vim /etc/dhcp/dhcpd.conf
option space pxelinux;
option pxelinux.magic code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;
option architecture-type code 93 = unsigned integer 16;
subnet 192.168.2.0 netmask 255.255.255.0 {
        range 192.168.2.22 192.168.2.100;
        option subnet-mask 255.255.255.0;
        option routers    192.168.2.1;
        default-lease-time 21600;
        max-lease-time 43200;
        class "pxeclients" {
                match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
                next-server 192.168.2.21;

                if option architecture-type = 00:07 or option architecture-type = 00:09 {
                        filename "shim.efi";
                } else {
                        filename "pxelinux.0";
                }
        }
}
  1. 部署tftp
vim /etc/xinetd.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
  1. 安装引导文件
yum -y install syslinux-tftpboot
  1. 创建windowsPE
    安装官方ADK工具:https://docs.microsoft.com/zh-cn/windows-hardware/get-started/adk-install#winADK
    安装对应版本ADKy以及WINPE加载项
#提取WinPE镜像
copype amd64 C:\WinPE_amd64

#加载WinPE镜像,在C盘下生成WinPE的文件夹
Dism /Mount-Image /ImageFile:"C:\WinPE_amd64\media\sources\boot.wim" /index:1 /MountDir:"C:\WinPE_amd64\mount"

#后台制作映像文件,完成后在C:\WinPE_amd64文件夹下生成了名为"WinPE_amd64.iso"
MakeWinPEMedia /ISO C:\WinPE_amd64 C:\WinPE_amd64\WinPE_amd64.iso

#将刚才制作好的WinPE_amd64.iso做成启动U盘
MakeWinPEMedia /UFD C:\WinPE_amd64 X:(X代表U盘盘符)

上传制作好的PE镜像到服务器的TFTP目录下

  1. 创建菜单
mkdir /var/lib/tftpboot/pxelinux.cfg
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
display boot.msg
prompt 0
timeout 300
totaltimeout 600
ONTIMEOUT windows
menu title ########## PXE Boot Menu #########
label windows
  menu label ^Install Windows 10
  kernel memdisk
  initrd WinPE/win10pe.iso
  append iso raw
$pxe_menu_items
MENU end
  1. 部署samba
yum -y instlal samba*
vim /etc/samba/smb.conf
[global]
        workgroup = PXESERVER
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        idmap config * : backend = tdb
        cups options = raw
        netbios name = pxe
        map to guest = bad user
        dns proxy = no
        public = yes
        ## For multiple installations the same time - not lock kernel
        kernel oplocks = no
        nt acl support = no
        security = user
        guest account = nobody
[install]
        comment = Windows 10 Image
        path = /var/www/html/Windows
        read only = no
        writeable = yes
        browseable = yes
        public = yes
        printable = no
        guest ok = yes
        oplocks = no
        level2 oplocks = no
        locking = no
  1. 下载官方原版win10
    将iso文件解压到samba共享目录

  2. 创建autounattend.xml
    在samba共享目录创建windows应答文件

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <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">
            <SetupUILanguage>
                <UILanguage>en-US</UILanguage>
            </SetupUILanguage>
            <InputLocale>zh-CN</InputLocale>
            <SystemLocale>zh-CN</SystemLocale>
            <UILanguage>zh-CN</UILanguage>
            <UserLocale>zh-CN</UserLocale>
        </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>
                <Disk wcm:action="add">
                    <DiskID>0</DiskID>
                    <WillWipeDisk>true</WillWipeDisk>
                    <CreatePartitions>
                        <CreatePartition wcm:action="add">
                            <Order>1</Order>
                            <Type>Primary</Type>
                            <Size>300</Size>
                        </CreatePartition>
                    </CreatePartitions>
                    <ModifyPartitions>
                        <ModifyPartition wcm:action="add">
                            <Active>true</Active>
                            <Extend>true</Extend>
                            <Format>NTFS</Format>
                            <Letter>C</Letter>
                            <Label />
                            <PartitionID>1</PartitionID>
                            <Order>1</Order>
                        </ModifyPartition>
                    </ModifyPartitions>
                </Disk>
            </DiskConfiguration>
            <ImageInstall>
                <OSImage>
                    <InstallTo>
                        <DiskID>0</DiskID>
                        <PartitionID>1</PartitionID>
                    </InstallTo>
                    <WillShowUI>OnError</WillShowUI>
                </OSImage>
            </ImageInstall>
            <UserData>
                <ProductKey>
                    <Key>VK7JG-NPHTM-C97JM-9MPGT-3V66T</Key>
                    <WillShowUI>OnError</WillShowUI>
                </ProductKey>
                <AcceptEula>true</AcceptEula>
                <FullName>Windows10</FullName>
                <Organization>WORKGROUP</Organization>
            </UserData>
        </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>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <SkipUserOOBE>false</SkipUserOOBE>
            </OOBE>
            <AutoLogon>
                <Username>Administrator</Username>
                <Enabled>true</Enabled>
                <LogonCount>1</LogonCount>
            </AutoLogon>
            <LogonCommands>
                <AsynchronousCommand wcm:action="add">
                    <CommandLine>netsh interface ipv4 set dnsservers name="Ethernet0" static 114.114.114.114 primary</CommandLine>
                    <Description>DNSset</Description>
                    <Order>1</Order>
                </AsynchronousCommand>
            </LogonCommands>
        </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>
            <TimeZone>China Standard Time</TimeZone>
        </component>
        <component name="Microsoft-Windows-Security-SPP-UX" 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">
            <SkipAutoActivation>true</SkipAutoActivation>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="wim://laptop-lloov0t1/users/%E6%9D%8E%E6%B5%A9%E8%BD%A9/downloads/cn_windows_10_business_editions_version_2004_updated_sep_2020_x64_dvd_7134ba4b/sources/install.wim#Windows 10 Pro" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
# PXE 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×