How are page files stored on hard drives

operating systems

Just as RAM is divided into frames, the logical address space is divided into pages and the secondary storage into blocks of the same size. Pages are very small in size, 4 kB or so, and are swapped out when needed and stored as pagefiles.

All easy to understand until now. What confuses me is that:

  • Most modern hard drives have sectors the size of 4 kB or 8 kB, so does it mean each sector becomes a page?
  • And what is a "block" on a hard drive? Isn't it a collection of sectors? Is a block the same as a "cluster" which is also a collection of sectors?
  • If the OS wants to keep the page size independent of the sector size then it can designate a portion of the harddrive as virtual memory and operate on it differently from how it operates on the rest of the hard drive. Here the blocks could be the same size as page size and in the rest of the hard drive it could be different. Is that correct?

Best Answer

"Block" and "cluster" are filesystem-layer terminology, and "sector" is disk-layer terminology. Unlike "page", block size is determined entirely by software.

A "block", "sector", or "allocation unit" is a group of sectors that are fetched at once. Fetching more sectors at once improves latency: reading a large file a sector at a time is like trying to read a library book with a separate trip to the library for each page.

Virtual memory in Windows is just implemented as a file, and I believe it's not handled in a particularly special way.

Related Question