Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

du on / filesystem without considering other filesystems under it

Status
Not open for further replies.

KPKIND

Technical User
Sep 8, 2003
130
IN
Hi All,

I am trying to find the sizes of all the directories and files under / filesystems only, and du does not seem to be very helpful.

When I run du on /, it goes and finds the size of all the dirs and file, including those dirs that have filesystems mounted on them, which I dont want. Looking at the man page I though -x option would do that but does not seem to be doing it. On Solaris there is du -dk option which will give only the sizes of dirs and files only.

This problem is not just for / but if I have an app filesystem or DB filesystem which might have another filesystem mounted on one of its sub dirs this will come handy.

For instance

/usr is a filesystem
/usr/WebSphere/AppServer is a filesystem

In the above example I want to see the sizes of all directories and file under /usr but excluding /usr/WebSphere/AppServer which is a filesystem on its own.

I am sure there should be a way to find this, but I am unable to figure it out right now.

Any help is much appreciated

Cheers
TIA
KPKIND
 
[tt]du -x /[/tt]

doesn't cross FS borders on my machine...
What command are you using exactly?


HTH,

p5wizard
 
Hi p5wizard,

Thanks for your response.

I have tried du -xsk * from root directory and the output is below. It has given me the size of those directories that have filesystems mounted on them. For example usr,var,opt, mksysb_image.

[root@sssc11]/ # du -xsk *
0 admin
0 audit
0 bin
8 bosinst.data
8 build
24 dev
0 esm
71096 etc
12 home
16 image.data
0 lib
0 lost+found
10108 lpp
1004204 mksysb_image
0 mnt
0 net
0 nmon
158680 opt
du: proc/36882: No such file or directory
0 proc
9764 sbin
0 tftpboot
5088 tmp
0 u
0 unix
1226012 usr
29532 var
[root@sssc11]/ #

The filesystems are below

[root@sssc11]/ # df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd4 262144 168552 36% 3266 8% /
/dev/hd2 2752512 1504012 46% 35482 10% /usr
/dev/hd9var 262144 231432 12% 607 2% /var
/dev/hd3 393216 387564 2% 86 1% /tmp
/dev/hd1 524288 523836 1% 11 1% /home
/dev/hd11admin 131072 130708 1% 5 1% /admin
/proc - - - - - /proc
/dev/hd10opt 917504 754908 18% 5576 4% /opt
/dev/rootlv 262144 258116 2% 134 1% /home/root
/dev/mksysblv 6291456 5261388 17% 5 1% /mksysb_image
/dev/nmonlv 2097152 2088312 1% 4 1% /nmon
/dev/buildlv 1310720 1301992 1% 6 1% /build


From what I have understood from the man page about -x option is that it will display the size of those files and directories that share the same device, now which device is this talking about, is it physical or logical, I am confused.

Cheers
KPKIND
 
The trouble is, /usr is a dir which is found by the * expansion and it is already in a different filesystem from / ...

HTH,

p5wizard
 
p5wizard,

Yes I understand the fact that /usr is a directory and also understand that every mount point for a filesystem is a directory under root, directly or indirectly.

I am trying to find out if there is a way, I could only list directories and files under / but ignore those directories which act as mount point for other filesystems.

The reason is that it is not just "/" I have this requirement for, but as I mentioned in my earlier example, where /usr is one filesystem and /usr/WebSphere/AppServer is another filesystem but under /usr.

The only way I am currently thinking of is that, to list all directories using "ls -l|grep ^d" and verify if each directory name matches exactly with anything in /etc/filesystems and pass this on to du and so on.. I cannot really think of anything else.

Any help is much appreciated

Regards
KPKIND

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top