A boot server is like a bootable USB flash drive, only a server and over the network. AOMEI PXE Boot: Booting computers over the network from a disk image file Add the ability to load various disk utilities and memory test

Well, it's time to continue downloading something else interesting and, most importantly, useful over the network. In we reviewed the launch Acronis programs, installing Debian/Ubuntu Linux, downloading small ISOs and running ready-made WIM images.

So, plans for today!

  1. Installing Windows in manual and automatic modes.
    1. Building a WIM image.
    2. Preparing the response file.
  2. Launching ERD Commander (MSDaRT).
  3. As a bonus, we will implement the launch of the Debian installation with further installation via SSH.

Let's start with Windows

WARNING

All further actions related to preparing Windows are performed in the Windows environment.

The first step is to prepare the WinPE environment with which we will launch the installations various systems Windows family. To do this, we need the Windows AIK package, which can be downloaded for free from the official Microsoft website.


After installation Windows package AIK open the “Deployment Tools Command Line” console. Let's copy the WIM image and bootloader and mount it into the system:

Copype.cmd amd64 c:\winpe mkdir c:\pe\win\boot imagex /mountrw winpe.wim 1 mount xcopy c:\winpe\mount\windows\boot\pxe\pxeboot.n12 c:\npe\win xcopy c :\winpe\mount\windows\boot\pxe\bootmgr.exe c:\pe\win xcopy c:\winpe\iso\boot\boot.sdi c:\pe\win\boot

The WinPE menu script is launched by the startnet.cmd file. To display the Cyrillic alphabet correctly, you need to change the encoding of this file to CP866. The next step is to edit the script file if necessary.

Adding parameters to the PXE server menu

The menu is ready. As you can see from the parameters in the script, at each stage a certain network folder is connected. On a PXE server, the installation and launch of which was described in the previous article, you need to publish a folder via Samba that will be read-only (otherwise the installer may try to stuff something there or overwrite it).

