Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I often write small programs of sizes < 512 bytes, which is my disk's sector size. However, the du command always shows these files' disk usage at 4K. My memory page size is 4K.

So I was wondering if the disk usage of a file is in terms of page sizes in stead of sector sizes and if so, is it because files are memory mapped when they are opened?

Or does this depend on the file system?

ADDED

filesystem: ext4

share|improve this question
3  
Individual filesystems are free to store files in such a way that they take up however much space the filesystem designer or implementor pleases. If you don't mention which type of filesystem you're asking about, there is no possible answer to your question. –  Celada Jan 14 '13 at 17:01

1 Answer 1

Typically, a cluster is the smallest addressable unit of diskspace at the filesystem level. A cluster is made up of multiple sectors, with a typical size being 4kb (this is the default for NTFS and probably others). If you write a file smaller than the cluster size, the whole cluster will be allocated.

The cluster size and memory page size are completely independent of each other, though I can imagine that there are technical reasons why they're both 4kb.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.