Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


WreX

XP Sysprep Clears My WinPE BCD Entry!

Recommended Posts

I'm developing an automated XP deployment using WinPE 2.0 and WIM image files. I'm using the Vista boot loader configured with bcdedit to launch a custom PE WIM on C: into RAM, and a legacy ntldr pointing at D:. The problem I'm encountering is that I can get everything configured as desired, apply the XP WIM to D:, ready to boot into Sysprep, but after Sysprep completes, my BCD entry for booting PE has been cleared of everything but the identifier and subsequently is no longer bootable!

While in the initial PE boot from CD the hard disk is partitioned and formatted NTFS with diskpart, then the boot loader configured with bcdedit, including "bootsect /nt60 c:". Then NTLDR, NTDETECT.COM, and boot.ini are copied to C:\ and the OS image applied to D:\ with D:\Sysprep\sysprep.inf getting customized. The reboot after that is able to load the PE WIM on C:, but if the Sysprep mini-install runs, the details for the PE WIM magically disappear.

Here's the command used to get Sysprep ready: Sysprep -pnp -reboot -mini -activated -reseal

Here's what's in Sysprep.inf:

[Unattended]
OemSkipEula=Yes
UnattendMode=FullUnattended
DriverSigningPolicy=Ignore
OemPnpDriversPath=*Lots of folders*
InstallFilesPath=\Sysprep\i386
; OemPreinstall=Yes
; ExtendOEMPartition=1
[WindowsFirewall]
Profiles = WindowsFirewall.TurnOffFirewall

[WindowsFirewall.TurnOffFirewall]
Mode = 0

[GuiUnattended]
OEMDuplicatorstring=*Description*
AdminPassword=*The password*
OEMSkipRegional=1
TimeZone=35
OemSkipWelcome=1
AutoLogon=Yes
AutoLogonCount=1

[UserData]
ProductID=*ID*
FullName=*Name*
OrgName="*Name*"
ComputerName=*Custom Computer name*

[Identification]
JoinWorkgroup=*Workgroup Name*

[Networking]
InstallDefaultComponents=Yes

Here are the commands used to configure the BCD:


xcopy %CDROM%:\BOOT\*.* /e /f /y C:\BOOT\
copy %CDROM%:\BOOTMGR C:\
IF EXIST C:\BOOT\BCD DEL C:\BOOT\BCD
IF NOT EXIST C:\TEMP MD C:\TEMP
IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCD
bcdedit -createstore C:\TEMP\BCD
bcdedit -store C:\TEMP\BCD -create {bootmgr} /d "Boot Manager"
bcdedit -store C:\TEMP\BCD -set {bootmgr} device boot
bcdedit -store C:\TEMP\BCD -create {ramdiskoptions} /d "WinPE"
bcdedit -import C:\TEMP\BCD
bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
bcdedit -set {ramdiskoptions} ramdisksdipath \BOOT\BOOT.sdi
for /f "tokens=3" %%a in ('bcdedit -create /d "WinPE" -application osloader') do set guid=%%a
bcdedit -set %guid% device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
bcdedit -set %guid% path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE
bcdedit -set %guid% osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
bcdedit -set %guid% systemroot \WINDOWS
bcdedit -set %guid% winpe yes
bcdedit -set %guid% detecthal yes
bcdedit -displayorder %guid% -addlast
bcdedit -create {ntldr} /d "Microsoft Windows XP Professional"
bcdedit -set {ntldr} device boot
bcdedit -set {ntldr} path \ntldr
bcdedit -displayorder {ntldr} -addfirst
bcdedit -default {ntldr}
bcdedit -timeout 5
bootsect /nt60 C:
IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCD
bcdedit

Here's what bcdedit shows before Sysprep:


Windows Boot Manager
--------------------
identifier {bootmgr}
device boot
description Boot Manager
default {ntldr}
displayorder {ntldr}
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
timeout 5

Windows Legacy OS Loader
------------------------
identifier {ntldr}
device boot
path \ntldr
description Microsoft Windows XP Professional

