Sunday, October 16, 2011

Windows 8 Preview installation using Network Boot (PXE)

Having an older Vaio VGN-A115B laptop with not enough disk space on the system partition (running the setup.exe from the older OS it says it requires 16 GB  free, although it will happily install later on a 12 GB partition), a shot DVD drive that couldn’t read a DVD-RW disk with Windows 8 installer and on top of that didn’t seem to power the USB ports at boot, the only option I was left off was to do a network boot (PXE) – something I always wanted to try. So after two days and a lot of failed attempts, here it is.

Somehow I always thought booting through PXE would be easy (just as easy as the USB or DVD boot) – and how wrong I was, as it requires both a DHCP server that allows to specify a boot program and TFTP server, neither of which is easily found on the net (details on Intel Boot Agent).

Eventually I did stumble onto TFTPD32/64 and Serva32/64 – both looking fairly similar which is fair enough cause the second is based on code from the first one. They seemed to have done the job well for other people, but for me the embedded TFTPD server failed a lot on transferring the BCD store during tests with a local VM, so I finally stopped using that and eventually found SolarWind TFTP Server much more reliable.

To make things even more complicated, you have to prepare the boot image with Windows PE (Preinstallation Environment) – you can find a lot more information for that one the web, but it does require quite a large download of the Windows Automated Installation Kit (AIK) – in my case I downloaded version 3.0 for Windows 7.

A few things to note about my setup

Since I already have a router on the network with a DHCP server running, to avoid conflicts I used an Ethernet hub I had around to connect the two laptops directly. I manually setup the Ethernet adapter on my “server” to use 10.0.0.1 IP address (easier to type) and disabled the firewall as well as the wireless adapter for the duration of the exercise (you can probably just as easily add the server programs below as exceptions to the firewall) – if you do it like me, remember to re-enable the firewall back on when finished and to set the Ethernet adapter for automatic IP allocation later on.

You may also notice that I also configured the DHCP server to server IP addresses from the same private class (10.0.0.xxx).

To point out we will prepare a 32 bit WinPE image in C:\WinPE directory and then use the C:\TFPT-Root\Boot to place the boot files (SolarWind TFTP server defaults to C:\TFTP-Root, feel free to change).

Windows PE image preparation

Installing Windows Automated Installation Kit (AIK) is fairly straight forward so I’m not going to go into details on that. For preparing the WinPE image I started from this Microsoft Walkthrough: Deploy an Image by Using PXE although I’m not going to follow it to the letter, feel free to use that if you want.

Run Windows AIK Command prompt:


Run the copype.cmd command (will automatically change to the image directory and will use relative paths from then on) – remember I’m building an image for an x86 system :
copype.cmd x86 C:\WinPE

imagex /mountrw winpe.wim 1 mount

copy mount\Windows\Boot\PXE\*.* C:\TFTP-Root\Boot

Now for copying boot.sdi you can use the full path to AIK tools or simply close the console and run a new Deployment console and use relative paths.
copy x86\boot\boot.sdi C:\TFTP-Root\Boot


Back to the WinPE directory and unmount the image (cleanup).
cd /d C:\WinPE      
imagex /unmount mount


Copy winpe.wim in the TFTP boot directory as boot.wim (might just work as winpe.wim, but the BCD commands below will mention boot.wim).
copy winpe.wim C:\TFTP-Root\Boot\boot.wim


Now moving on to preparing the BCD store. You might notice that instead of specifying the full path to the BCD I will change directory to the Boot directory and do it from in there. Personally I reuse the previous command (press up arrow) and change the parts at the end.
cd /d C:\TFTP-Root\Boot      
bcdedit -createstore BCD

bcdedit -store BCD -create {ramdiskoptions} /d "Ramdisk options"      
bcdedit -store BCD -set {ramdiskoptions} ramdisksdidevice boot       
bcdedit -store BCD -set {ramdiskoptions} ramdisksdipath \boot\boot.sdi

bcdedit -store BCD -create /d "MyWinPE Boot Image" /application osloader


Note the highlighted GUID value – you will need to copy that and use it in the subsequent commands (replace {guid} with the one generated for you).
bcdedit -store BCD -set {guid} systemroot \Windows      
bcdedit -store BCD -set {guid} detecthal Yes       
bcdedit -store BCD -set {guid} winpe Yes       
bcdedit -store BCD -set {guid} osdevice ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}      
bcdedit -store BCD -set {guid} device ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}

bcdedit -store BCD -create {bootmgr} /d "Windows BootManager"     
bcdedit -store BCD -set {bootmgr} timeout 30      
bcdedit -store BCD -displayorder {guid}

This is what I eventually got in the Boot folder.


