WreX Posted February 11, 2008 Posted February 11, 2008 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 -resealHere'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=YesHere 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\BCDIF NOT EXIST C:\TEMP MD C:\TEMPIF EXIST C:\TEMP\BCD DEL C:\TEMP\BCDbcdedit -createstore C:\TEMP\BCDbcdedit -store C:\TEMP\BCD -create {bootmgr} /d "Boot Manager"bcdedit -store C:\TEMP\BCD -set {bootmgr} device bootbcdedit -store C:\TEMP\BCD -create {ramdiskoptions} /d "WinPE"bcdedit -import C:\TEMP\BCDbcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:bcdedit -set {ramdiskoptions} ramdisksdipath \BOOT\BOOT.sdifor /f "tokens=3" %%a in ('bcdedit -create /d "WinPE" -application osloader') do set guid=%%abcdedit -set %guid% device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}bcdedit -set %guid% path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXEbcdedit -set %guid% osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}bcdedit -set %guid% systemroot \WINDOWSbcdedit -set %guid% winpe yesbcdedit -set %guid% detecthal yesbcdedit -displayorder %guid% -addlastbcdedit -create {ntldr} /d "Microsoft Windows XP Professional"bcdedit -set {ntldr} device bootbcdedit -set {ntldr} path \ntldrbcdedit -displayorder {ntldr} -addfirstbcdedit -default {ntldr}bcdedit -timeout 5bootsect /nt60 C:IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCDbcdeditHere's what bcdedit shows before Sysprep:Windows Boot Manager--------------------identifier {bootmgr}device bootdescription Boot Managerdefault {ntldr}displayorder {ntldr} {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}timeout 5Windows Legacy OS Loader------------------------identifier {ntldr}device bootpath \ntldrdescription Microsoft Windows XP ProfessionalWindows Boot Loader-------------------identifier {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXEdescription MAINTosdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}systemroot \WINDOWSdetecthal Yeswinpe Yes...and after Sysprep:Windows Boot Manager--------------------identifier {bootmgr}device bootdescription Boot Managerdefault {ntldr}displayorder {ntldr} {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}timeout 5Windows Legacy OS Loader------------------------identifier {ntldr}device bootpath \ntldrdescription Microsoft Windows XP ProfessionalWindows 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.
WreX Posted February 13, 2008 Author Posted February 13, 2008 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, reboot2) Boot PE from C:\ via the boot loader, export the BCD via "bcdedit /export FILE_NAME", reboot3) Boot Sysprep via the boot loader, let it do its reboot4) 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 bad5) Boot XP via the boot loader and let it complete its imagingPerhaps 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.
zorphnog Posted February 14, 2008 Posted February 14, 2008 What does your boot.ini look like originally?
WreX Posted February 14, 2008 Author Posted February 14, 2008 (edited) Original boot.ini:[boot loader]timeout=5default=multi(0)disk(0)rdisk(0)partition(2)\WINNT[operating systems]multi(0)disk(0)rdisk(0)partition(2)\WINNT="Microsoft Windows XP Professional" /fastdetectAfter Sysprep:[boot loader]timeout=30default=multi(0)disk(0)rdisk(0)partition(2)\WINNT[operating systems]multi(0)disk(0)rdisk(0)partition(2)\WINNT="Microsoft Windows XP Professional" /fastdetectWindows 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 February 14, 2008 by WreX
zorphnog Posted February 14, 2008 Posted February 14, 2008 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 VistaTo 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 Vista1. 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 /lh3. 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 bootBcdedit /set {legacy} path \ntldrBcdedit /displayorder {legacy} /addlast4. 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
WreX Posted February 14, 2008 Author Posted February 14, 2008 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.
zorphnog Posted February 14, 2008 Posted February 14, 2008 Have you tried it? Seems to me that the situation would still apply.
WreX Posted February 14, 2008 Author Posted February 14, 2008 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.
TheReasonIFail Posted February 15, 2008 Posted February 15, 2008 (edited) 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 February 15, 2008 by TheReasonIFail
zorphnog Posted February 15, 2008 Posted February 15, 2008 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 offbcdedit -set {ramdiskoptions} ramdisksdidevice partition=C: for /f "tokens=2,3*" %%i in ('bcdedit -enum bootapp') do set guid=%%ibcdedit -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 yesCmdlines.txt:"cmd /c \sysprep\i386\$OEM$\bcdfix.bat"
zorphnog Posted February 15, 2008 Posted February 15, 2008 (edited) 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 February 15, 2008 by zorphnog
WreX Posted February 20, 2008 Author Posted February 20, 2008 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 0cleancreate partition primary size=####activeassign letter=C:format fs=NTFS label="NAME" quickcreate partition extendedcreate partition logicalassign letter=D:format fs=NTFS label="NAME" quickAfter 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 0select volume dformat fs=NTFS label="NAME" quickSo 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.
benjt Posted June 19, 2009 Posted June 19, 2009 Did you find a solution to this issue? I'm having almost exactly the same problem.
WreX Posted June 19, 2009 Author Posted June 19, 2009 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.sdibcdedit -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.EXEbcdedit -set {00000000-0000-0000-0000-000000000001} osdevice ramdisk=[C:]\WINPE\WINPE.WIM,{ramdiskoptions}bcdedit -set {00000000-0000-0000-0000-000000000001} systemroot \WINDOWSbcdedit -set {00000000-0000-0000-0000-000000000001} winpe yesbcdedit -set {00000000-0000-0000-0000-000000000001} detecthal yesbcdedit -set {00000000-0000-0000-0000-000000000001} advancedoptions nobcdedit -displayorder {00000000-0000-0000-0000-000000000001} -addlastIt 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.
benjt Posted June 19, 2009 Posted June 19, 2009 Thanks for the info but unfortunately I need a solution that is completely automated. I won't be doing the installs.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now