Next, you need to prepare response files for auto-installations. Looking ahead, I will say that thanks to these very files you can achieve absolutely any result, for example, implement an auto-installation with a 40/60% split of the first disk with a connection to a domain, and then everything you need software can already be delivered group policies domain (but that's a completely different story).

Imagex.exe /unmount /commit mount

The resulting WinPE image - winpe.wim - is copied to the PXE server. Next, in the PXE boot menu created in /var/lib/tftpboot/pxelinux.cfg/default, we connect the child file, which will contain the windows partition.

Label Install Windows menu passwd qwerty menu label Install/Boot Windows kernel boot/vesamenu.c32 append pxelinux.cfg/windows

Menu label WinPE Install Windows All menu passwd my_password com32 linux.c32 boot/wimboot APPEND initrdfile=/images/windows/bootmgr.exe,/images/windows/boot/BCD,/images/windows/boot/boot.sdi,/images /windows/boot/winpe.wim

Preparing a response file

Let's start with Windows 7 Pro. To prepare the answer file, you will need the install.wim file, which can be obtained from installation disk Windows 7 in the source folder. We grab it and copy it to a convenient accessible place. Next we launch Windows System Image Manager.

Continuation is available only to members

Option 1. Join the “site” community to read all materials on the site

Membership in the community within the specified period will give you access to ALL Hacker materials, increase your personal cumulative discount and allow you to accumulate a professional Xakep Score rating!

PXE

 Preload execution environment ( Preboot Execution Environment, PXE, pronounced “pixie”) is the process of booting an operating system over a network. It can be compared to booting a LiveCD from a remote CD drive.

This download method requires:

    a file storage server running using the DHCP and TFTP protocols (you can run each protocol on a separate server);

    client with PXE boot loader in BIOS. May not have hard drive.

Step 1. Configure the PXE server

PXE server includes:

    DHCP server for connecting to clients;

    DHCP download file for configuring clients;

    TFTP server for loading the operating system.

SliTaz LiveCD can be used as a PXE server. To do this, launch the Netbox application (from the System menu).

    On the tab Statip IP click Start.

    • A DHCP server window will appear that cannot use DHCP to obtain IP information.

    On the tab Server select tab INETD and make sure the line tftpd in the /etc/initd.conf file not commented out. These are the default settings. Click Start.

    • The TFTP server will start and will download the SliTaz LiveCD over the network.

    On the same tab Server select tab PXE.

    Edit the settings according to your boot options.

    • This will automatically update the DHCP server configuration.

    On the tab Server select tab DHCP. Adjust the settings to match your network configuration. Before this we added the lines boot_file And siaddr. Click Start.

    • The DHCP server will start. If clients cannot obtain an IP address, check the settings of this server.

    Make sure the files bzImage And rootfs.gz are in the directory /boot on LiveCD.

Step 2. Configure the PXE client

Computers last generations with built-in Ethernet support have a BIOS that supports PXE. Check this option in the BIOS menu and make sure it is enabled. To go to the BIOS settings, you will need to press the corresponding key after turning on the computer (for example, F12).

If your computer does not support PXE booting, you can use SliTaz as a client on it. Create a bootable CD-ROM or floppy disk with the utility Boot Floppy/CDROM in the menu System.

On the PXE Network tab, select Write floppy. This will allow you to boot the system on the client's computer.

SliTaz LiveCD contains settings for loading the operating system via the Internet. This may be useful when using more new version SliTaz from old media.

To start network booting, at the initial SliTaz prompt, enter the command

That's all!

For further information on using an internet connection when downloading SliTaz, see the SliTaz online download home page.

You will also need a DHCP server to obtain the IP address, subnet mask and gateway address, just like when setting up a regular connection - a regular home router will do for this.

If you don't have a device that can be configured as a DHCP server, you'll still need an IP address, subnet mask, gateway address, and possibly DNS address.

Title Slitaz Web kernel /boot/gpxe ip=192.168.0.12/24 gw=192.168.0.1 dns=192.168.0.1 url=http://mirror.slitaz.org/pxe/pxelinux.0

Title Slitaz Web kernel /boot/gpxe ip=192.168.0.12/24 gw=192.168.0.1 dns=192.168.0.1 url=ip=192.168.0.12/24 gw=192.168.0.1 dns=192.168.0.1 url=http:// mirror.slitaz.org/pxe/pxelinux.0

With this download method, only the following options are available:

    nodhcp (will help avoid DHCP timeout error)

Additional customization of the download process

The network download process can be configured and distributed across routers and other devices.

Distributed boot via PXE and PROM (precedes PXE)

    install gpxe.exe to /jffs/boot

# echo "dhcp-boot=gpxe.pxe" >> /tmp/dnsmasq.conf

Start a tftp server for your local network (eg 192.168.0.1/24):

# /jffs/usr/sbin/tftpd 192.168.0.1 /jffs/boot

Changing the GPXE boot home page

$ dd bs=1 skip=519 count=255 if=gpxe 2> /dev/null | strings $ echo -n "http://myurl.org/myboot" | cat - /dev/zero | dd conv=notrunc bs=1 seek=519 count=255 of=gpxe $ echo -n "ip=192.168.0.10/24 gw=192.168.0.1 dns=192.168.0.1 url=http://myurl.org/myboot" | cat - /dev/zero | dd conv=notrunc bs=1 seek=519 count=255 of=gpxe $ dd if=/dev/zero conv=notrunc bs=1 seek=519 count=255 of=gpxe

Changing the home page for gpxe.exe

$ dd bs=1 skip=5 count=255 if=gpxe.pxe 2> /dev/null | strings

$ echo -n "http://myurl.org/myboot" | cat - /dev/zero | dd conv=notrunc bs=1 seek=5 count=255 of=gpxe.pxe

$ dd if=/dev/zero conv=notrunc bs=1 seek=5 count=255 of=gpxe.pxe

Using multiple links when working with download servers

Here's an example for current SliTaz boot servers:

$ echo -n "http://mirror.slitaz.org/pxe/pxelinux.0,http://mirror.switch.ch/ftp/mirror/pxe/pxelinux.0,http: download.tuxfamily.org/slitaz /pxe/pxelinux.0" | cat - /dev/zero | dd conv=notrunc bs=1 seek=519 count=255 of=gpxe

PXE Technology Overview

PXE (Pre Execution Environment), pronounced Pixie, is an approach that allows a computer (client computer) to boot using only its network card. This boot method was created back in 1999 and if the computer is connected to a network (and supports this standard), then it is possible to bypass the normal boot procedure (i.e. power on -> BIOS -> HD/CD) and do some neat things, starting with troubleshooting, for which live OS is usually used, and even capturing an image of the machine... but we're getting ahead of ourselves - let's go back to the beginning.

When the PXE approach is used, the boot process changes from normal to the following:

Power on -> BIOS -> PXE stack network card-> program network boot Network Boot Program (NBP), loaded using TFTP from the server into the memory of the client machine -> responsibility for performing the next step rests with the NBP program (2nd stage of loading).

By using the PXElinux NBP program, we can configure the server to do more than just load a single PXE program for our clients. In a way, this is the secret ingredient that will allow us to do all of the above and more. For a more detailed explanation of the entire process, its history, and some of the available customization options for this program and the gPXE program (which is a more advanced clone of the first program), see this lecture on YouTube, proposed by the developers of these programs. Additionally, there is a video below from 2008 that walks you through the setup so you can quickly jump into some of the download options.

Note: This video uses the legacy UDA project as the basis for the server, and the annotations were intended to explain that it was updated with the latest (at the time) additions.

Target

This tutorial will be the first in a series of tutorials covering PXE. In this guide, we will lay the foundations that we will build on in subsequent articles.

  • The client machine you are testing on supports PXE boot and you know how to enable it.
  • This guide was written and tested using Debian Squeeze, Ubuntu Server 9.10 and Linux Mint10. Therefore it is assumed that you also have a Debian based system.
  • You have the opportunity to look at the article “How to configure software RAID” for a “Simple file server” and “How to configure an entire network (802.3ad)”, since the disk speed and throughput for this option the servers must be very high. It is strongly recommended to assemble such a network using a server with highly fault-tolerant network and disk subsystems.
  • You'll see that we use VIM as the editor, that's just because I'm used to it... You can use any other editor you like.

Installation - a difficult start using the FOG system

Using FOG as the basis for your PXE server is a good way to have all the necessary pieces in place, such as TFTP and, if required, DHCP, without having to install and configure them manually, while giving you all the features of the FOG package as a bonus.

Since our goal is to add new features to this already large system, we will not go into detail about how to use the FOG package itself, nor will we cover the installation procedure. The FOG package wiki, with both text and video how-tos, is sufficient to obtain detailed information in case you want to understand in detail. In general, the steps are as follows:

This is all you need to do during the installation of the FOG package. Again, because FOG is a large system, its use is beyond the scope of this guide, and to help you better understand the capabilities of the FOG system and how it can help you manage the lifecycle of your client computers, we encourage you to refer to the wiki pages describing this system.

If all goes well, you should be able to boot your client machine into PXE mode (usually using F12) and get the FOG default prompt menu.


Image via Hotfortech.

To get a taste of the possibilities right away, you can select the "Run Memtest86+" option and be prompted by the Memtest program, which we cover in our article Diagnosing PC Hardware Problems Using Ubuntu Live CD.

Files and directories

As noted earlier, our goal is to expand the capabilities of the FOG system and for this purpose we must add some files and directories.

Create the following subdirectories:

Sudo mkdir -p /tftpboot/howtogeek/menus sudo mkdir -p /tftpboot/howtogeek/linux sudo mkdir -p /tftpboot/howtogeek/pics sudo mkdir -p /tftpboot/howtogeek/utils

These subdirectories will serve as templates for all the images, programs and configurations that we will use to expand the FOG system.

Set the default configuration file to be used by default

We will create a new main menu and place all the functions of the FOG system in its own submenu.

Copy the configuration file /tftpboot/pxelinux.cfg/default to howtogeek/menus/fog.cfg.

Sudo cp /tftpboot/pxelinux.cfg/default /tftpboot/howtogeek/menus/fog.cfg

Now edit the content source file default, used by default:

Sudo vim /tftpboot/pxelinux.cfg/default

Make its contents look like this:

DEFAULT vesamenu.c32 MENU TITLE FOG 0.32 + HowToGeek"s enhancements MENU INCLUDE /pxelinux.cfg/master.cfg menu color title 1;36;44 #ff8c00 #00000000 std LABEL FOG MENU LABEL Manual FOG MENU DEFAULT KERNEL vesamenu.c32 APPEND howtogeek /menus/fog.cfg LABEL Utils MENULABEL Utilities KERNEL vesamenu.c32 APPEND howtogeek/menus/utils.cfg LABEL Linux MENU LABEL Linux stuff KERNEL vesamenu.c32 APPEND howtogeek/menus/linux.cfg LABEL fog.local localboot 0 MENU LABEL Boot from hard disk TEXT HELP Boot from the local hard drive. If you are unsure, select this option. ENDTEXT PROMPT 0 TIMEOUT 300 ONTIMEOUT fog.local

When we are done, this configuration will give you the following 3 submenus: Utilities, Manual FOGing, Linux stuff (Linux).

Create a master file

The master file will allow you to make global changes to the appearance of the menu without re-entering them in a separate order over and over again. Features such as default wallpaper, border styles, positions, etc. will all be combined in this master.cfg file.

Create a file:

Sudo vim /tftpboot/pxelinux.cfg/master.cfg

Make sure its content is as follows:

MENU BACKGROUND fog/genie.png menu color screen 37;40 #80ffffff #00000000 std menu color border 30;44 #9370db #00000000 std menu color title 1;36;44 #ff8c00 #00000000 std menu color unsel 37;44 #ffffffff #00000000 std menu color hotkey 1;37;44 #ffffffff #00000000 std menu color sel 7;37;40 #4eee94 #9370db all menu color hotsel 1;7;37;40 #e0400000 #20ff8000 all menu color disabled 1;30 ;44 #60cccccc #00000000 std menu color scrollbar 30;44 #40000000 #00000000 std menu color tabmsg 31;40 #90ffff00 #00000000 std menu color cmdmark 1;36;40 #c000ffff #00000000 std menu color cmdline 37;40 #c 0ffffff #00000000 std menu color pwdborder 30;47 #80ffffff #20ffffff std menu color pwdheader 31;47 #80ff8080 #20ffffff std menu color pwdentry 30;47 #80ffffff #20ffffff std menu color timeout_msg 37;40 #80ffffff #00000000 std menu color timeout 1;37;40 #c0ffffff #00000000 std menu color help 37;40 #c0ffffff #00000000 std menu color msg07 37;40 #90ffffff #00000000 std MENU MARGIN 0 MENU PASSWORDMARGIN 3 MENU ROWS 15 MENU TABMSGROW 21 CMDL INEROW 20 MENU PASSWORDROW 11 MENU TIMEOUTROW 20 MENU HSHIFT 0 MENU VSHIFT 0

The configuration above will create purple borders and text highlighting; if you want to appearance was different, just change the values.

To set a background picture, place the picture in the catalog /tftproot and set MENU BACKGROUND to a relative path to the image (we recommend using images with a resolution of 640*480). For example, the full path to the picture configured above would be /tftproot/fog/bg.png.

Connect the FOG submenu to the main menu

Because we made a simple copy of the original config file into a subdirectory of the menu (preserving the color scheme, timeouts, etc.), if you now go to this submenu from a loaded PXE client, it will work, but you will not be able to return to the main menu without rebooting the machine .

So edit the file /tftpboot/howtogeek/menus/fog.cfg:

Sudo vim /tftpboot/howtogeek/menus/fog.cfg

Add the following entry after the "menu color title" entry and before the FOG functions:

LABEL back MENU LABEL .. KERNEL vesamenu.c32 APPEND pxelinux.cfg/default

Create templates for submenus

We have created 4 submenus, three of which will be filled by us. To do this, let's create a template that we will use in the future.

Create a template file:

Sudo vim /tftpboot/howtogeek/menus/template.cfg

Its contents should be as follows:

MENU INCLUDE /pxelinux.cfg/master.cfg #MENU BACKGROUND howtogeek/pics/fog-sub.jpgLABEL back MENU LABEL .. KERNEL vesamenu.c32 APPEND pxelinux.cfg/default

Let's set up templates for additional submenus that we will need in the following articles:

Cd /tftpboot/howtogeek/menus/ sudo cp template.cfg ./utils.cfg sudo cp template.cfg ./linux.cfg

That's it, the basic layout is now ready and now we will need to use it, which we will do in the following articles. Since these articles have not yet been published, we recommend that you familiarize yourself with the FOG system, because... This system itself is extremely interesting.

PXE has one very useful feature; everything that is configured in it is quite difficult to lose because all this is stored on the server, not on removable media, which tend to get lost, stolen, forgotten in DVD drives / at home, given to use and “in the end”, so the likelihood that they will take you to use and “play” tends to zero, well, perhaps together with the server... By connecting a device that has the ability to boot PXE, you can do quite a lot of useful things, namely: diagnose equipment, deploy operating systems, download Live system etc. what is enough knowledge and imagination?
To do this, we will need to configure a DHCP server and a TFTP server.
Previously, I already wrote about how to set up a server for, I highly recommend it for review, the main points were carried over from it.
What will we get as a result?!
And we will get a boot menu with the ability to select the application that we will download to the client machine, as well as the default actions that will be performed by the system if no commands are received from the users.

For work we will need:
1) Installed Ubuntu server
2) A configured DHCP server, an example of configuration can be found in the article:
3) Disk or ISO image of the Ubuntu installation distribution - the bit depth does not matter, but it is better to take a more recent version.

