Back to Home

How to do without a WDS server when installing Windows from WIM images over a network

MDT · PXE · iPXE · wimboot · pxelinux · syslinux · tftp

How to do without a WDS server when installing Windows from WIM images over a network

    Introduction


    Images in the WIM format prepared in the MDT system , Microsoft offers to deploy over the network using a WDS server , or integrate into SCCM .
    SCCM is quite expensive, but a WDS server is free if you are a happy owner of a license for Windows Server 2008/2012. But not everyone is happy with the capabilities of the WDS server.
    My proposed method will be useful for those:
    • who does not have a license for Windows Server, or all the resources on existing servers are already involved and there is no way to purchase another license;
    • Who doesn’t like the speed of loading Windows PE over the TFTP protocol used by the WDS server?
    • Who needs to combine the deployment of Windows and Linux over a network on a single server.

    I want to offer readers a solution based on the Ubuntu Linux OS using syslinux and iPXE.

    In the future, the use of the Ubuntu 14.04 LTS OS will be implied.
    The services listed below do not have to run on the same server.

    Install and configure tftp server


    To organize data transfer via TFTP protocol, the tftpd-hpa server will be used . It has the necessary capabilities, and also supports remapping.
    Install the appropriate package:
    aptitude install tftpd-hpa

    Settings are in the configuration file
    / etc / default / tftpd-hpa
    RUN_DAEMON="yes"
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/var/lib/tftpboot"
    TFTP_ADDRESS="0.0.0.0:69"
    TFTP_OPTIONS="--secure --listen --verbose --verbosity 10 --map-file /etc/tftpd.remap --refuse blksize"

    We also need a file with rules for remapping
    /etc/tftpd.remap
    rg \\ /
    ri (.*)ÿ$ \1
    ri (.*)M-\^\?$ \1
    ri (pxelinux\.0).*$ \1
    The first line redefines the slashes for Windows, the next ones warn of possible problems with loading on some network adapters when the client tries to request the file “pxelinux.0M- ^” or “pxelinux.0ÿ” instead of “pxelinux.0” from the tftp server.


    Configure http server


    Why do we need an http server, because a tftp server is enough to download WIM images over the network?
    It so happened that Trivial FTP, although it provides basic functions for transferring files over the network, cannot provide high reliability and data transfer speed.
    As practice shows, images with Windows PE about 250 MB in size are downloaded over a 1 Gbit network using the http protocol several times faster (5-10 seconds, versus 30-60 seconds, respectively).
    Also, using the http protocol, you can download preseed files for the debian-installer installer.
    You can use apache, nginx or any other server that you like as an http server. No special settings are required. The main thing is that the following * .ipxe, * .wim files and other files hosted on the http server are readable.

    Configure dhcp server


    According to RFC1232, you need to configure option 66 TFTP server name, where to specify the IP address of your tftp server, for example 192.168.1.1; and option 67 Bootfile name, where to specify the name of the file to load "pxelinux.0";

    If you use, for example, isc-dhcp-server running Ubuntu, then you will need to add approximately such settings to the file
    /etc/dhcp/dhcpd.conf
    
    shared-network PXE-Netwotk {
      subnet 192.168.1.0  netmask 255.255.255.0 {
        # Общие настройки для подсети
        range 192.168.1.2 192.168.1.254;
        option routers 192.168.1.1;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.1.1;
        # Настройки опций для сетевой загрузки в подсети
        filename "pxelinux.0";
        next-server 192.168.1.1;
        option root-path "192.168.1.1:/var/lib/tftpboot/"; # необязательный параметр
      }
    }


    Install and configure syslinux bootloader


    Bootloader installation


    We will need syslinux version 5.03 or higher.
    I would recommend building a bootloader from source, there’s nothing wrong with that
    To build from the source you need to install make, gcc, nasm, uuid-dev, and execute the commands:
    # Скачаем архив с исходными кодами
    wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.zip
    # распакуем его
    unzip syslinux-6.03.zip -d syslinux-6.03
    # Собственно сама сборка с помощью make
    cd syslinux-6.03
    make
    # Скопируем полученные файлы в каталог tftp-сервера:
    cd ..
    cp syslinux-6.03/bios/memdisk/memdisk /var/lib/tftpboot/
    find ./syslinux-6.03/bios/ -name "pxelinux.0"|xargs -I {} cp '{}' /var/lib/tftpboot/
    find ./syslinux-6.03/bios/ -name "*.c32"|xargs -I {} cp '{}' /var/lib/tftpboot/
    

    Setting the bootloader menu


    Create a directory for the syslinux menu files:
    mkdir -p /var/lib/tftpboot/pxelinux.cfg/
    And create a default menu file
    /var/lib/tftpboot/pxelinux.cfg/default
    ui vesamenu.c32
    PROMPT 0
    menu background background.jpg
    menu title PXE boot menu
    # По умолчанию загружаемся с первого жесткого диска
    LABEL bootlocal
       menu label Boot from first HDD
       kernel chain.c32
       append hd0 0
       # Таймаут для автоматической загрузки 12 секунд
       timeout 120
     TEXT HELP
    The system will boot after the time is up
     ENDTEXT
    # Подменю для центрального офиса
    LABEL Central Office    ->
          KERNEL vesamenu.c32
          APPEND pxelinux.cfg/CentralOffice
    # Подменю для региональных офисов
    LABEL Regional Offices ->  
          # menu PASSWD $1$15opgKTx$dP/IaLNiCbfECiC2KPkDC0 # раскомментировать если требуется вход в подменю по паролю, пароль Qwerty, алгоритм MD5
          KERNEL vesamenu.c32
          APPEND pxelinux.cfg/RegionalOffices
    Now create a submenu directly to boot the OS:
    /var/lib/tftpboot/pxelinux.cfg/CentralOffice
    PROMPT 0
    UI vesamenu.c32
    MENU BACKGROUND background.jpg
    MENU TITLE Central Office
    # Возврат в главное меню
    LABEL <- Main Menu
          KERNEL vesamenu.c32
          APPEND pxelinux.cfg/default
    # Загрузка через http
    LABEL PE via http
            KERNEL ipxe.lkrn
            APPEND dhcp && chain http://192.168.2.1/winpe.ipxe
    # Для сравнения загрузка через tftp
    LABEL PE via tftp
            KERNEL ipxe.lkrn
            APPEND dhcp && chain tftp://192.168.2.1/winpe.ipxe
    # Можно также загрузить debian-installer
    LABEL Ubuntu
            KERNEL ubuntu-installer/i386/linux
            APPEND initrd=ubuntu-installer/i386/initrd.gz preseed/url=http://192.168.1.1/preseed/custom.seed debconf/priority=high auto-install/enable=true debian-installer/language=ru debian-installer/locale=ru_RU.UTF-8 debian-installer/country=RU ipv6.disable=1 netcfg/hostname=testname DEBCONF_DEBUG=5 --
    , where winpe.ipxe is the configuration file with settings for ipxe, which we will discuss below in the corresponding section.
    Do not forget that the tftp server does not know how to work with symbolic links, so you will need to make a separate copy of the winpe.ipxe file in the tftp server directory if you want to compare the download speed over http and tftp.
    Some network cards do not have time to raise the link the first time, so you can make a second download attempt in case of failure, using the "||" operator. If, after the second attempt, we again fail, then we can display the interface statistics and open the command line to diagnose the problem:
    APPEND dhcp && chain http://192.168.2.1/winpe.ipxe || dhcp && chain http://192.168.2.1/winpe.ipxe || ifstat && shell


    iPXE


    Install iPXE


    I also suggest building iPXE from source, and it’s also very simple:
    git clone git://git.ipxe.org/ipxe.git
    cd ipxe/src
    make
    cp bin/ipxe.lkrn /var/lib/tftpboot

    If any network card refuses to raise the link from any attempt, then most likely the problem is in the iPXE driver.
    Especially this problem concerns new network interface cards from Intel. I had problems with the i218lm and i218v-2 cards, at a forced 1Gbit speed on the switch.
    Before building, you need to fix ipxe / src / drivers / net / intel.c: set the flag INTEL_NO_PHY_RST for i218lm and i218v-2:
    PCI_ROM ( 0x8086, 0x155a, "i218lm", "I218-LM", INTEL_NO_PHY_RST),
    PCI_ROM ( 0x8086, 0x15a1, "i218v-2", "I218-V", INTEL_NO_PHY_RST ),


    Wimboot installation


    To download WIM images via iPXE, you need the wimboot utility .
    Installing this utility is also very simple:
    wget http://git.ipxe.org/releases/wimboot/wimboot-latest.zip 
    unzip wimboot-latest.zip
    cp wimboot-2.5.1-signed/wimboot /var/lib/tftpboot/


    Creating .ipxe configuration files


    The .ipxe configuration files (the extension can be anything, but it’s more convenient) contain instructions for the ipxe kernel: what to download next.
    We will download the wimboot utility, and pass it the path parameters to the BCD boot configuration data file, boot.sdi RAM disk configuration file, and the boot.wim image. The directory structure is not required to be maintained, wimboot itself takes care of this. All files can be put in one directory.
    winpe.ipxe
    #!ipxe
    kernel http://192.168.1.1/boot/wimboot
    initrd http://192.168.1.1/boot/DeploymentShare/Boot/x86/Boot/bcd BCD
    initrd http://192.168.1.1/boot/DeploymentShare/Boot/x86/Boot/boot.sdi  boot.sdi
    initrd http://192.168.1.1/boot/DeploymentShare/Boot/LiteTouchPE_x86.wim boot.wim
    boot

    In this example, a symbolic link was made on the http server for 192.168.1.1/boot/DeploymentShare directly to the root of the MDT DeploymentShare. This method is not suitable as the main working option. Because if you suddenly collect a “wim” wim-image, then immediately ruin the download over the network for those who work with it. But this method is well suited for testing new wim images.
    Those who wish can replace the http protocol with tftp in the .ipxe file - it will also work, but slowly.

    All. Now you can boot and install the OS.

    Read Next