LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-28-2005, 06:39 AM   #1
essdeeay
Member
 
Registered: Aug 2004
Location: United Kingdom
Distribution: Debian
Posts: 88

Rep: Reputation: 15
Question Inconsistent disk/directory usage using 'ls'


Hello

I'm using FC3, and have noticed this anomoly on a few directories. When using the ls command, the size of the directory is nowhere near the size of the files within. For example, the file in here is larger that that reported for the size of it's parent:
Code:
[root@samba .maildir]# ls -alhR /home/tina/.maildir/new
/home/tina/.maildir/new:
total 440K
drwx------   2 tina tina  36K Oct 28 11:32 .
drwx------  13 tina tina 4.0K Oct 28 10:10 ..
-rw-------   1 tina tina 394K Oct 28 11:32 1130495528.Vfd00Ic07271.mydomain.org
And here, the size of the directory is way larger than the size of the file inside:
Code:
[root@samba .maildir]# ls -alhR /home/karen/.maildir/new
/home/karen/.maildir/new:
total 448K
drwx------   2 karen karen 424K Oct 28 12:06 .
drwx------  11 karen karen 4.0K Oct 28 11:54 ..
-rw-------   1 karen karen  14K Oct 28 12:06 1130497566.Vfd00Ic07219.mydomain.org
As far as I knew, the size of "." should always be 4K. These are IMAP folders (I'm using Dovecot) and I'm not sure if this is what IMAP is meant to do.

The reason I'm trying to work this out, is to check if the backups are being performed correctly (using rsync). I have a little script that counts the number of files, dirs and disk usage for a particular tree, and although the files/dirs numbers are the same for the real data and the backup, the disk usage is significantly different. So any other method to verify the backup is close enough to the real data will bypass this issue.

Kind regards,
Steve
 
Old 10-28-2005, 07:36 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Interesting. I did a test and found that "ls -lahR |grep ^dr" would give me the size of all the subdirectories and totaling those up would equal the size of "ls -lahd .".

Anyway a directory is a file in Linux/UNIX and sits within a filesystem more or less as a pointer to the files beneath it. It is NOT the size of the the files beneath it because if it were then a directory "file" would take up as much space as the total of all the files beneat it so you'd have to have double the space. If really interested you should reseach file handles and inodes to get more detail of the internal structure of filesystems.

Anyway what I think you're asking is how do you get a total for the space within a directory. The answer is with the "du" command. "du -sk <directory>" will give you the size of the space taken up by all the files within a given directory.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LQ disk usage student04 LQ Suggestions & Feedback 4 10-24-2004 09:35 PM
Disk Usage karan101 Linux - Software 8 10-17-2004 03:59 AM
'ls' failing in specific directory realjustin Linux - General 1 09-20-2004 01:55 PM
101% disk usage on an empty disk tsiuser Linux - Software 3 01-28-2004 06:24 PM
Disk Usage dvong3 Linux - Software 2 06-13-2003 12:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:32 PM.

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
Open Source Consulting | Domain Registration