frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

How to check which files/folders are taking the most space on your server?

VPS servers could are usually limited by disk space and/or Inodes(file number). If a server reaches the limit, it may cause some problems and the server might stop working correctly. When you lack disk space and/or Inodes, the server will not function normally. When a task/app is executed it usually creates a temporary file and if you have no disk space/inodes for that, it will simply get stuck and might cause further issues.

When you are near the end of free disk space, usually the server informs you about it if you use any control panel, but you can check the disk space or Inodes periodically yourself in order to manage it.

Checking disk space

The disk space can be check using the following commands:

Check the general disk space usage on the server

df -h

Check the folder you are in content, files, and how much space it takes:

du -h

Check  only the disk space of the folder you are opened:

du -hs

Check any folder and the size of files/folders in it:

du –hs /etc

Checking files that are larger than 1024kb:

find / -mount -size +1024k -type f -exec du -Sh {} \;|sort -rh

Checking inodes usage

Checking the inodes on the folder you are in:

for i in 'ls -1A'; do echo "'find $i | sort -u | wc -l' $i"; done | sort -rn | head -5

Checking the top 50 folders by inode usage:

du -a / | sort -n -r | head -n 50

Note. You can use this command within the specific folder:

cd /etc
du -a / | sort -n -r | head -n 50

Tagged:

Comments

  • What steps can be taken to prevent issues caused by running out of disk space or inodes on a VPS server, and how can you periodically check disk space and inode usage?

  • IevazIevaz Administrator

    Hello,

    Preventing disk space or inode exhaustion on a VPS server is essential to maintaining its stability and performance. Running out of disk space or inodes can cause application failures, system crashes, and other critical issues. Here are steps to prevent these issues and periodically check disk space and inode usage:

    Monitor Disk Usage Regularly:

    Use monitoring tools to set up alerts for disk space and inode usage. Configure alerts to notify you when usage exceeds a certain threshold (e.g., 80%).

    Implement Log Rotation:

    Logs can quickly fill up disk space if not managed. Use log rotation tools like logrotate to automatically archive and remove old log files, preventing them from consuming too much space.
    Remove Unused Files:

    Regularly delete unused files, backups, or outdated application data. Tools like ncdu can help identify large files and directories that can be cleaned up.

    Optimize Application Storage:

    Ensure applications are not generating unnecessary or duplicate files. Review your application's caching and temporary file handling.

    Use Separate Partitions:

    Isolate critical directories (e.g., /var/log, /home, /tmp) on separate partitions. This prevents a full partition from impacting the entire system.

    Increase Disk Space or Inode Count:

    If consistently running out of space or inodes, consider upgrading your VPS with additional disk space or migrate to a VPS with a larger disk capacity.

  • Thanks for sharing this information.

Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch