Boot server - like a bootable USB flash drive, only the server and over the network. AOMEI PXE Boot: Booting computers over the network from a disk image file Preparing a disk image for pxe boot

A bootable flash drive with a set of the necessary software is a wonderful tool for a system administrator. It would seem, what could be better? And the boot server can be better!

Imagine that you have chosen to boot over the network in the BIOS and you can install the OS / cure the computer of viruses / reanimate disks / test RAM / etc from the PXE Boot server, because this is much more convenient than running with a flash drive from machine to machine.
And in the case of a large computer park, such a tool is completely indispensable.

We wrote earlier about how to prepare Windows for installation with PXE.
The only difference with this installation is that here we can install both Windows 2008R2 and Windows 2012R2 (however, Windows 7/8 too, you just need to prepare the distribution and winpe files accordingly). After downloading winpe, we mount the /srv/tftp/images/ folder, which contains the files for installing the OS from Microsoft:
ls -l /srv/tftp/images/ total 8 drwxr-xr-x 6 root root 4096 Feb 17 22:19 w2k12r2 drwxr-xr-x 7 tftp tftp 4096 Feb 17 19:05 w2k8r2
and run the required installer.
For automation, through startnet.cmd, I sketched the following menu:

Now it remains to deal with VMware.
As you noticed, the configuration for installing hypervisors is somewhat different from the rest - this is where we need an HTTP server.
In /var/www we will create the folders vmw5.5, vmw5.0, and in the folders we will make symlinks to the config
# cd /var/www # mkdir vmw5.5 # cd vmw5.5/ # ln -s /srv/tftp/vmw/5.5/ks.cfg # mkdir ../vmw5.0 # cd ../vmw5.0/ # ln -s /srv/tftp/vmw/5.0/ks.cfg
How to prepare, for example, Debian for installation with PXE is written, but I will not stop there.

Add the ability to load various disk utilities and a memory test

This section will contain:
  1. Memtest86+
  2. clonezilla-live
  3. SystemRescueCD

configs are located here

default
ui vesamenu.c32 PROMPT 0 menu background background.jpg menu title ServerClub PXE boot menu LABEL bootlocal menu label Boot from first HDD kernel chain.c32 append hd0 0 timeout 120000 TEXT HELP The system will boot after time is up. ENDTEXT LABEL Windows -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/windows LABEL Linux -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/linux LABEL FreeBSD -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/bsd LABEL VMvare -> KERNEL vesamenu. c32 APPEND pxelinux.cfg/vmware LABEL HDD and RAM utils -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/du
du
PROMPT 0 UI vesamenu.c32 MENU BACKGROUND background.jpg MENU TITLE HDD and RAM utils LABEL<- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default LABEL Memtest86+ kernel memtest/memtest label Clonezilla-live MENU LABEL Clonezilla Live KERNEL clonezilla/vmlinuz APPEND initrd=clonezilla/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" keyboard-layouts="" ocs_live_batch="no" locales="" vga=788 nosplash noprompt fetch=tftp://10.0.10.1/clonezilla/filesystem.squashfs label SystemRescueCD kernel SystemRescueCD/isolinux/rescue64 append initrd=SystemRescueCD/isolinux/initram.igz dodhcp nfsboot=10.0.10.1:/srv/tftp/SystemRescueCD LABEL MHDD kernel memdisk initrd mhdd/mhdd32ver4.6.iso append iso raw LABEL <- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default


And I'll tell you why we also installed an NFS server.
As can be seen from the SystemRescueCD boot config, it pulls up the files necessary for this LiveCD by mounting the directory using the NFS protocol. The server is already installed, all that remains is to edit /etc/exports and restart the server daemon.
# cat >> /etc/exports /srv/tftp/SystemRescueCD/ 10.0.10.1/255.255.255.0(ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000) # service nfs-kernel-server restart
I suppose you have a reasonable question - "What does LiveCD do here if there is a separate item for them?"
SystemRescueCD contains a lot useful programs to work with the disk (such as GParted and testdisk) and therefore it is available both here and in the LiveCD.

live CD

Our LiveCD set will include:
  1. Debian 7 LiveCD
  2. HirensBootCD
  3. Trinity Rescue Kit CD
  4. SystemRescueCD
  5. Plop Live

configs

