Saturday, January 17, 2009

Estimate disk usage of each folder on a Linux System

To estimate disk usage of each directory, you can use a command line such as du with a particular option. This tool is used when you feel something uncomfortable with your hard disk capacity. Or you want to know, which folder (or sub folder) that make your hard disk becomes full.

Code :
# du --max-depth=1 -h

Example :
[root@msmunir1 /]# du --max-depth=1 -h
8,5M ./root
15M ./sbin
76M ./opt
145M ./lib
4,3M ./repo
6,6M ./bin
du: cannot access `./proc/5822/task/5822/fd/4': No such file or directory
du: cannot access `./proc/5822/task/5822/fdinfo/4': No such file or directory
du: cannot access `./proc/5822/fd/4': No such file or directory
du: cannot access `./proc/5822/fdinfo/4': No such file or directory
0 ./proc
20K ./lost+found
4,0K ./srv
280K ./tmp
6,0G ./var
4,0K ./mnt
1,2G ./etc
13M ./boot
du: cannot access `./home/msmunir/.gvfs': Permission denied
9,0G ./home
0 ./sys
4,0K ./media
3,0G ./usr
4,0K ./selinux
100K ./dev
20G .
[root@msmunir1 /]#

From information above, you see, folder /home used 9.0 GB, folder /var used 6.0 GB, folder /usr used 3.0 GB, folder /etc used 1.2 GB, and etc.

“--max-depth=1” option, only first level from current directory will be shown. Therefor, it's better, if you use root account and from root directory.

This is screen display, when you don't use “-h” option. “h” mean human readable.

[root@msmunir1 /]# du --max-depth=1
8672 ./root
14492 ./sbin
77788 ./opt
147496 ./lib
4336 ./repo
6700 ./bin
du: cannot access `./proc/6749/task/6749/fd/4': No such file or directory
du: cannot access `./proc/6749/task/6749/fdinfo/4': No such file or directory
du: cannot access `./proc/6749/fd/4': No such file or directory
du: cannot access `./proc/6749/fdinfo/4': No such file or directory
0 ./proc
20 ./lost+found
4 ./srv
280 ./tmp
6217808 ./var
4 ./mnt
1258100 ./etc
13243 ./boot
du: cannot access `./home/msmunir/.gvfs': Permission denied
9415880 ./home
0 ./sys
4 ./media
3082848 ./usr
4 ./selinux
100 ./dev
20247787 .
[root@msmunir1 /]#

by.msmunir@batan.go.id

No comments:

Post a Comment