How to fix:
The drive where Windows is installed is locked. Unlock the drive and try again.
Brief description what caused the error (if not interested skip to Repair steps)
Explaining for novice users - further below VHD is mentioned.
VHD is Virtual Hard Disk and can be regarded as real disk as it has the same logical structure, e.g. partitions, boot sectors e.t.c. and more important - you can install an operating system like Windows on it !
The whole concept of virtualization (virtual processors, virtual disks, virtual machines) is not only interesting but also very practical as home computers are usually powerful enough to run an operating system on top of another.
Installed new version of Ubuntu 12.04 and Virtual Box in dual boot with Windows 7.
Wanted to try if a Windows 8 installation to VHD could be run by Virtual Box on Ubuntu.
Created a new virtual machine with the VHD in question in Virtual Box and started it.
No luck. My processor did not have virtualization capabilities.
So rebooted my computer and selected Windows 8 just to check if the VHD is still intact.
Was greeted with the error message:
"The drive where Windows is installed is locked. Unlock the drive and try again."
Booted my Windows 8 Install USB and started Recovery console.
1) First thing I tried was to check if Windows drive has still a correct disk structure using the command chkdsk.
chkdsk v: /R ( demagged Windows was mounted to drive v: )
Note: The /R option "Locates bad sectors and recovers readable information (implies /F)." The process is pretty long on larger disks. You can use the /F option instead on large disks if you do not want to wait for a more thorough checking.
So the alternative for large disk to the command above is:
chkdsk v: /F
No errors - everything was fine.
The error was showing pretty early before appearance of the "running circle" when booting Windows 8 so the problem was in winload.exe or the very first system files loaded by winload.exe. (Winload.exe is Windows loader for Vista and later versions and is the first file loaded and executed by Windows boot manager after you select to load Vista/7/8 OS from boot-menu.)
After spending some time on several forums it appeared that the error message in question was reported in connection with error code 0xC0000098.
The message for error code 0xC0000098 is
"The volume for a file has been externally altered such that the opened file is no longer valid."
Attaching my Windows 8 VHD to Virtual Box and starting it had as result that some file needed for starting up the system was altered by Virtual Box and left in an inconsistent state.
2) For repairing boot environment files Microsoft delivers the utility bcdboot.
bcdboot is known to fix BCD errors but it also recreates the whole \boot folder, fixes bootmgr and winload.exe (and some other boot related files new in Windows 8)
Executed a simple command:
bcdboot v:\Windows /s v:
(demagged Windows was mapped to drive v:)
When using this command and having several Windows Vista/7/8 installations in dual or multi boot you should always choose the latest Windows version as parameter to the command because from this source (v:\Windows) the system protected boot related files are taken and installed to the system partition (active partition) if no /s parameter is specified.
That was it.
Rebooted and SUCCESS !
There was a small drawback however after using bcdboot - the "Repair your computer" in advanced boot options on F8 key for the repaired loader (and boot menu entry) was missing but that was easy to solve with just two commands on command prompt (from a running Windows 8 VHD system in my case):
And everything was as it was before going into trouble..
It should be mentioned that if a system file needed for starting up the system is tampered the command:
should fix the issue - at least Windows should be able to start in safe mode where you could do more comfortable further investigations what is causing the problem if it still persists.
You can try also offline repair of system files:
sfc /scannow /offbootdir=c:\ /offwindir=d:\windows
- "offbootdir" is the system reserved partition (usually about 100 MB in size) or the active partition on MBR disks
(on UEFI firmware and GPT style disks this is the EFI System partition used for booting)
- "offwindir" is the Windows directory on the drive you would like to fix.
Next would be to check integrity of drivers, anti-virus program (switching it off) and so on the chain of loaded programs.
A start-up with boot logging would also be helpful as it would record the last loaded file at error point.
Hope this helps.