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.

This question already has an answer here:

It isn't a major concern of mine, but I am curious as to why a .txt file's size is 21bytes, and the size of it on disk is 4kilobytes. Here is a snapshot of what I mean:

Example:

I am also wondering if the same goes for the size of a hard-disk. Example: I have installed a 1tb hard-disk, but the actual available capacity is quite a bit less than 1tb, I have seen up to 60gb less, and thought this was quite a large amount? ie: 1TB hard-disk, but only has the capacity of storing 950gb.

I am not after any scientific explanation, just perhaps an idea of what happens behind the scenes to make this happen?

share|improve this question

migrated from stackoverflow.com Jun 20 '13 at 4:41

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Karan, Breakthrough, AthomSfere, terdon, mpy Jun 21 '13 at 12:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Look at this: superuser.com/questions/66825/… –  Little Helper Jun 20 '13 at 7:34
add comment

3 Answers

File systems like to align files on hard drive blocks, as it's simpler and can lead to better performance. When the size of a file is smaller than a block, the rest of the block is still used, leading to that discrepancy.

While you could end up with large discrepancies this way if you have many, many small files, it is more likely that the difference between the advertised and real space available is due to the different definitions of gigabyte (1024 megabytes vs 1000 megabytes).

share|improve this answer
add comment

this is because windows allots space as chunks of 4KB. so till u fill 4 KB, one chunk will be allocated to u. ie: 4KB. after your reach 4kB and 1 byte, your size on disk will be 8 KB and like on...

you could do Compression option in NTFS drives, to reduce the size on disk to almost same. But beware some experts say that this will slow your access speed by a tiny bit.

the bard disk issue is a different matter. your 1 TB when manufacturers say it actually says 1 T (metric system)= 1000^4 ie 1000 x 1000 x 1000 x 1000 ie 10^12 units

But when u take it to computer terms 1 TB = 1024^4 bytes

so, 1 TB in computer is much more than 1 T in metric system

so to do the conversion from Tera metric system to Tera Computer system,

= 1 x 1000^4 / 1024^4

= 0.909 TB in computer system (931 GB ie 0.909 * 1024)

share|improve this answer
add comment

This happens because harddisks are "block devices". That means you can only write data in units of complete "sectors" at a time, and you can only reserve space on the device in units of "sectors".
It is not possible to write 21 bytes, it is only possible to write a full block (or "sector") of which you effectively only use 21 bytes.

The actual sector size may vary from device to device, and it is mostly invisible (and not really important) to you. 512 bytes were common for decades, but newer drives have other sizes, usually 4096 bytes, to account for larger storage capacities.
Some drives (for example SSDs) are even more complicated internally, as they have physical allocation granularities of e.g. 512kiB but expose units of 4kiB to the outside world. To make this work at all, the drive internally (and without telling anyone) copies around data as needed. None of that is visible to the operating system or the user.

Now, since the device works that way, the operating system necessarily has to do something similar (in fact, not necessarily, but that is what is the only efficient way -- you could of course do it differently if you absolutely wanted, it just does not make much sense). 4096 is a good default "guess" for reasonably sized partitions because it is a multiple of all normally occurring device block sizes, and it does not waste too much space. Therefore, that is what NTFS (and most other file systems) uses as default, too. You can manually change this when formatting a drive, but usually this is not necessary and not advised.

For very large partitions, NTFS will use even bigger cluster sizes (8K upwards of 16TB, and 16k upwards of 32TB) as this keeps the cluster numbers smaller, and large drives can get over with wasting a few bytes on small files.

share|improve this answer
add comment

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