NTLDR is typically run from the primary storage device, but it can also run from portable storage devices such as a CD-ROM, USB flash drive, or floppy disk. NTLDR can also load a non NT-based operating system given the appropriate boot sector in a file.
NTLDR requires, at a minimum, the following two files to be on the system volume:
ntldr, the main boot loader itself
NTDETECT.COM, required for booting an NT-based OS, detects basic hardware information needed for successful boot
An additional important file is boot.ini, which contains boot configuration (if missing, NTLDR will default to \Windows on the first partition of the first hard drive). On non-English versions of NTLDR, it may also load bootfont.bin; this is not the case for BOOTMGR.
NTLDR is launched by the volume boot record of system partition, which is typically written to the disk by the Windows FORMAT or SYS command.
History
Windows NT was originally designed for Advanced RISC Computing (ARC) platforms, relying on its boot manager support and providing only osloader.exe, a loading program accepting ordinary command-line arguments specifying Windows directory partition, location or boot parameters, which is launched by an ARC-compatible boot manager when a user chooses to start a specific Windows NT operating system. However, because IBM PC compatible machines lacked any kind of ARC support (as they predate the creation of the ARC specification), an additional layer was added specifically for that platform: a custom boot manager code presenting a text-based menu allowing the user to choose from one or more operating systems and its options configured in a boot.ini configuration file, prepended by a special StartUp module which is responsible for some preparations such as switching the CPU to protected mode.
When a user chooses an operating system from the boot menu, the following command-line arguments are then passed to the part of the osloader.exe common to all processor architectures:
In Windows releases starting from Windows Vista and Windows Server 2008, NTLDR was split off into two parts: Windows Boot Manager for the boot manager and winload.exe for the system loader. The boot manager part has been completely rewritten; it no longer uses boot.ini as a configuration file, although the bootcfg utility for modifying boot.ini is still present in the case of multi-boot configurations with Windows versions up to Windows XP and Windows Server 2003.
The bootsect.exe utility program in the Windows PE tools has options (/nt52 (NTLDR) and /nt60 (Vista and up)) to store a NTLDR or Vista boot record in the first sector of a specified partition.[1] The command can be used for FAT and NTFS based file systems. It replaces the FixFAT and FixNTFS tools.[2]
Example
The following example applies the NTLDR compatible master boot code to the D: volume:[2]
When a PC is powered on its BIOS follows the configured boot order to find a bootable device. This can be a harddisk, floppy, CD/DVD, network connection, USB-device, etc. depending on the BIOS. In the case of a floppy the BIOS interprets its boot sector (first sector) as code, for NTLDR this could be a NTLDR boot sector looking for the ntldr file on the floppy. For a harddisk the code in the Master Boot Record (first sector) determines the active partition. The code in the boot sector of the active partition could then be again a NTLDR boot sector looking for ntldr in the root directory of this active partition. In a more convoluted scenario the active partition can contain a Vista boot sector for the newer Vista boot manager with an {ntldr} entry pointing to another partition with a NTLDR boot sector.[3]
When booting, the loader portion of NTLDR does the following in order:
Accesses the file system on the boot drive (either FAT or New Technology File System, NTFS).
If Windows was put in the hibernation state, the contents of hiberfil.sys are loaded into memory and the system resumes where it left off.
Otherwise, reads boot.ini and prompts the user with the boot menu accordingly.
If a non NT-based OS is selected, NTLDR loads the associated file listed in boot.ini (bootsect.dos if no file is specified or if the user is booting into a DOS based OS) and gives it control.
If an NT-based OS is selected, NTLDR runs ntdetect.com, which gathers information about the computer's hardware. (If ntdetect.com hangs during hardware detection, there is a debug version called ntdetect.chk that can be found on Microsoft support.[4])
Starts ntoskrnl.exe, passing to it the information returned by ntdetect.com.[5]
boot.ini
NTLDR's first action is to read the boot.ini file.[6] It allows the user to choose which operating system to boot from at the menu. For NT and NT-based operating systems, it also allows the user to pass preconfigured options to the kernel. The menu options are stored in boot.ini, which itself is located in the root of the same disk as NTLDR. Though NTLDR can boot DOS and non-NT versions of Windows, boot.ini cannot configure their boot options.
For NT-based OSs, the location of the operating system is written as an ARC path. bootsect.dos is the boot sector loaded by NTLDR to load DOS, or if there is no file specified when loading a non NT-based OS.
boot.ini is protected from user configuration by having the following file attributes: system, hidden, read-only. To manually edit it, the user would first have to remove these attributes. A more secure fashion to edit the file is to use the bootcfg command from a console. bootcfg will also relock the file (setting the file back to system, hidden, and read-only). Additionally, the file can be edited within Windows using a text editor if the folder view option "Show hidden files and folders" is selected, the folder view option "Hide protected operating system files" is unchecked, and the "Read-only" option is unchecked under the file's properties. Extreme caution should be taken when modifying boot.ini, as erroneous information can result in an OS that fails to boot.
Example
An example of a boot.ini file, extracted from a working Windows XP Professional installation:
[boot loader]timeout=30default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS[operating systems]multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional"/fastdetect
Note: If the boot loader timeout option in boot.ini is set to 0, the NTLDR boot menu does not appear. This happens especially on multi-booted systems; the boot menu also does not appear when only one operating system is installed, like the example above, even if the timeout option is set into any other value other than 0.
NT kernel switches
Advanced Option Menu in NTLDR on Windows XP
Note: Unless otherwise stated, the following kernel switches apply to both Windows XP and Windows Server 2003 as well as prior versions of Windows NT.
/3GB– Option used only on 32-bit x86-based systems that allocates 3GB for the user-mode address space and 1GB for the system-mode (or kernel-mode) address space (more than that of the 2GB allocation used for both user-mode and system/kernel-mode address spaces). It is intended for programs that can take advantage of the additional memory address space, such as certain Windows Server 2003 and Microsoft Exchange Server 2003 configurations.[7][8] Activating this option however may break VMR-9 video;[9] it may also cause audio problems with certain Sound Blaster X-Fi sound cards (X-Fi Gamer / X-Fi Titanium @ WINXP 32-bit 3/2012) due to the way that Creative's drivers handle memory over 2GB.[10][11]
/BASEVIDEO– Starts Windows in "VGA mode", where a VGA-compatible display driver is used with a 16-color, 640 × 480 resolution.[8] This can be used to recover from configuration problems with certain display drivers; the /SOS switch can be used in conjunction with the /BASEVIDEO switch to help diagnose display driver failures on startup (this is the case for Windows NT 4.0 for the "VGA mode" option in the boot menu, which has both /BASEVIDEO and /SOS switches enabled).[7]
/BAUDRATE=nnn– Specifies the baud rate for the debug port used by the kernel debugger, overriding the default value (9600–19200Kbps with a modem and 115200Kbps with a null modem). Enabling this option under boot.ini automatically enables kernel debugging with the /DEBUG switch.[7][8]
/BOOTLOG– Writes a log of the boot process to the file %SystemRoot%\Ntbtlog.txt for diagnostic purposes.[7][8] It is set by default for certain Safe Mode options.
/BOOTLOGO– Displays a custom 640 × 480 16-color bitmap instead of the default graphical boot screen on startup. This file is located in %SystemRoot%\Windows and is named boot.bmp. It is used in conjunction with the /NOGUIBOOT switch; the custom bitmap will not display properly without it.[8]
/BURNMEMORY=nnn– Decreases the amount of memory that Windows can use (e.g. /BURNMEMORY=128 on a system using 512MB of memory would take out 128MB of memory from within Windows, making it only use 384MB of memory).[7][8]
/CHANNEL=nn– Used when debugging through the IEEE 1394 port (using /DEBUGPORT=1394), to specify channels where the kernel debugger can communicate with.[7][8]
/CLKLVL– Sets the HAL to use level-sensitive clocks settings rather than edge-triggered clock settings for hardware interrupts.[8]
/CRASHDEBUG– Loads the kernel debugger on startup, to be used when the system crashes.[8]
/DEBUG– Enables debugging at the kernel level.[7][8]
/DEBUGPORT=comx– Specifies a port used for kernel-mode debugging. Supports serial and (in Windows XP and Windows Server 2003 only) IEEE 1394 ports for use with debugging.[8][7]
/FASTDETECT[:comx[,comy]]– Disables serial and bus mouse detection in NTDETECT.COM. Otherwise serial and bus mouse detections are performed if the /FASTDETECT switch is excluded. Set by default on Windows 2000 onwards.[7][8]
/INTAFFINITY– Makes the HAL set hardware interrupts to only the highest numbered processor on multiprocessor systems.[8]
/KERNEL=filename– Sets a different kernel image to use.[8][7]
/MAXMEM=nnn– Sets the maximum amount of memory that Windows can use (e.g. /MAXMEM=64 makes Windows use 64MB of memory even if the computer has 512MB or more memory). /MAXMEM does not account for memory leaks; /BURNMEMORY is recommended for those use cases instead.[7]
/MININT– Option used for Windows PE. Changes the HKLM\SYSTEM key in the Windows Registry to be non-persistent so that any changes made to the key are not saved when the system shuts down.[8]
/NODEBUG– Disables debugging at the kernel level.[7]
/NOEXECUTE={OPTIN|OPTOUT|ALWAYSON|ALWAYSOFF}– Sets Data Execution Prevention (DEP) settings, applies to 32-bit and 64-bit CPUs with the NX bit.[8]
/NOEXECUTE=OPTIN– Enables DEP for core system images and those specified in the DEP configuration dialog.
/NOEXECUTE=OPTOUT– Enables DEP for all images except those specified in the DEP configuration dialog.
/NOEXECUTE=ALWAYSON– Enables DEP on all images.
/NOEXECUTE=ALWAYSOFF– Disables DEP.
/NOGUIBOOT– Disables the graphical boot screen on startup, only displaying device driver names as they are loaded, similar to /SOS. It can be used in conjunction with /BASEVIDEO to diagnose device driver failures on startup.[7][8] It is set by default for certain Safe Mode options.
/NOSERIALMICE[=comx]– Disables serial mouse detection in NTDETECT.COM. Otherwise serial mouse detections are performed if the /NOSERIALMICE switch is excluded. Replaced with /FASTDETECT on Windows 2000 onwards.[8]
/NUMPROC=nnn– Specifies the number of processors used in a multiprocessor system (e.g. /NUMPROC=2 on a four-way system causes Windows to use only two processors instead of all four). Can be used to troubleshoot performance issues and defective CPUs.[8][7]
/ONECPU– Makes Windows use only one processor in a multiprocessor system, similar to that of /NUMPROC=1.[8]
Safe Mode (/SAFEBOOT:MINIMAL /SOS /BOOTLOG /NOGUIBOOT) – Default: Uses a minimal set of device drivers and services to start Windows.[12]
Safe Mode with Networking (/SAFEBOOT:NETWORK /SOS /BOOTLOG /NOGUIBOOT) – Default mode together with the drivers necessary to load networking.[12]
Safe Mode with Command Prompt (/SAFEBOOT:MINIMAL(ALTERNATESHELL) /SOS /BOOTLOG /NOGUIBOOT) – Default mode, except that Cmd.exe starts instead of Windows Explorer.[12]
Windows in Directory Services Restore Mode (/SAFEBOOT:DSREPAIR /SOS) – (This mode is valid only for Windows-based domain controllers.) Performs a directory service repair.[12]
/SDIBOOT– Option used for Windows XP Embedded. Allows booting a RAM image from a System Disk Image (SDI) file.[7][8]
/SOS– Displays device driver names on startup. Also changes the graphical boot screen to the one seen when CHKDSK is run on startup (Autochk) in Windows 2000 onwards, showing operating system information in a similar manner to Windows NT 4.0.[7][8] Can be used in conjunction with the /BASEVIDEO switch to help diagnose display driver failures on startup (this is the case for Windows NT 4.0 for the "VGA mode" option in the boot menu, which has both /BASEVIDEO and /SOS switches enabled). It is set by default for certain Safe Mode options.
/TIMERES– Sets the system timer resolution for the HAL.[8]
/USEPMTIMER– Specifies that Windows uses the Power Management Timer (PM_TIMER) timer settings instead of the Time Stamp Counter (TSC) timer settings if the processor supports the PM_TIMER settings.[7] By default, Windows Server 2003 Service Pack 2 (SP2) uses the PM timer for all multiprocessor APIC or ACPI HALs. /USEPMTIMER must be enabled for Windows Server 2003 Service Pack 1 (SP1) and below.[13]
/USERVA=nnn– Option used only on 32-bit x86-based systems that allows applications to be given a larger address space specified by the user, similar to the /3GB switch. The aforementioned switch is mandatory when using the /USERVA switch.[8][12]
/WIN95– Allows booting of non-NT versions of Windows (e.g. Windows 9x) using BOOTSECT.W40.[8]
/WIN95DOS– Allows booting of DOS or non-NT versions of Windows (e.g. Windows 9x) using BOOTSECT.DOS.[8]
/YEAR=yyyy– Overrides the year set by the computer's clock settings (e.g. /YEAR=2000 sets the year to 2000 within Windows, even if the year is set to 1999 within the computer's clock settings). Was used for testing Y2K compliance.[8]
This page is based on this Wikipedia article Text is available under the CC BY-SA 4.0 license; additional terms may apply. Images, videos and audio are available under their respective licenses.