Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell which disk Windows Used to Boot

Tags:

windows

mbr

I'm need to find a method to programmatically determine which disk drive Windows is using to boot. In other words, I need a way from Windows to determine which drive the BIOS is using to boot the whole system.

Does Windows expose an interface to discover this? With how big the Windows API is, I'm hoping there is something buried in there that might do the trick.

Terry

p.s. Just reading the first sectors of the hard disk isn't reveling anything. On my dev box I have two hard disks, and when I look at the contents of the first couple of sectors on either of the hard disks I have a standard boiler plate MBR.

Edit to clarify a few things. The way I want to identify the device is with a string which will identify a physical disk drive (as opposed to a logical disk drive). Physical disk drives are of the form "\\.\PHYSICALDRIVEx" where x is a number. On the other hand, a logical drive is identified by a string of the form, "\\.\x" where x is a drive letter.

Edit to discuss a few of the ideas that were thrown out. Knowing which logical volume Windows used to boot doesn't help me here. Here is the reason. Assume that C: is using a mirrored RAID setup. Now, that means we have at least two physical drives. Now, I get the mapping from Logical Drive to Physical Drive and I discover that there are two physical drives used by that volume. Which one did Windows use to boot? Of course, this is assuming that the physical drive Windows used to boot is the same physical drive that contains the MBR.

like image 378
Terry Avatar asked Sep 02 '08 19:09

Terry


People also ask

How do you know from which drive window is booting?

Press Windows + R to bring up the Run command box. Type in the command msconfig and press Enter , This will bring up system configuration settings. Click on the 'Boot' tab.

Which drive is the boot drive?

The most commonly used boot device or boot drive is the hard drive. When an operating system (e.g., Microsoft Windows) is installed on the hard drive, it copies the boot files and drivers required to load Windows on the computer.


1 Answers

Unless C: is not the drive that windows booted from.
Parse the %SystemRoot% variable, it contains the location of the windows folder (i.e. c:\windows).

like image 71
UnkwnTech Avatar answered Oct 06 '22 15:10

UnkwnTech