Windows Boot Loader
-------------------
identifier {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE
description MAINT
osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
systemroot \WINDOWS
detecthal Yes
winpe Yes

...and after Sysprep:



Windows Boot Manager
--------------------
identifier {bootmgr}
device boot
description Boot Manager
default {ntldr}
displayorder {ntldr}
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
timeout 5

Windows Legacy OS Loader
------------------------
identifier {ntldr}
device boot
path \ntldr
description Microsoft Windows XP Professional

Windows Boot Loader
-------------------
identifier {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

Does anyone have any thoughts on this? My initial C:\boot.ini has "timeout=5", but after Sysprep runs it has "timeout=30", so Sysprep is obviously doing something to modify the boot process, I just can't wrap my head around what it could do to my BCD.

Share this post


Link to post
Share on other sites

For what it's worth, I can't even export / import my BCD. Here's what I've tried:

1) Boot PE from CD, partition, format, extract WIMs, reboot

2) Boot PE from C:\ via the boot loader, export the BCD via "bcdedit /export FILE_NAME", reboot

3) Boot Sysprep via the boot loader, let it do its reboot

4) Boot to PE from C:\ fails via the boot loader, so boot PE from CD, attempt a BCD import via "bcdedit /import FILE_NAME", but the boot PE from C:\ option remains bad

5) Boot XP via the boot loader and let it complete its imaging

Perhaps this is a clue about what the problem is. Maybe the import fails because after Sysprep runs some data on C: doesn't match up with what's in the exported BCD and it refuses to acknowledge my past entry. I may have to enlist the big guns from M$ to figure this bad boy out.

Share this post


Link to post
Share on other sites

Original boot.ini:

[boot loader]
timeout=5
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="Microsoft Windows XP Professional" /fastdetect

After Sysprep:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(2)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINNT="Microsoft Windows XP Professional" /fastdetect

Windows is installed in D:\WINNT. I've tried removing the timeout line from the original but that hasn't made a difference.

Keep in mind that boot.ini isn't my issue, the problem is that Sysprep is clobbering one entry in my BCD, but not the boot loader itself. The NTLDR stuff continues to function as expected.

Edited by WreX

Share this post


Link to post
Share on other sites

From M$ http://technet2.microsoft.com/windowsserve...3.mspx?mfr=true:

How to modify BCD when installing a previous version of Windows onto a computer running Windows Vista

To install an older Windows operating system on a computer running Windows Vista, use the following procedure.

To install a previous version of Windows onto a computer running Windows Vista

1. Install the previous version of Windows.

2. Log on to the older operating system and restore the latest boot manager by running the following. Fixntfs.exe will be in the \boot directory of the active partition.

fixntfs /lh

3. Create a BCD entry for the older operating system by specifying the following. Bcdedit.exe is located in the \Windows\System32 directory of the Windows Vista partition. Description is the description of the new entry for the older operating system.

Bcdedit /create {legacy} /d “Description”

Bcdedit /set {legacy} device boot

Bcdedit /set {legacy} path \ntldr

Bcdedit /displayorder {legacy} /addlast

4. Restart the computer in order for the changes to take effect.

Seems like fixntfs.exe should do the trick. So perhaps you could add this to a script and put it in sysprep\I386\$OEM$\CmdLines.txt

Share this post


Link to post
Share on other sites

Unfortunately, fixntfs is for repairing the Boot Sector, which I have no problem with. That procedure is for when you run a legacy Windows text setup and it overwrites the Boot Sector to use the legacy boot loader. My Vista boot loader works fine, the problem is that one of its entries gets cleared of everything but its GUID after Sysprep runs.

Share this post


Link to post
Share on other sites

Yeah, I had to download fixntfs.exe since I'm not running Vista and it's not included with PE 2.0. It did nothing to the contents of my BCD. If I did "fixntfs -xp" I got the legacy loader, if I did "fixntfs -lh" I got my Vista loader configured as before. Basically, it's the same thing as doing "bootsect /nt52 c:" for legacy and "bootsect /nt60 c:" for Vista.

Share this post


Link to post
Share on other sites

Is it possible to save an unaltered copy of the working BCD and then just import it back in once sysprep is done, but before the reboot?

Edited by TheReasonIFail

Share this post


Link to post
Share on other sites

Ok I set up a test box with you parameters and duplicated the error. I added a batch file and bcdedit to the \sysprep\i386\$OEM$ directory to add the correct entries back to the bcd. Worked flawlessly, but for some reason renamed the GUID to {current}.

bcdfix.bat:

@echo off
bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
for /f "tokens=2,3*" %%i in ('bcdedit -enum bootapp') do set guid=%%i
bcdedit -set %guid% device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
bcdedit -set %guid% path \WINDOWS\System32\boot\winload.exe
bcdedit -set %guid% osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
bcdedit -set %guid% systemroot \WINDOWS
bcdedit -set %guid% winpe yes
bcdedit -set %guid% detecthal yes

Cmdlines.txt:

"cmd /c \sysprep\i386\$OEM$\bcdfix.bat"

Share this post


Link to post
Share on other sites

Forget about the {current} comment. That appeared because I was in that PE environment when I ran the command. The acutal GUID didn't change.

Edited by zorphnog

Share this post


Link to post
Share on other sites

I'm still focused on getting an answer / resolution to this that doesn't require a script to be run after the boot loader is busted. I've been struggling the last few days to get setup for M$ phone support, but I should be able to find out what they have to say in the next few days.

On a related note, I've noticed some interesting behavior around this whole scenario:

Boot PC to PE, partition and format hard disk with the following diskpart script and allow the load to complete:

select disk 0
clean
create partition primary size=####
active
assign letter=C:
format fs=NTFS label="NAME" quick
create partition extended
create partition logical
assign letter=D:
format fs=NTFS label="NAME" quick

After Sysprep runs on the PC, the option to boot the WIM on C: into RAM is broke. However, if I run my same routine again, but exclude partitioning the drive and simply format D: with diskpart, my boot loader works every time, even after sysprep!

select disk 0
select volume d
format fs=NTFS label="NAME" quick

So for whatever reason, it looks like after Sysprep has initially left its mark on C: and C: isn't subsequently touched, my bcdedit commands seem to stick. Hopefully this gives the M$ folks something to work with.

Share this post


Link to post
Share on other sites

Did you find a solution to this issue? I'm having almost exactly the same problem.

Share this post


Link to post
Share on other sites

My only solution was to run a batch file during the first boot and login after SysPrep to reconfigure my BCD entry. I decided on a static GUID so I wouldn't have to keep track of dynamic ones. Here's what I run from the batch file to re-install my entry:

bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
bcdedit -set {ramdiskoptions} ramdisksdipath \BOOT\BOOT.sdi
bcdedit -set {00000000-0000-0000-0000-000000000001} device ramdisk=[C:]\WINPE\WINPE.WIM,{ramdiskoptions}
bcdedit -set {00000000-0000-0000-0000-000000000001} path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE
bcdedit -set {00000000-0000-0000-0000-000000000001} osdevice ramdisk=[C:]\WINPE\WINPE.WIM,{ramdiskoptions}
bcdedit -set {00000000-0000-0000-0000-000000000001} systemroot \WINDOWS
bcdedit -set {00000000-0000-0000-0000-000000000001} winpe yes
bcdedit -set {00000000-0000-0000-0000-000000000001} detecthal yes
bcdedit -set {00000000-0000-0000-0000-000000000001} advancedoptions no
bcdedit -displayorder {00000000-0000-0000-0000-000000000001} -addlast

It leaves my boot option in a bad state for one boot, but the user isn't present to do anything at that point, so fixing it on the first boot wasn't a problem.

Share this post


Link to post
Share on other sites

Thanks for the info but unfortunately I need a solution that is completely automated. I won't be doing the installs. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...