Vijaydidmca1234
Vijaydidmca1234

Reputation: 59

Where does operating system gets located into hard disk

When we install operating system into hard disk, then where does it located into hard disk. Is it a predetermine certain location or the OS gets located in any arbitrary location. How does boot sector finds and loads OS into RAM, so that execution begins normally.

Upvotes: 0

Views: 380

Answers (1)

Alain Merigot
Alain Merigot

Reputation: 11557

How does boot sector finds and loads OS into RAM, so that execution begins normally.

When a processor boots, it starts executing code at a given location in the BIOS. This code contains safety check (power on self test), then it reads at some location in the memory to routines to know from which device it will boot, and it reads from this "disk" the first sector (512 bytes).

This sector is called the "master boot record", and it contains some code (~440 bytes on a PC), and the description of the disk partitions. The actual code depends on the underlying OS. On windows, it mainly describes which is the "active partition" on which the system can be found. On linux, there is a more complex code executed by bootloaders as grub in order to boot different systems, but it ends by getting the number of the partition where the system is located. This is frequently called "first stage" of the boot process.

Then, once the system partition is identified, one read the boot sector (first 512 bytes) of this partition ("second stage"). Code of this boot loader contains a simplified OS that has means to read a disk content with respect to the OS filesystem. This way, it can read files from the disk. In general, there is a configuration file (grub.conf for grub or boot.ini in windows) that gives directives and filename of the system to load.

So, the bootloader reads the configuration file, locates the file that contains the operating system, reads it from disk and loads it in memory. Then the processor can the start executing the system.

When we install operating system into hard disk, then where does it located into hard disk. Is it a predetermine certain location or the OS gets located in any arbitrary location.

As you can see, the system is located on the disk in a more or less arbitrary location, but there are programs at fixed locations (boot sector of the disk and of its partitions) that are used to read the disk and access the system. You can find more details in for instance https://en.wikipedia.org/wiki/Booting.

Upvotes: 1

Related Questions