Monitoring disk usage¶
These are just my personal notes. No warranty whatsoever.
Table of contents
Manually see the overall disk usage:
$ df -h Filesystem Size Used Avail Use% Mounted on /dev/simfs 15G 7.0G 8.1G 47% / tmpfs 205M 2.1M 203M 2% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 820M 0 820M 0% /run/shm
Show all directories which have more than a GB:
$ du ~ -h | grep '[0-9\.]\+G'
Show all subdirectories and their size (sorted by size):
$ du -h -d1 | sort -h
--summarize option means "only the specified directories, no subdirs"
$ du -sh ~/*
Install monit (sudo apt-get install monit ) and get alerts per
/etc/monit/monitrc you can write for example:
check filesystem datafs with path / if space usage > 80% for 5 times within 15 cycles then alert if space usage > 99% then stop
To erase downloaded archive files:
$ sudo apt-get clean
To remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed:
$ sudo apt-get autoremove
To see which kernel versions are installed:
$ dpkg --get-selections | grep linux-image
To remove an unused kernel image:
$ sudo apt-get remove --purge linux-image-X.X.XX-XX-generic