Hello (sorry for long post),
We build servers using ghost, we have a standard generalized image we apply using ghost and sysprep. The image has 4 partitions, C, D, E, and a hidden partition (F if unhidden). The hidden partition has a WinPE environment that we use to re-image C & D in the event of a problem with the system. We used bcdedit to setup a dual boot to OS (2016 standard) or WinPE (64bit) for a factory restore.
Important note-when this was originally setup (the dual boot part), the WinPE partition had to be unhidden in order to set the ramdisk up in bcdedit (or the commands would fail). Once it was setup, the partition could be hidden again and it would boot fine into either OS or WinPE. The hidden partition contains a syspreped/generalized image of C, and an image of D. We call the reset process a "Factory Restore" and it shows that way in the boot menu. There is an autoit utility (.exe) that runs if a user boots into the Factory Restore partition that is launched via startnet.cmd in WinPE, which launches ghost and drops the image of C & D onto the HD.
The factory restore works perfectly the first time it is run. The system behaves identically after being restored as it does after being imaged the first time (sysprep runs, apps are installed, etc). The dual boot menu is still there after a reset. However, after that initial factory reset, the system will no longer boot to the WinPe environment when selected, the bootloader complains (a device does not exist). Upon investigation, the BCD appears to be hosed for the ramdisk entries. The GUID is still there, but it shows "unknown" instead of the F: partition for device and osdevice. I can (and have) manually fix the device and osdevice options so that they look exactly like they do on a system that has NOT been reset, but it still says it can't access the device when trying to boot to the WinPE environment.
I have two goals, to understand why it is breaking in the first place and to be able to either avoid the problem by doing something different or correct it programmatically as part of the Factory Restore process.
We don't do anything to the F partition during the Factory Restore, so I'm sure the WinPE stuff is there and should work fine. Since we are restoring an image of C as part of this process, and that has the BCD store on it, I'm wondering if I can move the BCD store to E: instead (which isn't touched as part of the restore process) if that would prevent the problem in the first place?
What I don't understand is that the BCD info looks the same on a system that has been reset and one that hasn't, so it doesn't appear to be getting lost. The only difference I can see is that the partition shows 'unknown' instead of F: in the entry for device and osdevice. I was sure that if I fixed those two entries, it would work...but it doesn't. Same error.
I've posted here because I downloaded Visual BCD to see if I could determine what was wrong (rather than to fix it using the GUI). I have to be able to fix this via command line if I'm going to repair the BCD during the process (it has to be automated along with the restore). I'm hoping there are people here with sufficient knowledge to assist. There is limited info about BCD in general, and just about none about ramdisk.
What i have tried so far:
During the reset, after C & D images have been loaded, a batch file fixes 'unknown' and puts back to [F:] using bcdedt set {GUID} device ....I have tried this manually as well, same result
I have tried with F hidden and unhidden
instead of specifying the device and osdevice path as F:, i've tried [\DeviceHarddiskVolume4]\sources\boot.wim
I have a system in the 'bad state', so I'm trying to get it to work and then automate the steps. So far, I can't get it to work. Deleting and creating a new entry is problematic, as the GUID that gets generated is unique and would be required to input back into commands (ie I would need to capture the output into a variable and give it back in subsequent commands). I don't see why I should have to delete and recreate, I should be able to fix.
Appreciate any help/insight/suggestions.
Thanks,
Steve