Using bcdedit on Windows from Recovery Mode

Usually when you cannot get windows to boot up properly, it is worth trying safe mode. However, sometimes getting to safe mode is a bit tricky, such as when windows fails to boot even before you have the option to go to safe mode.

In hindsight, the odds of safe mode fixing such a problem are probably pretty small to begin with, because it presumably isn’t driver or startup program related and it is usually something else such as file corruption. But I wasn’t going to let that stop me.

I knew from similar problems in the past that the bcdedit command can be used to alter the windows boot menu and the boot options for each entry, including a safe mode option. Unfortunately, you kind of need windows booted to run commands. Foiled again.

The answer, in this case, is to boot to the recovery environment instead. I couldn’t boot to recovery on the existing windows installation, but you can also boot to recovery mode using windows install media such as a disc or flash drive. So I did. Once you are in recovery mode, you can then open a command prompt.

Then, run bcdedit. By default it will automatically find the boot configuration data and display each of the boot entries and their respective options.

You can then set the safe mode option like so:

bcdedit /set {default} safeboot network

{default}, in this case, is the actual name of the boot entry. Our possible options are {bootmgr} and {default}. Safeboot is the option name and network is the safeboot mode. There are other possible safeboot modes, such as booting without networking or booting to a command prompt.

When you run bcdedit again, you can see that the safeboot option has been added to the {default} boot entry. Upon restart, windows will boot in safe mode. Tada, problem solved.

That is the easy way to do it.

The Hard Way

Unfortunately, when I first encountered this problem I got this message when running bcdedit:

The boot configuration data store could not be opened. The requested system device cannot be found.

In other words, the command failed to automagically find the boot configuration data store. I have noticed similar problems when running other commands in recovery mode. Notice that when you open the command prompt, you are actually on the X: drive, not the C: drive. I suspect the root cause of the problem is related to this – the windows boot drive is effectively the recovery environment rather than your existing windows installation.

What we need to do in this case is tell bcdedit where the boot configuration data store is using the /store option. But where is the boot configuration data store?

According to MSDN, the file is located at \Boot\Bcd. Notably, the drive it is on can vary. If your windows installation uses legacy BIOS, then it is on your main windows partition, usually labeled C:. However, if you have a UEFI windows installation, it is located on your EFI system partition. The EFI system partition doesn’t have a drive letter by default. You know, because you wouldn’t want those pesky kids mucking around in there making a mess.

EDIT: It seems I may have been a bit mistaken about the file paths. It may be that, when using a BIOS installation, it is located on the boot partition, which probably isn’t the actual windows partition. More specifically, the boot partition is going to be smaller, like volume 1 in the picture below. MSDN uses the term “active partition”, which means the partition booted to by the MBR bootstrap, and in the case of windows that would be the system partition.

As far as UEFI systems go, I tried this on one recently and found the file on [letter]:\EFI\Microsoft\Boot\Bcd, where letter represents the UEFI system partition – a small partition, again.

How do you access files on a drive without a drive letter? You give it a drive letter, of course. This can be done using diskpart.

In any case, once you find the file you can run bcdedit /store <file-path> <all the other options here>. You need to include the /store option every time you run the command for it to work correctly. You can then proceed to set safemode as shown before. Restart and windows should boot into safe mode. Problem solved, hopefully.

 


I previously thought that using bcdedit from recovery mode always resulted in the “hard way,” where you have to find the boot configuration data file and use the /store option. Apparently, that isn’t the case. I discovered this in the process of writing this post, as I used a virtual machine to retrace my steps. Everything worked out of the box and I didn’t encounter the same problem. Oh well.

 

 

Jacob Clarity

 

One thought on “Using bcdedit on Windows from Recovery Mode

  1. I got this error “The boot configuration data store could not be opened. The requested system device cannot be found.” when the HDD was disabled for booting in BIOS. After I set it as bootable, the error disappeared and I could edit and see the boot manager data store.

Leave a Reply