Hardware and software setup

Storing information on hard drives

Storing information on hard drives

Part 1

1. Introduction

Most users, answering the question of what is in their system unit, among other things, mention the hard drive. Winchester is the device on which your data is most often stored. There is a legend explaining why hard drives have such a fancy name. The first hard drive, released in America in the early 70s, had a capacity of 30 MB of information on each work surface. At the same time, the O. F. Winchester magazine rifle, widely known in the same America, had a caliber of 0.30; maybe the first hard drive rumbled during its work like an automatic machine or it smelled of gunpowder - I don’t know, but since then hard drives have been called hard drives.

Failures occur during the operation of the computer. Viruses, power outages, software errors - all this can cause damage to the information stored on your hard drive. Damage to information does not always mean loss of it, so it is useful to know how it is stored on the hard drive, because then it can be restored. Then, for example, if the boot area is damaged by a virus, it is not at all necessary to format the entire disk (!), but, after restoring the damaged area, continue normal work with the preservation of all your priceless data.

On the one hand, in the process of writing this article, I set myself the task of telling you:

  1. about the principles of recording information on a hard disk;
  2. on the placement and loading of the operating system;
  3. about how to competently divide your new hard drive into sections in order to use several operating systems.

On the other hand, I want to prepare the reader for the second article, in which I will talk about programs called boot managers. In order to understand how these programs work, you need to have a basic knowledge of things like MBR, Partitions, etc.

Enough general words - let's get started.

2. Hard disk device

A hard disk (HDD - Hard Disk Drive) is arranged as follows: on a spindle connected to an electric motor, there is a block of several disks (pancakes), above the surface of which there are heads for reading / writing information. The shape of the heads is given in the form of a wing and they are attached to a crescent-shaped leash. During operation, they "fly" above the surface of the disks in the air flow, which is created during the rotation of the same disks. Obviously, the lifting force depends on the air pressure on the heads. It, in turn, depends on the external atmospheric pressure. Therefore, some manufacturers indicate the maximum operating ceiling in the specifications for their devices (for example, 3000 m). Why not a plane? The disc is divided into tracks (or tracks), which in turn are divided into sectors. Two tracks equidistant from the center, but located on opposite sides of the disk, are called cylinders.

3. Information storage

A hard drive, like any other block device, stores information in fixed portions called blocks. A block is the smallest piece of data that has a unique address on the hard disk. In order to read or write the right information to the right place, it is necessary to present the block address as a parameter of the command issued to the hard disk controller. The block size has been the standard for all hard drives for quite a long time - 512 bytes.

Unfortunately, quite often there is confusion between such concepts as "sector", "cluster" and "block". In fact, there is no difference between a "block" and a "sector". True, one concept is logical, and the second is topological. A "cluster" is a number of sectors considered by the operating system as one. Why didn't they abandon simple work with sectors? I will answer. The transition to clusters happened because the size of the FAT table was limited, and the size of the disk increased. In the case of FAT16, for a 512 MB disk, the cluster will be 8 KB, up to 1 GB - 16 KB, up to 2 GB - 32 KB, and so on.

In order to uniquely address a data block, all three numbers must be specified (cylinder number, sector number on the track, head number). This method of disk addressing was widely used and was subsequently designated by the abbreviation CHS (cylinder, head, sector). It was this method that was originally implemented in the BIOS, so subsequently there were restrictions associated with it. The fact is that the BIOS has defined a bit grid of addresses into 63 sectors, 1024 cylinders and 255 heads. However, the development of hard drives at that time was limited to the use of only 16 heads due to the complexity of manufacturing. Hence the first limitation on the maximum addressable capacity of a hard disk appeared: 1024×16×63×512 = 504 MB.

Over time, manufacturers began to make larger HDDs. Accordingly, the number of cylinders on them exceeded 1024, the maximum allowable number of cylinders (from the point of view of older BIOSes). However, the addressable part of the disk continued to be 504 MB, provided that the disk was accessed using the BIOS. This limitation was removed over time by the introduction of the so-called address translation mechanism, which is discussed below.

Problems that arose with the limitation of the BIOS in terms of the physical geometry of disks eventually led to the emergence of a new way of addressing blocks on a disk. This method is quite simple. Blocks on the disk are described by one parameter - the linear address of the block. Disk addressing linearly received the abbreviation LBA (logical block addressing). The linear address of a block is uniquely related to its CHS address:

lba = (cyl*HEADS + head)*SECTORS + (sector-1);

The introduction of linear addressing support in hard disk controllers made it possible for the BIOS to take up address translation. The essence of this method is that if you increase the HEADS parameter in the above formula, then fewer cylinders will be required to address the same number of disk blocks. But on the other hand more heads will be needed. However, only 16 out of 255 heads were used. Therefore, the BIOS "s began to transfer excess cylinders into heads, reducing the number of some and increasing the number of others. This allowed them to use the entire bit grid of heads. This pushed the limit of the disk space addressed by the BIOS to 8 GB.

It is impossible not to say a few words about Large Mode. This mode of operation is designed to operate hard drives up to 1 GB. In Large Mode, the number of logical heads is increased to 32, and the number of logical cylinders is halved. In this case, accesses to logical heads 0..F are translated into even physical cylinders, and accesses to heads 10..1F are translated into odd ones. A hard drive marked in LBA mode is incompatible with Large mode, and vice versa.

A further increase in the addressable volumes of a disk using the old BIOS services has become fundamentally impossible. Indeed, all parameters are used according to the maximum “bar” (63 sectors, 1024 cylinders and 255 heads). Then a new extended BIOS interface was developed, taking into account the possibility of very large block addresses. However, this interface is no longer compatible with the old one, as a result of which old operating systems, such as DOS, which use the old BIOS interfaces, could not and will not be able to overstep the bounds of 8GB. Almost all modern systems no longer use the BIOS "ohm, but use their own drivers for working with disks. Therefore, this restriction does not apply to them. But it should be understood that before the system can use its own driver, it must at least load it. Therefore, on During the boot phase, any system is forced to use the BIOS. This causes restrictions on the placement of many systems beyond 8GB, they cannot boot from there, but they can read and write information (for example, DOS which works with the disk through the BIOS).

4. Sections, or Partitions

Let us now turn to the placement of operating systems on hard drives. To organize systems, the disk address space of blocks is divided into parts called partitions. Partitions are exactly like a whole disk in that they are made up of contiguous blocks. Thanks to this organization, to describe a section, it is enough to indicate the beginning of the section and its length in blocks. A hard drive can contain four primary partitions.

During computer boot, the BIOS loads the first sector of the head partition (boot sector) at 0000h:7C00h and transfers control to it. At the beginning of this sector is the bootloader (boot code) that reads the partition table and determines the bootable partition (active). And then everything repeats. That is, it loads the boot sector of this partition to the same address and again transfers control to it.

Sections are containers for all their content. This content is usually the file system. From a disk point of view, a file system refers to a block layout system for storing files. After the file system is created on the partition and the operating system files are placed on it, the partition can become bootable. The boot partition has in its first block a small program that loads the operating system. However, to boot a specific system, you must explicitly run its boot program from the first block. How this happens will be discussed below.

Partitions with file systems must not overlap. This is because two different file systems each have their own idea of ​​where files are placed, but when that location is in the same physical location on the disk, there is a conflict between the file systems. This conflict does not occur immediately, but only as the files begin to be placed in the place on the disk where the partitions intersect. Therefore, you should be careful about dividing the disk into partitions.

In itself, crossing sections is not dangerous. It is the placement of several file systems on overlapping partitions that is dangerous. Partitioning a disk does not mean creating file systems. However, the very attempt to create an empty file system (that is, formatting) on ​​one of the intersecting partitions can lead to errors in the file system of another partition. All of the above applies equally to all operating systems, not just the most popular ones.

The disk is divided into sections programmatically. That is, you can create an arbitrary partition configuration. Partitioning information is stored in the very first block of the hard drive, called the Master Boot Record (MBR).

5. MBR

The MBR is the main hard drive boot facility supported by the BIOS. For clarity, we present the contents of the boot area in the form of a diagram:

Everything that is located at offset 01BEh-01FDh is called the partition table. You can see that it has four sections. Only one of the four partitions has the right to be marked as active, which will mean that the boot program must load the first sector of this particular partition into memory and transfer control there. The last two bytes of the MBR must contain the number 0xAA55. Based on the presence of this signature, the BIOS verifies that the first block was loaded successfully. This signature was not chosen by chance. A successful check of it allows you to establish that all data lines can transmit both zeros and ones.

The boot program looks through the partition table, selects the active one, loads the first block of this partition and transfers control there.

Let's see how the partition descriptor works:


* 0001h-0003h start of section
** 0005h-0007h end of section

From the point of view of disk partitions, MS-DOS has been and remains the most popular until recently. It takes into its use two of the four partitions: Primary DOS partition, Extended DOS partition. The first one, (primary) is a regular dos C: drive. The second is the logical drive container. They all hang out there in the form of a chain of subsections, which are called like this: D:, E:, ... Logical drives can also have foreign file systems that are different from the DOS file system. However, as a rule, the heterogeneity of the file system is due to the presence of another operating system, which, generally speaking, should be placed on its own partition (not extended DOS), but the partition table is often too small for such antics.

Let us note one more important circumstance. When DOS is installed on a blank hard disk, there are no alternatives in choosing operating systems at boot. Therefore, the bootloader looks very primitive, it does not need to ask the user which system he wants to boot. With the desire to have several systems at once, it becomes necessary to start a program that allows you to select a system to boot.

6. Conclusion

I hope that I have been able to provide you with sufficient clarity and detail about the basic information about the hard disk device, MBR and PT. In my opinion, such a set of knowledge is quite enough for a small "repair" of the information storage. In the next article, I will tell you about programs called Boot Manager and how they work.

Many thanks for the help to Vladimir Dashevsky

Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!