HDD Overview


Created: 28.09.2020

In this article I’m going to give a general overview of how HDDs work.

Floppy

Floppy disks πŸ’Ύ are like dinosaurs πŸ¦•. They are ancient, not usually used nowadays. But the mechanism is very much like the one found in an HDD that’s why I’ve found it useful to start the intro to HDD from a simplier mechanism. In the square brackerts I’ll be giving an analogy with a person reading a book (inspired by takeupcode.com).

Computer (a man πŸ‘¨ ) has CPU (🧠 brains), drives (eyes πŸ‘€), RAM (memory) and lot’s of other body parts that are not relevant for this explanation πŸ˜‰. A floppy disk (and any other disk for that matter) is like a book πŸ“˜ , that the CPU can read from and write to. There is a small πŸ’Ώ disk inside it (it had to be called “a disk” for a reason). It’s covered with magnetized materials from both sides. When there is magnetic field detected at some location on the disk, CPU understands, that the bit is set. In human terms, it’s a 1. When there is no magnetic field, CPU interprets it that the bit is not set and in human terms, it means it’s 0. So that the whole surface of a floppy is a bunch of 1s and 0s for the CPU (to be more precise, we call it 1 and 0, CPU only “thinks” in terms of “is magnetic field” or “is signal” and no “magnetic field” and “no signal”).

Floppy disks are read by special devices that are called floppy drives. Well, that was when there WERE floppies in use, of course. These devices have heads (which are used almoust for the same purpose as humans’ eyes in their heads) that are used to look for something and pass that information to CPU (brains 🧠). A head is simpy a sensor which gets attached from both sides of that disk when it’s inserted into PC. It can “feel” whether there is or there is no magnetic charge in a particular location on the disk’s surface. This drive has two heads for both surfaces of a disk: one below and one above. They always move to the same locations: wherever the first goes, the second follows along. So, just to stress: they always point to the same location but one -from above, and another from below.

HDD

HDDs are like floppy disks, but they consist of many disks instead of one. Since there are more than one disk, there are more than two heads as well. For each disk there are two head: from above and from below. And they move synchronously just like in a floppy πŸ’Ύ.

tree-hdd In the above picture there can be seen circles that form a tree’s trunk. Everyone knows that when a tree gets older, it gets new circles on its trunk. If we cut this trunk into, say, 10 platters and stack them up agains, it will resemble an HDD’s intestines. Of course, an HDD does not get new circles with age, but still it has circles. These circles are called tracks. Each platter (disk inside HDD) has lots of tracks on the upper surface and the lower. Let’s take the second circle for the example’s sake. If we combine all the second circles from each platter, we will get a cylinder. If we were to isolate one cylinder from the HDD, it would be a hollow thing, like a bin.

Say, we have 10 platters in HDD and 30 tracks on each surface of each platter. Then, we have 30 cylinders in total and 20 heads (two for each platter). All 20 heads move synchronously to the same locations of the platter that they are serving to. Since the heads are moving to the same locations on different disks (same sectors), the data is written to a cylinder ❗not a track. Here at the end of the page is good demostration.

Now, what’s a sector? It’s the smallest unit of storage on one platter. It’s usually 512 bytes, but there are certain types of disk that have extended sector size. A cluster constitutes a group of sectors, which are used to❗️ allocate the data storage area. They are written during high-level formatting. Can be set by user or OS. Cluster size varies with the size of the disk itself. The most common - 8 sectors. Cluster numbering starts at 1 (not 0). They are relative to the partition or volume, they are the smallest allocable units. When you save a file 1,5 clusters in size, it will actually occupy 2 clusters. The left-over space is the slack space, very useful when carving data and in forensic investigations.

Sectors are defined by the disk manufacturer and cannot be changed by OS tools. The smallest readable and writable unit on disk. Sector numbering starts at 0. Physical numbering starts from the disk start, logical - from the volume start.

A sector is usually 512 bytes long. Also, there are typically 1-63 sectors.

Unpartitioned space is the disk space prior to the logical volume. It’s. going to be relative to the physical disk, addressed in sectors. Mater boot record is usually there, boot code, partition tables (GPT, MBR). No cluster addressing there❗️.

Let’s write “Hello, world!” to an HDD, to the outer cylinder. All the 20 heads of the HDD move to the outer cylinder. The first head writes H, the second - e. So, the upper platter has He on the outer track (H on the upper surface and e on the lower one). The third and the fourth head (the second platter) both write l to both sides of the platter. And so on until we get to !.

nested-cylinders-hdd

CHS vs LBA

CHS. To locate information, you need to know the cylinder, head, sector. Cylinder specifies the track on each platter of the disk. The head specifies: upper or lower surface of that disk. And the sector specifies the location on the plate’s surface. If I draw a simple analogy with a book (as was suggested by takeupcode.com), then I would remember a game I used to play when I was little.

You make a wish or ask a question. Then you take any book and say outload, which line and which word is going to answer your question. Then, you open the book on a random page and search for the line you named and then for the word. The same principle is here. Hard drive searches for the cylinder (double-page spread), then choses even or uneven page number (head) and then searches for a specific sector (line and word on the page).

Was limited to 8.2Gb. Relative to the physical structure of the disk. No longer used.

LBA. It’s just like page numbering in a book: sequencially from the very first one to the end. A particular LBA number can be mapped to a specific cylinder, head, and sector, but now we operate on a higher layer of abstarction, not bothering with sectors, head and cylinders. LBA parameter on the disk label shows the number of sectors on this disk. In this case in order to get the disk size we would use the formula: LBA x sector_size = total_bytes.

References

[1] Types of addressing

[2] HDD animation

[3] Victoria HDD/SDD articles