Disk space

From LQWiki
Jump to navigation Jump to search

Even with our cheap disk storage, we can run out of disk space easily. Also, most filesystems need 15% free disk space to keep optimum performance, as your files will be fragmented, and the system will have to move files arround a lot more to defragment your partitions. And defaults usually require 5% free for the root user to have available in emergencies.

Tools

You can buy a new disk, and if you are using LVM you can just add the disk and resize partitions as needed.

To see the largest files in a directory:

ls -Slah | head

To see free disk space

df -h

* you must have the partitions mounted that you want

To analyze disk usage

du -h /directory
du -h --max-depth=1

* view only one level of current directory - good to start at / to get a good overview of where the space is. can then descend into certain directories and do it again there.

To see a visual representation of relative size:
in KDE, use Konqueror --> FSViewPart

Files that may be safely removed, by distro

Gentoo

  • /usr/portage/distfiles
  • the "work" directory for failed builds, Maybe /var/cache/portage or similar.

See also