LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2011, 10:38 AM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
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.
 
Old 03-28-2011, 01:25 PM   #2
tommylovell
Member
 
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372

Rep: Reputation: 101Reputation: 101
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
1.1G    sparse

[root@athlonz ~]# du -sh --apparent-size sparse
3.1G    sparse

[root@athlonz sparse]# ls -sl
total 1049720
     16 -rwxrwxr-x 1 root  root       15621 2010-09-27 22:44 ff
     12 -rw-r--r-- 1 root  root        9813 2010-09-27 22:44 ff.c
     16 -rwxrwxr-x 1 root  root       14802 2010-09-27 17:41 filefrag
     12 -rw-r--r-- 1 15806 15806       9676 2010-05-13 19:00 filefrag.c
      4 -rw-r--r-- 1 root  root        1383 2010-09-27 22:31 hexprint.h
1049604 -rw-r--r-- 1 root  root  1073741824 2010-09-27 17:46 nonsparsefile
     12 -rwxrwxr-x 1 root  root        8553 2010-09-23 15:55 sparse
      8 -rwxrwxr-x 1 root  root        8100 2010-09-23 16:05 sparse2
      4 -rw-r--r-- 1 root  root        1118 2010-09-23 16:05 sparse2.c
      4 -rw-r--r-- 1 root  root        2820 2010-09-23 15:55 sparse.c
     16 -rw-r--r-- 1 root  root  1073741824 2010-09-23 15:55 sparsefile
     12 -rw-r--r-- 1 root  root  1073741824 2010-09-23 16:05 sparsefile2

[root@athlonz sparse]# ls -sl --block-size=4096
total 262430
     4 -rwxrwxr-x 1 root  root       4 2010-09-27 22:44 ff
     3 -rw-r--r-- 1 root  root       3 2010-09-27 22:44 ff.c
     4 -rwxrwxr-x 1 root  root       4 2010-09-27 17:41 filefrag
     3 -rw-r--r-- 1 15806 15806      3 2010-05-13 19:00 filefrag.c
     1 -rw-r--r-- 1 root  root       1 2010-09-27 22:31 hexprint.h
262401 -rw-r--r-- 1 root  root  262144 2010-09-27 17:46 nonsparsefile
     3 -rwxrwxr-x 1 root  root       3 2010-09-23 15:55 sparse
     2 -rwxrwxr-x 1 root  root       2 2010-09-23 16:05 sparse2
     1 -rw-r--r-- 1 root  root       1 2010-09-23 16:05 sparse2.c
     1 -rw-r--r-- 1 root  root       1 2010-09-23 15:55 sparse.c
     4 -rw-r--r-- 1 root  root  262144 2010-09-23 15:55 sparsefile
     3 -rw-r--r-- 1 root  root  262144 2010-09-23 16:05 sparsefile2
If you totalled the file sizes it comes to 3,221,297,358.

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
     12 -rw-r--r-- 1 root  root  1073741824 2010-09-23 16:05 sparsefile2
Each of these files is logically 1GB, but they take up 16KB and 12KB respectively.

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?

Last edited by tommylovell; 03-28-2011 at 04:29 PM.
 
1 members found this post helpful.
Old 03-28-2011, 03:58 PM   #3
toordog
Member
 
Registered: Jul 2010
Location: Montreal, Canada
Distribution: RedHat, Ubuntu, Solaris, AIX, BSD
Posts: 42

Rep: Reputation: 3
DELETED.
My post was redundant and useless.

Last edited by toordog; 03-28-2011 at 04:44 PM.
 
Old 03-28-2011, 04:36 PM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Quote:
Originally Posted by toordog View Post
My post is redundant in the end. I wanted to delete it but can't find how.
You cannot delete posts here. You can edit them to say "deleted" and/or to explain the reason for deletion, though.
 
Old 03-29-2011, 07:20 AM   #5
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18
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.
 
Old 03-29-2011, 11:48 AM   #6
toordog
Member
 
Registered: Jul 2010
Location: Montreal, Canada
Distribution: RedHat, Ubuntu, Solaris, AIX, BSD
Posts: 42

Rep: Reputation: 3
Quote:
Originally Posted by dinakumar12 View Post
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.

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.
 
Old 03-29-2011, 07:27 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,412

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
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

 
Old 03-30-2011, 10:18 AM   #8
toordog
Member
 
Registered: Jul 2010
Location: Montreal, Canada
Distribution: RedHat, Ubuntu, Solaris, AIX, BSD
Posts: 42

Rep: Reputation: 3
[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
 
Old 03-30-2011, 10:48 AM   #9
tommylovell
Member
 
Registered: Nov 2005
Distribution: Fedora, Redhat
Posts: 372

Rep: Reputation: 101Reputation: 101
Quote:
Also, Linux reserves an amt (5% default iirc) on each disk for root to use when the user's area becomes full.
Yup. Good thing to keep in mind if a non-root user (again, a default) can't use 100% of a filesystem.
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.

Last edited by tommylovell; 03-30-2011 at 10:53 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating tar : shell vs ui, size differs tank junior Linux - Newbie 1 10-14-2010 01:08 PM
How come file size differs between ls and df? felixrabe Linux - General 6 01-06-2008 07:26 PM
The same font and it's size differs from Windows to Linux. How to solve it ? aboaventura Linux - General 1 12-20-2006 09:46 AM
File size differs procfs General 3 06-06-2006 10:14 AM
fdisk partition size differs from mounted partition size jimieee Linux - General 3 10-15-2003 04:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration