×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

du for root dir
2

du for root dir

du for root dir

(OP)
I need to find out the size of each file under root (/) and its sub dir, but so far I haven't had a luck.

du -m / |sort +0rn
du -m . |sort +0rn

etc etc

Can you pls help me on that?

thx a lot in adv.

RE: du for root dir

du -ms /* | sort -rn

should do it, if I understand what you're asking.

You want to rank the disk space used by each of the subdirectories of the root directory, along with files actually in the root directory, right?

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
Rod,

lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs   PPs   PVs  LV STATE      MOUNT POINT
hd5                 boot       1     2     2    closed/syncd  N/A
hd6                 paging     180   360   2    open/syncd    N/A
hd8                 jfslog     1     2     2    open/syncd    N/A
hd4                 jfs        2     4     2    open/syncd    /
hd2                 jfs        9     18    2    open/syncd    /usr
hd9var              jfs        4     8     2    open/syncd    /var
hd3                 jfs        2     4     2    open/syncd    /tmp
hd1                 jfs        1     2     2    open/syncd    /home
hd10opt             jfs        1     2     2    open/syncd    /opt

It just gives the sum:

377.07  /var
345.93  /tmp

So, still the size of each file under root (/) and its sub dir is not showing.  

thx much

RE: du for root dir

I'm still not sure what you're looking for. Could you restate it, or make up an example of how it would look?

You can do a long listing of every file on the system by using "ls -lR /", if that's what you want.

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
Rod,

ls -lR / |sort +4nr |more
-rw-r--r--   1 root     system    927909409 Jan 27 06:05 check_printq.log
-rw-r--r--   1 patrol   system    619666036 Jan 27 19:54 param.hist

This gives the size of each file, but not which dir the file is under.

It wuld be great if it gives like:
1200.21  /
       3.2   fileA
       2.7   fileB
       2.4   fileC
        .... etc ....

377.07  /var
       2.2   fileA
       1.8   fileB
       1.1   fileC
        .... etc ....
345.93  /tmp
       3.2   fileA
       2.8   fileB
       1.7   fileC
        .... etc ....

Would that be possible?

thx much

RE: du for root dir

Anything's possible for the man who doesn't have to do it. smile

Search around for "script tree disk space" and you should find plenty of ways to do it.

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
before going through tools out there,

this ( find / -ls |sort +4nr |more ) would work for me as long as I can exclude certain dirs i.e. /proc under root (/).

find: 0652-023 Cannot open file /proc/491944.
sort: 0653-657 A write error occurred while sorting.

Any thoughts on this?

thx muxh for your help.

RE: du for root dir

how about something akin to

find / -ls|grep -v "/proc/"|sort +4nr

You might want to adjust the grep to ensure that it is only the /proc directory that is ignored and doesn't ignore any subordinate directories called proc

Dave

RE: du for root dir

find / -ls|awk '$11 !~ /^\/proc/'|sort +4nr

should exclude /proc

Dave

RE: du for root dir

Since I'm guessing you only care about real files, then

find / -type f -ls | sort +4nr | more

should do it.

The "sort: 0653-657" error was caused, most likely, by quitting "more" before you got to the end of the output.

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
I am still getting:

root:/> find / -ls|awk '$11 !~ /^\/proc/'|sort +4nr
find: 0652-019 The status on /proc/400824 is not valid.
root:/> find / -type f -ls | sort +4nr | more
sort: 0653-657 A write error occurred while sorting.

It seems |sort takes time and timed out.
Any way to get around it?

thx much

RE: du for root dir

Are you running out of space on /tmp?

From the looks of the strings in the "sort" binary, it might be writing scratch files there. Since "sort" is reporting the error, that seems a likely cause.

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
The issue is on /.

Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/hd4           2.00      0.00   100%     4918     1% /

RE: du for root dir

(OP)
I found the reason why / was filled up 100%.
There was a filesystem that was not mounted, thus it affected / when it had many files with large size.  

If there is .ksh that can get filesystems that are not mounted and give me du, that will be great.

Any ideas, please?

thx much

RE: du for root dir

You can't check du for an unmounted filesystem, since du has to examine the filesystem.

Check man mount for instructions on mounting a filesystem temporarily at a point other than its defined mount point.

I'm still not sure what exactly it is you're looking for. What is the problem you're trying to solve?

- Rod

IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

Wish you could view posts with a fixed font? Got Firefox & Greasemonkey? Give yourself the option.
 

RE: du for root dir

(OP)
With severqal tries, I realized that it is not quite possible to check sizes of EACH files under dirs under / with command lines.  It seems that the only solution avail would be to run   customized scripts.  Your inputs were very helpful though..

thx much

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close