We will install everything else along the way... I will not dwell on the DHCP settings, assuming that you have it configured, according to the article, the link to which is provided in the system requirements.

Installing a tftp server
Let's install the necessary package:
We raise the rights to root:
sudo su

Let's install the necessary package
aptitude install tftpd-hpa

Now all files that relate to our tfpt server should be in the directory /var/lib/tftpboot/, all paths are specified relative to it.

Let's move on to creating the boot menu
First of all, we need to get a deputy loader, how to do this?! It can be found on any disk with ubuntu, in others Linux distributions, the location is almost always the same. We will need an installation ISO image or a disc inserted into the DVD drive, in which we go to the following directory:
If the installation disk is x86 architecture:
/install/netboot/ubuntu-installer/i386
We are interested in the file pxelinux.0 this is the bootloader, take it and copy it to the directory:
/var/lib/tftpboot/
Then the path to it looks like:
/var/lib/tftpboot/pxelinux.0
Also, we will need the boot menu itself, which can be taken on the same disk, in the directory boot-screens we are interested in a file named vesamenu.c32

Copy it to the same directory as the loader so that the path looks like:
/var/lib/tftpboot/vesamenu.c32

Configuring the contents of the PXE menu

As an example, we will make a boot menu consisting of 2 items.
Point one: Boot from local hard drive. This item will be the default item if the user boots the PC via PXE and within 15 seconds. did not perform any actions, the system will automatically boot from the local disk.
Point two: let's call him Testing Inside this menu There will be an item with the ability to download Memtest x86+. This program will always be useful in diagnosing problems with workstations and servers; in general, it is a necessary thing and will be useful to everyone on the farm...

