1

Lets say I have a 1 TB hard drive and the computer tells me that 750GB of it is free. How does the computer determine that a particular amount of space on a hard drive is free or otherwise? I ask because for all I know both these kind of spaces are just a bunch of magnetically stored 0s and 1s.

1 Answer 1

5

Filesystem metadata. At the beginning of your disk are a set of invisible files like $MFT, that store information about the directories and files on your system, including information like their name, folder location, permissions, etc. They also contain information about the specific blocks the file occurs in, exactly where it starts, and how long it is. This information is indexed and organized for very fast retrieval.

So your OS can query these small/fast files which describe the files on your disk, and then just add the lengths of all the files together in order to get the total space taken up.

As for the size of the disk, it comes from the Volume Descriptor records in the file $volume which contains information about your partition. subtract total used from total, and you get free.

The mechanics I'm describing are related to the NTFS filesystem, and while filesystem metadata manifests in different ways for different filesystem types, they all have the same general concepts for how to define and describe files on the disk.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .