Learn

As data is the cornerstone of how a computer operates, discussing its physical representation is crucial to best understanding it. What does it look like in the real world when a file is saved onto a hard drive?

For this discussion we will focus mainly on the spinning metal hard disc drive, as most of the design choices for filesystems were based on their inclusion and they are still the most prevalent form of data storage, especially in servers.

Within a hard disk drive is a spinning platter with a thin magnetic coating. A pointy head that looks like a thin fountain pen moves over this platter to etch data into the platter by adjusting the direction of the magnetic field at an incredibly precise location.

The smallest chunk of this physical storage is called a sector. It is the smallest unit of storage for the physical drive and its size is determined by a balance between excessive metadata and wasting space.

Smaller sectors require more information to index the entire drive, like a librarian trying to organize millions of small pamphlets. This ruins performance for finding files as well as creates substantial overhead for documenting the location and content of each sector.

However, larger sector sizes also have drawbacks. For example, if saving a file that has a size of 512 bytes and the sector size is 4096 bytes, the entire sector is written and used, effectively wasting 3584 bytes of space.

This is abstracted further in the software filesystem, where blocks are used to represent groupings of sectors. This is used as an abstraction so that the operating system and all of the applications that reside on it can have a common block size to target instead of needing to accommodate whatever arbitrary sector size is chosen by the hardware manufacturer.

Instructions

In the image on the right, a sector is shown as a small region on a hard disk drive, while a block is a collection multiple such sectors.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?