First, we need to create a directory for configuration files called pxelinux.cfg - the name is critical for work!
mkdir /var/lib/tftpboot/pxelinux.cfg

Now let's create a configuration file with the parameters of menu items, named default
nano /var/lib/tftpboot/pxelinux.cfg/default

With the following content:
default vesamenu.c32 prompt 0 menu title PXE Boot Menu MENU AUTOBOOT Starting Local System in # seconds label Boot from local drive menu label ^Boot from local drive menu default localboot 0 timeout 150 TOTALTIMEOUT 9000 LABEL Testing MENU LABEL ^Testing KERNEL vesamenu.c32 APPEND pxelinux.cfg/testing.menu

The most observant ones noticed that in the previous file we had an entry that concerns another file testing.menu, in it we will have the settings for the item Testing
Let's create this file:

With the following content:
MENU TITLE Testing LABEL Test software MENU LABEL ^Return to Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default label Memory Test menu label ^Memory Test: Memtest86+ v4.20 kernel memtest/mt86plus

The first menu item will be responsible for returning to the previous menu, and the second for loading Memtest86+ v4.20

Everything is fine, but we did not create the directory where the Memtest file is stored, we will fix this now, let's create the appropriate directory.
Let's do this:
mkdir /var/lib/tftpboot/memtest
All we have to do is add the executable file of Memtest86+ itself, it can be found on the installation disk, in the directory /install/ we are interested in the file mt86plus we need to copy it to the memtest directory so that the path to it looks like:
/var/lib/tftpboot/memtest/mt86plus

At this point we are done with the tftp server, we just need to finish the DHCP server a little.

Setting up a DHCP server

This item can only be called a setup with a stretch; if you configured the DHCP server according to the article, then you need to add only one entry to:
nano /etc/dhcp/dhcpd.conf

We find the item with the IP address pool settings, which looks like:
subnet 192.168.10.0 netmask 255.255.255.0 ( range 192.168.10.10 192.168.10.254; option domain-name-servers 192.168.10.1; option domain-name "example.org"; option routers 192.168.10.1; option broadcast-address 192 .168.10.255 ; default-lease-time 604800; max-lease-time 604800;

And we add an entry pointing to our PXE bootloader:
ping-check = 1; filename = "pxelinux.0";
The path to the file is relative to the directory /var/lib/tftpboot/ those. it is considered the root directory, as I wrote about earlier...

The entire entry looks like:
ping-check = 1; filename = "pxelinux.0"; subnet 192.168.10.0 netmask 255.255.255.0 ( range 192.168.10.10 192.168.10.254; option domain-name-servers 192.168.10.1; option domain-name "example.org"; option routers 192.168.10.1; option broadcast-address 192 .168.10.255 ; default-lease-time 604800; max-lease-time 604800;

Save the changes and restart the DHCP server:
/etc/init.d/isc-dhcp-server restart

Now we can connect to our local network a device that supports PXE boot and in which this function is enabled (see the documentation for your equipment) or connect a virtual machine with the adaptometer connected in bridge mode and without bootable media.

If you did everything correctly, the menu will look like this:

And if you go to the menu Testing:


If you select the item with Memtest, a memory test will run.
Other menu items are added accordingly.

Let's imagine a situation where you need to provide access to one of the menus to a limited number of people, for example, you have a distribution kit there that costs a lot of money. For this purpose, you can set a password for a menu item, how to do this?!
Let's imagine a situation where you need to set a password (for example: password) on Memory Test, it's easy to do

Nano /var/lib/tftpboot/pxelinux.cfg/testing.menu

We need to add an entry:
MENU PASSWD password

Then the file looks like:
MENU TITLE Testing LABEL Test software MENU LABEL ^Return to Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default label memtest MENU PASSWD password menu label ^Memory Test: Memtest86+ v4.20 kernel memtest/mt86plus

The protection is, of course, so-so, but it can help for ordinary users.

Then when you try to start, the following window will appear:


If you enter the correct password, Memtest will start.
In this way, you can hide entire menus or block access to individual items.
If changes are made to these configuration files, there is no need to restart the DHCP server; it is enough to reboot the client PC if it booted via PXE.
Regarding the speed of tftp, the speed is not high, and if you decide to transfer large amounts of information, try to use a WEB or FTP server for this, be prepared to spend some time on it. If there is a need to download some kind of distribution, then it is better to download a small OS, an example would be Windows PE, or a miniature Linux distribution.
I guess I'll end here...

Continuing the series of articles on Windows deployment, today we will prepare a network boot server based on Linux OS and organize Windows boot PE from such a server, and we will also prepare an installation distribution of Windows 7 or Windows Server 2008 R2 for installation from a network resource. In this tutorial I will give an example for Debian Linux 8.

For work we need Windows image PE and installation distribution of the Windows system.

  • Creating your own Windows 7 or Windows Server 2008 R2 distribution image
  • Setting up a Linux PXE server for a network installation of Windows 7 or Windows Server 2008 R2

Preparing Windows Boot Files for PXE

To boot a Windows system from a PXE server, we need the following files:
  • winpe/boot/fonts/wgl4_boot.ttf - from the Windows distribution
  • winpe/boot/bcd - configuration storage (must be generated)
  • winpe/boot/boot.sdi - from Windows distribution
  • winpe/boot/winpe.wim - Windows PE image (assembly instructions)
  • winpe/pxeboot.0 - pxeboot.n12 from the Windows distribution
  • winpe/bootmgr.exe - from the Windows distribution
Let's create a folder in which we will collect the PXE-booted system:
Let's copy the font that uses bootfix.bin and the boot.sdi file, which is necessary to create a virtual disk in memory:
xcopy c:\WinPE\x86\ISO\boot\fonts\wgl4_boot.ttf c:\tftpboot\winpe\boot\fonts\wgl4_boot.ttf
xcopy c:\WinPE\x86\ISO\boot\boot.sdi c:\tftpboot\winpe\boot\boot.sdi
Now we need a bootloader that will load the boot manager and configuration store. They are in boot image Windows PE. To do this, connect the Windows PE image:
dism /mount-wim /wimfile:C:\WinPE\x86\winpe.wim /index:1 /mountdir:C:\WinPE\x86\mount
And copy the file pxeboot.n12 from there, renaming it pxeboot.0 and bootmgr.exe:
xcopy c:\WinPE\x86\mount\Windows\Boot\PXE\pxeboot.n12 c:\tftpboot\winpe\pxeboot.0
xcopy c:\WinPE\x86\mount\Windows\Boot\PXE\bootmgr.exe c:\tftpboot\winpe\bootmgr.exe
We have the necessary files except for the boot configuration and system image, so the Windows PE image can be disabled without saving changes:
dism /unmount-wim /mountdir:C:\WinPE\x86\mount /discard
Copy the Windows PE system image to the download folder:
xcopy C:\WinPE\x86\winpe.wim c:\tftpboot\winpe\boot\
Now is the time to generate the boot configuration; to do this, create the makebcd.cmd file:
notepad c:\tftpboot\makebcd.cmd
With the following content:
bcdedit -createstore %1\BCD
bcdedit -store %1\BCD -create (ramdiskoptions) /d "Ramdisk options"
bcdedit -store %1\BCD -set (ramdiskoptions) ramdisksdidevice boot
bcdedit -store %1\BCD -set (ramdiskoptions) ramdisksdipath \boot\boot.sdi
for /F "tokens=2 delims=()" %%i in ("bcdedit -store %1\BCD -create /d "Windows PE Boot Image" /application osloader") do set guid=(%%i)
bcdedit -store %1\BCD -set %guid% systemroot \Windows
bcdedit -store %1\BCD -set %guid% detecthal Yes
bcdedit -store %1\BCD -set %guid% winpe Yes
bcdedit -store %1\BCD -set %guid% osdevice ramdisk=\Boot\winpe.wim,(ramdiskoptions)
bcdedit -store %1\BCD -set %guid% device ramdisk=\Boot\winpe.wim,(ramdiskoptions)
bcdedit -store %1\BCD -create (bootmgr) /d "Windows BootManager"
bcdedit -store %1\BCD -set (bootmgr) timeout 30
bcdedit -store %1\BCD -set (bootmgr) displayorder %guid%
move %1\BCD %1\bcd
And let’s run it for execution, passing it the location and name of the configuration storage file as an argument:
c:\tftpboot\makebcd.cmd c:\tftpboot\winpe\boot
This completes the preparation of the necessary files for booting from PXE in the Windows environment, and we begin setting up the Linux server.

Installing a PXE server

Installing TFTP

Installing the required packages:
# aptitude install tftpd-hpa syslinux pxelinux -y
Setting up a TFTP server:
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure -m /etc/default/tftp-remap.conf -v"
RUN_DAEMON="yes"
Because Windows will look for its download files relative to the tftp root, we do mapping and associate these files with the winpe directory on the server.

Create a mapping file:

# vim /etc/default/tftp-remap.conf
With the following content:
r pxeboot.0 /pxeboot.0
r bootmgr.exe /winpe/bootmgr.exe
r\\Boot\\BCD /winpe/boot/bcd
r \\boot\\boot.sdi /winpe/boot/boot.sdi
r \\Boot\\winpe.wim /winpe/boot/winpe.wim
r \\Boot\\Fonts\\wgl4_boot.ttf /winpe/boot/fonts/wgl4_boot.ttf
gr\\/
The last line "gr \\ /" tells tftp if paths contain backslashes, change them to forward slashes.
Attention! It is important that the case of letters in file names is exactly the same as you specify in the files. If you specified /boot/bcd at the configuration stage and named the file /Boot/BCD, the bootloader will not be able to boot the system, because will not find the required file.

Let's create our download directory:

Now you need to copy files into it from the c:\tftpboot\ directory:
c:\tftpboot\winpe\> pscp -r * [email protected]:/srv/tftpboot/winpe

Creating a boot menu

In order for the boot menu to work, we need the following files, copy them to the root directory of our tftp server:
# cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftpboot
# cp /usr/lib/syslinux/modules/bios/chain.c32 /srv/tftpboot
# cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /srv/tftpboot
# cp /usr/lib/syslinux/modules/bios/libcom32.c32 /srv/tftpboot
# cp /usr/lib/syslinux/modules/bios/libutil.c32 /srv/tftpboot
# cp /usr/lib/syslinux/modules/bios/vesamenu.c32 /srv/tftpboot
And create a directory where the boot menu itself will be stored:
# mkdir -p /srv/tftpboot/pxelinux.cfg
We also need a beautiful loading image for our menu. She should be in jpg format and resolution 640x480. Let's copy it from our machine:
C:\Users\golovlevmv\> pscp Pictures\menu.jpg [email protected]:/srv/tftpboot/pxelinux.cfg/menu.jpg
Now it's time to create the boot menu:
With the following content:
PROMPT 0
UI vesamenu.c32
MENU TITLE PXE Server Boot Menu
MENU BACKGROUND pxelinux.cfg/menu.jpg
TIMEOUT 600

LABEL ^0) Boot from hard disk
TEXT HELP
Boot from first (hdd 0)
ENDTEXT
COM32 chain.c32
APPEND hd0 1

LABEL ^1) Load Windows PE 3.1 x86
TEXT HELP
Boot Windows PE x86 from pxeboot
ENDTEXT
kernel winpe/pxeboot.0