Sharing Windows 8 installation files

    As you will see later on, when the remote computer will boot up and load the WinPE image it will take you to a command line where you need to map a network drive to the computer sharing the image files.

    In my case, I took the Windows 8 ISO image, mounted in Virtual Clone Drive and shared it as Windows8 folder. I also created a pxe user with pxe password (you can use an existing user if it has a password assigned to it), and you will see how you will need to map a network drive from the remote computer to the installation files in order to start the actual Windows setup.

    Serva32/64 DHCP server

      As noted below, I will configure Serva64 (in my case again, running Windows 7 x64) to only enable the DHCP server and disable the other services.
      IP pool / size : 10.0.0.100 / 100 (IP range .100 to .200)
      Boot file      : Boot\pxeboot.com
      Subnet mask    : 255.255.255.0

      SolarWinds TFTP server

        Not much to configure there, go to File > Configure and start the service (change the storage location to point to your files – note we’re not pointing to Boot, but the parent directory). Otherwise the software is smart enough to bind to the interface and allow to serve files.


        Test run with Windows Virtual PC

          Simply create a VM with a blank VM and it will try to automatically boot from the network – if everything works fine you will notice that it gets an IP in DHCP server console and it will start transferring files from the TFTP server.



            Old laptop (PXE booting)

              I should note that in the case of my VAIO I had to enable the Network Boot in BIOS (press F2 at boot) and then press ESC to get the boot devices listing and choose Network Boot. Then it will move to a screen similar to the above if everything is setup ok.

              Pressing F12 will continue the boot process, where it downloads the boot manager, WinPE image etc. Ignore the errors in the TFTP console about not finding boot.ini and wgl4_boot.ttf.


              Eventually the remote computer will start loading boot.wim and get you the setup background and a command line prompt. Now you will map that network drive to point to the installation files (remember I created a new user pxe/pxe and shared the Windows8 installation files – the net use command will fail if a user is not specified saying something about Server service not being started).

              From the remote computer console run the statements:
              net use y: \\10.0.0.1\Windows8 pxe /user:pxe
              y:\setup.exe
              And finally now you are running the Windows 8 setup and continue with the usual stuff… It only took me 2 days to figure it out and get it running, hopefully this is going to useful to someone else as well, I know I’ll definitely try it again, although I will be zipping up the boot files and keeping them for future use, what might change is the setup files on the share.

              Keep in mind that when we prepared the image in the first place it was for an x32 platform and you will probably need to go through the process again to build for an x64 platform, replacing all the x86 references with amd64.

              14 comments :

              1. One of Serva's main features is running all the PXE reqd services on a single app.
                I'm using Serva's TFTP and after setting it right I never got a problem...
                Why don't you contact Serva's author with your findings? I did it in the past and he was very responsive.

                ReplyDelete
              2. That is true, and in fairness TFTPD32/64 does the exact same thing (the interface is a bit cleaner and works slightly better than TFTPD), but they both were failing when communicating my Vaio - I might give them a try again next time, it can very well be the Intel Boot Agent version in my Vaio.

                ReplyDelete
              3. Verify you are configuring TFTP options properly. I "think" you have to uncheck "PXE Compatibility" for PXE booting Microsoft OSs

                Besides the neater approach Serva really does many more things and better (it doesn't crash!)than Tftpd...

                ReplyDelete
              4. I don't know, I tried a few different combinations and it was mostly right in the Intel Boot Agent, tried with the laptop itself, then with Virtual PC and VMware Player all with different PXE clients and they all failed till I used the SolarWinds TFTPD server - they all served the files just fine to the ftpd.exe Windows client, but the timeout might be short in the embedded clients as I've seen then trying a lot... Anyways, not important, what's important is that it worked for you, and anyone reading the comments will now have alternatives - that's why I mentioned it in the first place, maybe it works for someone else.

                ReplyDelete
              5. Excellent ! I tried once but could not get through, tried again got it, again on third attempt there was an error while booting. But doesn't matter. Can you please provide me details or link for doing the same for another O.S. say Windows XP

                arabimran@hotmail.com

                ReplyDelete
              6. I'd say you need a WAIK that supports Windows XP, maybe see this.

                http://technet.microsoft.com/en-gb/magazine/2007.01.desktopfiles.aspx
                http://www.microsoft.com/download/en/details.aspx?id=10333

                If unable to transfer the files from TFTPD server, watch the logs and maybe see this as well.

                http://dandar3.blogspot.com/2012/03/windows-8-consumer-preview-installation.html

                ReplyDelete
              7. just get Serva 2.0; it does everything automatically...
                read here:
                http://vercot.com/~serva/howto/WindowsPXE1.html

                ReplyDelete
              8. Serva is violating GPL, look here for proof: http://reboot.pro/16899/

                I would recommend sticking with a good open source application instead of using a shady tool.

                ReplyDelete
              9. Yeah, maybe not fully compliant with chapter 6 of GNU Lesser General Public License 2.1 (http://www.gnu.org/licenses/lgpl-2.1.html), but I see it mentions Hivex in the About dialog (Hivex by Richard W.M. Jones).

                Which open source alternatives would you recommend?

                Thanks,
                Dan

                ReplyDelete
              10. I'm always looking for net boot alternatives, FOG could be somehow a Serva alternative but not really the same. Serva is just one of a kind.

                I've read http://reboot.pro/16899/ which seems not to be a serious analysis; those guys can’t tell the difference between GPL and LGPL.

                ReplyDelete
              11. Thanks for that, FOG Project looks interesting (http://www.fogproject.org/wiki/index.php?title=FOGUserGuide#Preface) from what I can see (it's a got a few video tutorials on YouTube). Might be interesting to build a VM with FOG, and just bring up whenever needed.

                ReplyDelete
              12. One of the big differences is that FOG is an "HDD image" server; you create an image of your HDD for offering it to the net.
                Serva instead, natively offers Microsoft install CDs, DVDs, or ISOs as they come from Seatle.

                If you have to install customized images on identical hardware FOG/Clonezilla are valid options, for everything else Serva is the way. I’ve tried them all, today I use Serva most of the time.

                ReplyDelete
              13. I see, that would make it a bit more complicated for the casual home user scenarios...

                ReplyDelete
              14. Good to see the windows 8 update here with preview.

                ReplyDelete