In the end default added
LABEL LiveCDs -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/livecds
livecds
PROMPT 0 UI vesamenu.c32 MENU BACKGROUND background.jpg MENU TITLE LiveCDs LABEL<- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default LABEL Debian LiveCD KERNEL Debian7live/vmlinuz APPEND initrd=Debian7live/initrd boot=live fetch=tftp://10.0.10.1/Debian7live/filesystem.squashfs root=/dev/ram0 rw LABEL HirensBootCD MENU LABEL Hiren"s Boot CD KERNEL memdisk APPEND iso initrd=hirens/hirens.iso LABEL Trinity Rescue Kit CD kernel trk/kernel.trk append initrd=trk/initrd.trk ramdisk_size=65536 root=/dev/ram0 vga=788 splash=verbose pci=conf1 trkmenu timeout 100 trknfs=10.0.10.1:/srv/tftp/trk ip=dhcp LABEL SystemRescueCD kernel SystemRescueCD/isolinux/rescue64 append initrd=SystemRescueCD/isolinux/initram.igz dodhcp nfsboot=10.0.10.1:/srv/tftp/SystemRescueCD LABEL Plop Live KERNEL plop/bzImage APPEND initrd=plop/initramfs.gz vga=normal nfsmount=10.0.10.1:/srv/tftp/plop LABEL <- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default

To download the Trinity Rescue Kit CD and Plop Live, add the following lines to /etc/exports:
/srv/tftp/trk/ 10.0.10.1/255.255.255.0(ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000) /srv/tftp/plop/ 10.0.10.1/255.255.255.0(ro,no_subtree_check, all_squash,insecure,anonuid=1000,anongid=1000)
and send the NFS restart command to the daemon.


A few words about the selected LiveCDs.
Debian 7 LiveCD
This CD is a build by one of our engineers, including the following:

Login / password: root / ServerClub

HirensBootCD
It hardly needs an introduction, it contains many useful utilities.
More details can be found.
It takes a long time to load, MiniXP and Linux do not work. Other utilities are available for use.

Trinity Rescue Kit CD
According to the developers, it was created to restore the Windows OS.
Contains utilities for resetting passwords, antiviruses, a program for cloning a "computer" over the network (moreover, on several computers at the same time), as well as much more.
Read more.

SystemRescueCD
Based on Gentoo, designed to restore Linux systems.
It includes a large number of various programs for administration, the list can be found at the link.

Plop Live
LiveCD with three full-fledged DEs to choose from, as well as the necessary admin software.

The final configuration file of the main menu, as well as the antivirus menu file

default
ui vesamenu.c32 PROMPT 0 menu background background.jpg menu title ServerClub PXE boot menu LABEL bootlocal menu label Boot from first HDD kernel chain.c32 append hd0 0 timeout 120000 TEXT HELP The system will boot after time is up. ENDTEXT LABEL Windows -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/windows LABEL Linux -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/linux LABEL FreeBSD -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/bsd LABEL VMvare -> KERNEL vesamenu. c32 APPEND pxelinux.cfg/vmware LABEL HDD and RAM utils -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/du LABEL LiveCDs -> KERNEL vesamenu.c32 APPEND pxelinux.cfg/livecds LABEL Antiviruses -> KERNEL vesamenu.c32 APPEND pxelinux.c fg /av
av
PROMPT 0 UI vesamenu.c32 MENU BACKGROUND background.jpg MENU TITLE Antivirus LABEL<- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default LABEL Kaspersky Antivirus KERNEL kav/rescue APPEND initrd=kav/rescue.igz root=live rootfstype=auto vga=791 init=/init kav_lang=ru udev liveimg doscsi nomodeset LABEL Kaspersky Antivirus (text mode) KERNEL kav/rescue APPEND initrd=kav/rescue.igz root=live rootfstype=auto vga=791 init=/init kav_lang=ru udev liveimg nox kavshell noresume doscsi nomodeset label AVG menu label AVG Rescue CD kernel avg/vmlinuz append max_loop=255 vga=791 initrd=avg/initrd.lzm init=linuxrc reboot=bios label AVG nofb menu label AVG Rescue CD with Disabled Framebuffer kernel avg/vmlinuz append max_loop=255 video=vesafb:off initrd=avg/initrd.lzm init=linuxrc reboot=bios label AVG vgask menu label AVG Rescue CD with Resolution Selection kernel avg/vmlinuz append max_loop=255 initrd=avg/initrd.lzm init=linuxrc vga=ask reboot=bios LABEL <- Main Menu KERNEL vesamenu.c32 APPEND pxelinux.cfg/default

Conclusion, it's also a surprise

Throughout the article, I deliberately did not give explanations of where to get and how to prepare the content, because these actions are very trivial and would only overload the text.

As a surprise, I offer you two options for our assembly, available from the links below:

  1. Archive with all content /srv/tftp (link to torrent file, direct link)
  2. Archive of the entire OS (link to torrent file, direct link)
In the first case, you need to prepare the server yourself (the chapter "Beginning" of this epos will help with this), unzip the contents of the archive and make adjustments according to the realities of your environment.

The second case involves installation on bare metal or a virtual machine.
Briefly, the steps to deploy an assembly from a full OS archive would be:
1. Boot from Linux LiveCD.
2. Partition the disk and format the partitions.
3. Mount the "/" partition.
4. Unpack the archive.
5. Install the bootloader.
6. Reboot.
7. Set up OS according to your network and start using.
Login / password: root / ServerClub.
IMPORTANT: If your network has a working dhcp server, then before starting our assembly, disable dhcp autostart in it.

This is the end, thank you for your attention!

For those who do not have an account on Habré.
If you have any questions / comments, then write to me by mail - erserverclub.com.

Today, more and more tasks are being automated, and virtualization is increasingly being used to maximize server performance. But you still have to install OSes. Everyone does it in their own way: someone has full pockets of various images for all occasions, someone in the old fashioned way carries with him a “purse” with discs, or even two. As a rule, administrators do this work with little pleasure. Let's see how to reduce time for trivial tasks, how to teach computers to install systems on their own, without the participation of an administrator at all, using only a local network.

So, today we will learn how to: install Windows and Linux over the network, load small ISO images, useful software (all sorts of Kaspersky, Acronis, WinPE, memtests), deploy thin clients and manage them. So that, for example, an accountant working with 1C via RDP doesn’t beat you up because her Windows crashed, and the report had to be prepared yesterday ... Or a stingy boss who doesn’t want to update his computer admired your professionalism when he will see how Windows 8 flies on old computers ... In achieving our insidious goals, a server that provides booting over the network (PXE) will help us.

Any system administrator has a universal USB-drive in his stash for emergency computer resuscitation. Agree, it would be much better to have the same functionality using only one network card. At the same time, it is impossible not to note the possibility of simultaneous work with several nodes at once. So, based on our needs, we have two solutions: use PXE or LTSP.

LTSP is not very suitable for us: it is designed to load the OS installed on the server itself over the network, which allows the use of LTSP server applications. This is not exactly what we need. PXE is a tool for booting a computer over a network without using local storage media, just like LTSP. PXE allows you to organize a multi-boot boot menu, similar to the universal "USB resuscitator".


What will we implement?

It all started with the need to have a tool for remote installation of Ubuntu / Debian Server over the network, with the ability to boot a Live CD of a small system, like SliTaz or Kolibri OS.
As they say, appetite comes with eating: they didn’t manage to realize what was planned, and a number of “Wishlists” were added to the plan. As a result, the list turned out to be quite impressive.

  1. Thin clients based on Thinstation Linux.
  2. Linux section.
    1. Installing Ubuntu 14.04 x86.
    2. Installing Ubuntu 14.04 x64.
    3. Installing Ubuntu 12.04 x86.
    4. Installing Ubuntu 12.04 x64.
  3. Windows section.
    1. Installing Windows 2012.
    2. Installing Windows 7.
  4. Acronis.
    1. Windows PE with a package of useful software.
    2. Acronis True Image.
      1. legacy BIOS.
      2. UEFI.
    3. Acronis Disk Manager.
      1. legacy BIOS.
      2. UEFI.
  5. Kaspersky Rescue v 10.
  6. ERD Commander 5 to 8 via ISO image.
  7. memtest.

We collect everything in a heap and take off

As a distribution kit for the server, the choice fell on Ubuntu Server 14.04.2 LTS. You can stop at any other OS, the difference will be only in the syntax. So let's get started. We need TFTP, DHCP (optionally installed on the same server, a router can act as a DHCP server), a service for organizing an NFS network file system. We will consider only those settings that interest us within the framework of the topic. First of all, install everything you need, having previously made all the updates:

Continued available to members only

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

Membership in the community during 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 has one very useful feature, everything that is configured in it is quite difficult to lose. all this is stored on the server, and not on removable media, which tend to get lost, stolen, forgotten in DVD / home drives, given to use and "satisfy", so the probability that you will be taken 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: perform hardware diagnostics, deploy operating systems, boot the Live system, etc. What is enough knowledge and imagination.
To do this, we need to configure a DHCP server and a TFTP server.
Earlier, I already wrote about how to set up a server for, I highly recommend it for review, the main points have migrated 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 users.

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

Everything else we'll install along the way... I won't dwell on the DHCP settings, assuming you have it configured, according to the article linked to in the system requirements.

Installing a tftp server
Install the required package:
We raise the rights to root:
sudo su

Install the required package
aptitude install tftpd-hpa

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

Let's move on to creating the boot menu
First of all, we need to get the deputy bootloader, how to do it ?! It can be found on any ubuntu disk, in other 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, pick it up and copy it to the directory:
/var/lib/tftpboot/
Then the path to it looks like:
/var/lib/tftpboot/pxelinux.0
Also, we need the boot menu itself, which can be taken on the same disk, in the directory boot-sccreens we are interested in a file named vesamenu.c32

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

Customizing 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 booted the PC via PXE and within 15 seconds. did not perform any action, 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 of workstations and servers, in general, a necessary thing, it will be useful to everyone in the household ...

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

Now let's create a configuration file with parameters for menu items, with the name 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, noticed that in the previous file we had an entry that refers to another file testing.menu, in it we will have the settings of 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 have not created the directory where the Memtest file is stored, we will fix this now, let's create the appropriate directory.
Let's do it:
mkdir /var/lib/tftpboot/memtest
It remains for us to 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 mt86 plus we need to copy it to the memtest directory so that the path to it looks like:
/var/lib/tftpboot/memtest/mt86plus

This is where we finished with the tftp server, we just need to finish the DHCP server a little.

Setting up a DHCP server

This item, the setting can only be called 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 settings of the pool of IP addresses, 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 19 2.168.10.255 ; default-lease-time 604800; max-lease-time 604800; )

And add an entry to it 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, which I wrote about earlier ...

The whole 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 19 2.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 an adapter connected in bridge mode and without bootable media.

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

And if you go to the menu testing:


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

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

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

Protection, of course, is so-so, but from ordinary users it can help.

Then, when you try to start, a 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 menu items.
If changes are made to these configuration files, there is no need to restart the DHCP server, it is enough to restart the client PC if it booted via PXE.
Regarding the speed of tftp, the speed of work is not high, and if you decide to transfer large amounts of information, try to use a WEB or FTP server for this, get ready to spend some time on this. If there is a need to download some distribution, then it is better to download a small OS, an example is Windows PE, well, or a miniature Linux distribution.
This is where I will end...

AOMEI PXE Boot is a free software to boot computers from ISO via LAN. Being very easy to use, this program allows you to use a bootable disk image (ISO) to boot multiple computers remotely, as long as they are connected to the same local network. This makes AOMEI PXE Boot an extremely useful tool for tasks such as remote application deployment and maintenance, especially in enterprises.

Working with AOMEI PXE Boot is quite simple: you install the program on the system that will be used as a server, mount the ISO and wait for the client machines to boot. And the best part is that AOMEI PXE Boot supports multiple computers to boot synchronously at the same time. Let's learn more about this great program and find out how you can use it to boot computers from ISOs over a wired LAN.

AOMEI PXE Boot: main purpose and a few words about Windows PE

It is important to note that AOMEI PXE Boot is primarily designed to fix problems with computers on the network. You can use the program to boot a non-functioning system in a restricted environment. For this purpose, AOMEI PXE Boot works best with Linux or Windows PE bootable disk images. The latter is an operating system with limited services that is used to boot the computer for repair or installation purposes. Based on the Vista kernel, Windows PE is not a complete operating system. Instead, it provides a safe environment for troubleshooting your computer and restoring it to a working state.

There is absolutely no reason to believe that AOMEI PXE Boot will not work with any other disk image. During testing, I was able to remote boot a Damn Small Linux (DSL) client system using a bootable ISO image.

How to boot computers using ISO over LAN

Now that you know a lot about AOMEI PXE Boot, it's time to see how this thing works. The process essentially consists of two stages. The first part involves configuring the client computer to boot over the network, and the second consists of configuring and running the application on the system acting as the server.

Please note that both computers must be connected to the same network. In my case, the server was connected to the network wirelessly, but the client machine was wired.

Part 1: Set up client computer(s) for network boot

As the name suggests, the first thing to do is set up the client computer or computers to boot over the wired network. To do this, you need to access the computer's BIOS menu. Here's how to do it (the process is more or less the same, regardless of computer manufacturer):

1. Turn on the client computer and press the key to access the BIOS menu (usually Del, Esc, F8, or F12). In the BIOS, go to the "Boot" submenu and in the "Boot Options Priorities" section, select "PXE" (on some computers "Legacy LAN", "Realtek PXE B02 D00", "Network boot from Intel", etc.) as first boot device. You may also need to enable the PXE ROM option if it is disabled.

2. AOMEI PXE Boot only supports Legacy boot mode, so you also need to disable the UEFI Boot option if it is supported by your computer motherboard. This option can be found in the Boot submenu.