Restart tftpd:
# /etc/init.d/tftpd-hpa restart

Alternative PXE Boot Option

You can also organize another option for booting the system from PXE using memdisk, but it will require a significantly larger amount of memory and you may have problems with computers with less than 1GB of memory.

The Tftp server should already be prepared according to the instructions above.

We need memdisk, copy it from the syslinux package:

# cp /usr/lib/syslinux/memdisk /srv/tftpboot
Copy Windows ISO image PE:
C:\WinPE\x86\> pscp WinPE_x86.iso [email protected]:/srv/tftpboot/winpe/winpe_x86.iso
We add one more item to our boot menu:
# vim /srv/tftpboot/pxelinux.cfg/default
LABEL ^2) Load Windows PE 3.1 x86 (iso)
TEXT HELP
Boot Windows PE x86 from iso image
need more 512MB RAM to correct work
ENDTEXT
KERNEL memdisk
APPEND iso raw
INITRD winpe/winpe_x86.iso

DHCP setup

In order for our clients to be able to boot over the network, a DHCP server must be present, and it, in turn, must provide clients with a network boot reference address and the name of the file that needs to be loaded.
You can use any existing DHCP server; you need to pass the following parameters to it:
  • filename = "pxelinux.0";
  • next-server ;
If you do not have a DHCP server, I will also give an example of installing and configuring it on our PXE server.

Installing a DHCP server:

# aptitude install isc-dhcp-server -y
We enable DHCP on the one we need network interface:
# vim /etc/default/isc-dhcp-server
We bring dhcpd.conf to the form we need:
ddns-update-style none;
option domain-name "home.local";
option domain-name-servers 192.168.140.10;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.140.0 netmask 255.255.255.0 (
range 192.168.140.51 192.168.140.254;
option routers 192.168.140.10;
option domain-name "home.local";
filename = "pxelinux.0";
next-server 192.168.140.10;
}
Launch isc-dhcp-server:
# /etc/init.d/isc-dhcp-server start
Now we should load the Windows PE environment. Through it we can copy data from the emergency system and install a clean system on the machine.

We set the virtual machine to boot from network adapter, and try to boot via the network.

If everything worked out, then the main and most difficult part of the work is done. Now let's prepare the distribution kit for installing the system over the network.

Windows network installation

Next for network installation you can use an existing Windows or SAMBA file server. But, since I decided to organize the storage of system installation distributions on the same server, I will briefly show how to organize such a SAMBA server on our PXE server.

Installing SAMBA

Everything is quite simple here. I will provide a minimal config of smb.conf, without connecting the server to the domain and setting custom accounts. It will just be a server with guest read access.

Editing the samba configuration:


workgroup = WORKGROUP
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role= standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
acl allow execute always = true


comment = Windows 7
path = /srv/dist/win7x86
guest ok = yes
browseable = yes
create mask = 0644
directory mask = 0755
acl allow execute always = true

Don't forget to specify "acl allow execute always = true". This parameter must be specified so that you can launch exe files for execution, otherwise you will not be able to run setup.exe.

Let's take the Windows 7 SP1 x86 installation distribution of the required edition, and copy all the files to our server in the distribution folder:

C:\Users\golovlevmv\> pscp -r E:\ [email protected]:/srv/dist/win7x86/
Let's restart samba
Let's try to access our network resource by name or IP address "\\pxeboot\" or "\\192.168.140.10\".

Now, in order for our system to be installed from our server, we take the install.wim file, which we created when assembling our own Windows distribution, and replace the distribution file with it.

C:\Users\golovlevmv\> pscp C:\Win7\x86\dist\sources\install.wim [email protected]:/srv/dist/win7x86/sources/
But the file /srv/dist/win7x86/sources/boot.wim can be deleted, because By that time we had already loaded from using Windows P.E.

Starting installation of Windows 7 x86 system

In order to start the installation, you need to connect a network resource:
net use *\\192.168.140.10\win7x86
Connect the network drive "Z:", and run the command:
Next, in order to automate the installation of the system, you can use the “Windows System Image Manager” to prepare the answer file autounattend.xml, and run the installation with the answer file:
Z:\setup.exe /unattend:autounattend.xml
In this case, in order to deploy Windows systems on a large number of PCs, you will only need to boot from PXE, connect a network resource, and run the installation specifying the answer file.


Share