Skip to main content
← All guides

When your disk is full

When the disk fills up, programs can't save files and throw errors, databases stop, and in bad cases even SSH may not connect properly. Here's how to find what's taking up space and clean it up safely.

1. Check remaining space

df -h /

If Use% is over 90%, it's time to clean up.

2. Find what's big

sudo du -xh / --max-depth=1 2>/dev/null | sort -h | tail -n 15

Go into the large folders listed at the bottom and repeat the same command. For example, if /var is big:

sudo du -xh /var --max-depth=1 2>/dev/null | sort -h | tail -n 15

Installing ncdu makes this easier, since you can move between folders with the arrow keys and see their sizes. (Press q to quit)

sudo apt install -y ncdu
sudo ncdu -x /

3. Things you can safely delete

System logs

sudo journalctl --disk-usage          # Check the current log size
sudo journalctl --vacuum-size=200M    # Clean up, keeping only the most recent 200MB

Package cache and unused packages

sudo apt clean
sudo apt autoremove -y

If you use Docker

Docker takes up a lot of space as unused images and build cache pile up.

docker system df       # Check how much space Docker uses
docker system prune    # Clean up stopped containers, unused images/networks and build cache

Adding options, as in docker system prune -a --volumes, can delete even volumes that contain data. Only use it after checking what will be deleted.

pm2 logs

If you run a bot or app with pm2, its log files keep growing.

pm2 flush                    # Empty the logs collected so far
pm2 install pm2-logrotate    # From now on, clean up logs automatically once they pass a set size

Minecraft logs and old backups

You can delete old .log.gz files inside logs in your Minecraft server folder. For backup files piling up on the server, download them to your PC first and then delete them, oldest first.

4. I deleted files but the space didn't change

If a running program has a file open, deleting it won't free the space until that program stops. Restart the program or reboot the server and the change will show.

sudo lsof +L1 2>/dev/null | head    # List files that were deleted but are still open

If you don't have lsof, install it with sudo apt install -y lsof.

Cautions

  • Don't manually delete files inside system folders like /bin, /usr, /etc, /boot and /lib. Your server may fail to boot.
  • If space is still short after cleaning up, consider moving to a plan with a bigger disk. Moving to a new server

Windows server

  • Go to Settings → System → Storage → Temporary files, select the items you don't need, and remove them.
  • Check that no large files are left in the Downloads folder or the Recycle Bin.

If your problem isn't solved, open a ticket on our Discord.