patternMinor
Representation of used space and free space in hard drives
Viewed 0 times
spacefreeusedharddrivesandrepresentation
Problem
I've read from this How data is physically stored in hard drives, that the North/South orientation of the magnetic medium represents data as 0 or 1 physically in the hard drive. Data is stored in binary, which means that it can be stored as either 0 or 1 in the hard drive. But what determines if that particular block of memory in the hard drive is "Used Space" or "Free Space".
In the OS, you can view how much memory is used, and how much is free.
Let's say i have a 1 TB hard drive. I stored 100 GB worth of data with the repeating pattern "1100 1100". This means that I have 100 GB of used space and 900 GB left of free space (does it?). How does it know that it is used or free? If both 1 and 0 can be used to represent the data in that block of memory, then what represents as a "Free Space"? What if i delete 50 GB of data? I'll have 50 GB more free space, but what represents this free space? And how is the data 1 or 0 of "Used Space" converted to "Free Space"?
In the OS, you can view how much memory is used, and how much is free.
Let's say i have a 1 TB hard drive. I stored 100 GB worth of data with the repeating pattern "1100 1100". This means that I have 100 GB of used space and 900 GB left of free space (does it?). How does it know that it is used or free? If both 1 and 0 can be used to represent the data in that block of memory, then what represents as a "Free Space"? What if i delete 50 GB of data? I'll have 50 GB more free space, but what represents this free space? And how is the data 1 or 0 of "Used Space" converted to "Free Space"?
Solution
Free space is a concept at the level of the filesystem, which is part of the operating system. It is up to the filesystem to determine what space is free, and how to exploit it.
Data is stored on the hard drive in a structured way. The filesystem divides the drive into sectors (basic units, usually 512, 1024, 2048, or 4096 bytes), and maintains data structures on the drive which store which sectors are used and which are available. These data structures also store the directory structure of the drive, which sectors comprise which file, file names, and other metadata (such as various file timestamps).
Your experiment, of storing a repeated pattern on the raw drive, doesn't constitute a legitimate use of the drive. The drive is usually used only via a filesystem. The filesystem presents to the user (i.e., the software programmer) a logical view of the hard drive. Physical details such as were different parts of a file are stored are the business of the filesystem rather than of the user (though sometimes the user would like to know more, for example in order to defragment the drive).
The same, by the way, is true for memory, which is maintained by the memory manager, another part of the operating system. The operating system allocated memory to the user, takes care of swapping, stores the memory when hibernating, and so on. On modern CPUs, the user can't just use unallocated memory - this will trigger an exception. The supporting data structures are perhaps more lightweight, but there is still an infrastructure supporting memory allocation and deallocation.
Data is stored on the hard drive in a structured way. The filesystem divides the drive into sectors (basic units, usually 512, 1024, 2048, or 4096 bytes), and maintains data structures on the drive which store which sectors are used and which are available. These data structures also store the directory structure of the drive, which sectors comprise which file, file names, and other metadata (such as various file timestamps).
Your experiment, of storing a repeated pattern on the raw drive, doesn't constitute a legitimate use of the drive. The drive is usually used only via a filesystem. The filesystem presents to the user (i.e., the software programmer) a logical view of the hard drive. Physical details such as were different parts of a file are stored are the business of the filesystem rather than of the user (though sometimes the user would like to know more, for example in order to defragment the drive).
The same, by the way, is true for memory, which is maintained by the memory manager, another part of the operating system. The operating system allocated memory to the user, takes care of swapping, stores the memory when hibernating, and so on. On modern CPUs, the user can't just use unallocated memory - this will trigger an exception. The supporting data structures are perhaps more lightweight, but there is still an infrastructure supporting memory allocation and deallocation.
Context
StackExchange Computer Science Q#86722, answer score: 6
Revisions (0)
No revisions yet.