View Full Version : Determine the directories/files on a partition

30th December 2008, 04:52 AM
Hey All,

I have a partition (hda6) that is 86% full and I would like to know exactly what is on this partition so I can see if there are directories or files or parts of files that I can delete to lessen the load on this server. So is there a command that allows you to see the directories and/or files on a particular partition?

Thank you for your time and help,

30th December 2008, 05:17 AM
Are you familiar with ls? That will give a listing of the files, color coded by default.

There is also du -sh which will give you the files and their size.
You can do ls -S which will sort by size. ls -lS will give you the size as well as sorting by size.
There's a bunch of different ways to do it. You could start with something like du -sh |grep G which will only show things that are at least one gig in size, as well as any other files with a capital G in their name. :)

30th December 2008, 05:26 AM
Thank you for the reply. I am familiar with ls but I don't know how that will actually give me the partition that the directories and/or files are located on. I need to them specific to a particular hard drive partition????

30th December 2008, 05:35 AM
ls, mc, nautilus, thunar, df, kfm ... there are dozens of tools.

Mount the file system somewhere and then start looking for the size of directories w/
df -s --si /media/disk/*
as a starting point.
Sometimes just seeing all the directory names helps
find /media/disk -type d | less
or maybe just the big file
find /etc -size 5M | xargs ls -l

30th December 2008, 07:17 AM
There is also a graphical application called baobab (Disk Usage Analyzer) that I find it useful to hunt down the directories containing large files. I am not saying it is better then CLI tools. Just point out the available option.

30th December 2008, 02:42 PM
type 'mount' at a command prompt, it'll show you the top-level directory where each partition is mounted:

/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
/proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)

so my / is an LVM
/dev/sda1 is mounted at /boot

So you need to find where /dev/hda6 is mounted at and can figure out what directories are on it from there. It does get complicated if /dev/hda6 is / because you might have other partitions mounted underneath it (/boot in my case) which do not contribute to /dev/hda6's usage.

30th December 2008, 02:59 PM
Using "df -Th' is a much prettier way to display useable mounts.
If you want a console tool, stick with "du", use the "-x" to not include other partitions in the calculations.
See the manpage on "du" for more info, it was made for what you want.