This is all that needs to be done on the client computer. Be sure to save the changes you made to the BIOS configuration. Now let's move on to the server.

Part 2: Download the ISO and run the application on the server computer

This part is actually even easier. First, download and install AOMEI PXE Boot (about 5 MB) on the computer that will be used as a server. In addition to this, you must also download a bootable disk image to boot the client computer or computers. The steps below explain what is required of you:

1. Launch AOMEI PXE Boot. On the first screen of the program, select the "Boot from custom image file" option and navigate to your ISO file (you can also use the other option to download a Windows PE or Linux ISO from the AOMEI website if you wish). Once the image is selected, click on the "Start Service" button to start the service.

2. Now the AOMEI PXE Boot window will display information about the activity taking place on the server and client computers. You don't need to do anything else on the server. To see the real action, let's move on. And, needless to say, the application, and of course the server, must be running.

You just have to start the client computer and wait until it boots over the network using the ISO image that you selected through AOMEI PXE Boot on the server computer. Here is a fully working Damn Small Linux distribution running on a client machine:

Final words

If you are a network administrator looking for a simple and efficient (and no frills) way to deploy and manage your OS remotely, AOMEI PXE Boot might be just what you need. It's a quality tool that's ridiculously easy to set up and works surprisingly well.

Have a great day!

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

To work, we need a Windows PE image and an installation distribution of the Windows system.

  • Create a custom image of a Windows 7 or Windows Server 2008 R2 distribution
  • Configuring a Linux PXE Network Installation Server for 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 store (need to be generated)
  • winpe/boot/boot.sdi - from the Windows distribution
  • winpe/boot/winpe.wim - Windows PE image (build 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 assemble the PXE bootable system:
Let's copy the font that uses bootfix.bin and the boot.sdi file that is needed 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 the Windows PE boot image. To do this, we will connect the Windows PE image:
dism /mount-wim /wimfile:C:\WinPE\x86\winpe.wim /index:1 /mountdir:C:\WinPE\x86\mount
And copy the pxeboot.n12 file from there, renaming it to 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, with the exception of the boot configuration and the 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 it's time to generate the boot configuration, for this we will 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 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 proceed to configure the Linux server.

PXE server installation

Installing TFTP

Installing required packages:
# aptitude install tftpd-hpa syslinux pxelinux -y
Set 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 boot files relative to the tftp root, map and associate those files with the winpe directory on the server.

Create a mapping file:

# vim /etc/default/tftp-remap.conf
With the following content:
rpxeboot.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 to change backslashes to forward slashes in paths.
Attention! It is important that the case of the letters in the file names is exactly the same as you specify in the files. If you specified /boot/bcd at the configuration stage, and the file was named /Boot/BCD, the bootloader will not be able to boot the system, because. does not find the required file.

Create our download directory:

Now you need to copy files to 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 nice boot image for our menu. It must be in jpg format and 640x480 resolution. 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 ftpd:
# /etc/init.d/tftpd-hpa restart

Alternative PXE boot option

You can also organize another option to boot the system from PXE using memdisk, but it will require much more memory and you may have problems with computers with less than 1GB of memory.

The Tftp server must already be prepared, following the instructions above.

We need memdisk, copy it from the syslinux package:

# cp /usr/lib/syslinux/memdisk /srv/tftpboot
Copy the Windows PE ISO image:
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

Configuring DHCP

In order for our clients to be able to boot over the network, we need a DHCP server, which in turn must give clients the address of the network boot server and the file name to be downloaded.
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.

Install DHCP server:

# aptitude install isc-dhcp-server -y
Enable DHCP on the network interface we need:
# 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;
}
Start isc-dhcp-server:
# /etc/init.d/isc-dhcp-server start
Now we should have a Windows PE environment loaded. Through it, we can copy the data from the emergency system and install a clean system on the machine.

We set the virtual machine to boot from the 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

You can then use an existing Windows-based or SAMBA-based file server for network installation. But, since I decided to organize the storage of the installation distributions of the system 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 give a minimal smb.conf config, without connecting the server to the domain and setting user accounts. It will be just a server with guest read access.

Edit 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 in order to be able to run exe files for execution, otherwise you will not be able to run setup.exe.

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

C:\Users\golovlevmv\> pscp -r E:\ [email protected]:/srv/dist/win7x86/
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 building 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 /srv/dist/win7x86/sources/boot.wim file can be deleted, because By that time, we had already made the download using Windows PE.

Starting the installation of Windows 7 x86

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:
Further, in order to automate the installation of the system, you can use the "Windows System Image Manager" to prepare the autounattend.xml answer file, 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 share, and run the installation with the answer file.


mob_info