size of linux folder differs
Hi all,
I checked the folder size in my machine by running " du -sh foldername" in my terminal i got an output of 98M i checked the folder size graphically by right clicking the folder and checked with properties. it showed 83M which one is right. I am confused. Your suggestions please. |
I don't know the answer definitively, but since no one else has responded, here's my 2¢.
They are probably both right. It's just a definition of what "right" is. Things to consider. Is 1K equal to 1,000 or 1024? Is 1M equal to 1,000,000 or 1048576? The answer is probably 1024 and 1048576. You see this nonsense mostly with disk sizes, not with files within filesystems. If there are subdirectories, I would guess there is also directory overhead as well to account or not account for. This is probably negligible, and also probably not a factor. Is the total the sum of the individual file sizes, or the total of each file's disk space usage? A small example using a directory I have called "sparse" that contains sparse files. Code:
[root@athlonz ~]# du -sh sparse If you got the properties of directory 'sparse' in Nautilus it says "Contents: 12 items, totalling 3.0 GB". On disk it is 1.1GB. These two lines tell you a lot. Code:
16 -rw-r--r-- 1 root root 1073741824 2010-09-23 15:55 sparsefile Since the Block Size of my filesystem is 4K, non-sparse files on disk are rounded up to a multiple of 4K; but on the other hand, if it is a sparse file, it can be smaller in size on disk than its apparent size as shown above. So, which one is right? |
DELETED.
My post was redundant and useless. |
Quote:
|
hi tommylovell,
Thanks for your reply. My doubt is which value is the exact or the real one. The one which we get by executing du -sh command or the value which got graphically by clicking on folder's properties. |
Quote:
The both are valid and exact. It's always a matter of how the math is made to make it Human Readable. Human Readable should always be used only as reference. Human Readable is not the most exact. You always some digit when you read in G or in M or in K. The best way to know the size of a file is to look at it raw in bytes. |
Post #2 is a good explanation. As pointed out in other similar threads, manufacturers will usually express disk size in powers of 10 (1k = 1000) to make the disks look bigger, whereas computers use 1k=1024 (powers of 2).
The difference between these 2 scales becomes progressively larger as the values increase. https://secure.wikimedia.org/wikiped...y_measurements Also, Linux reserves an amt (5% default iirc) on each disk for root to use when the user's area becomes full. If you REALLY want to understand this topic, read & digest the following http://linux.die.net/man/8/mkfs http://linux.die.net/man/8/tune2fs http://linux.die.net/man/1/du http://linux.die.net/man/1/df :) |
[QUOTE=chrism01;4307987]
Also, Linux reserves an amt (5% default iirc) on each disk for root to use when the user's area becomes full. /QUOTE] I didn't know that. Thanks for this info :) |
Quote:
The 5% is not taken out of the 'used' and still shows as 'free'. For ext2/3/4, see the man page for 'tune2fs', the -r, -u and -g flags. And do a 'dumpe2fs -h /dev/<device>' to see what it is currently set to (and to see other interesting filesystem tidbits). It would be a good idea if you set up a terabyte filesystem for a database that the whole terabyte could be used by the database uid. 'tune2fs' comes in handy for that. Why waste 5GB of space. |
All times are GMT -5. The time now is 10:50 AM. |