How do I fix disk space issues on my Droplet?

When the space on the Droplet’s disk is full, it can interfere with the Droplet’s functionality, such as causing database write issues, being unable to view application logs, Droplet resizing problems, and being unable to reset the Droplet’s root password. Clearing space on the Droplet’s hard disk allows the Droplet to function normally.

To fix the problem, access the Droplet via SSH or log in using the Recovery Console.

You can check which folders are using the most space on the Droplet by using the disk utilization command, du:

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

The command returns output similar to this:

4.0K	/var/local
4.0K	/var/opt
91M	/var/cache
4.0K	/var/mail
623M	/var/lib
214M	/var/log
4.0K	/var/crash
28K	/var/spool
1.6M	/var/backups
60K	/var/snap
36K	/var/tmp
930M	/var

In this example, the command lists the directories in the /var directory and how much space they are using. The -h flag returns the output in a human-readable format, and the --max-depth=1 flag outputs the disk usage only for the folders in the /vars directory. Increasing the value of --max-depth returns additional levels of subfolders. You can use the du command to assess other directories and sub-directories by changing the path in the command.

Once you see which directories have high utilization, you can use the list command, ls, with the -larSh flag to see which individual files are largest in the directory:

ls -larSh /var/log/

In the example above, this returns all of the files in /var/log directory, sorted by size, in human-readable format.

Rapid increases in disk utilization are commonly caused by system or application log files being filled with errant entries in the /var directory. When clearing out hard disk space on your Droplets, we suggest you start by assessing the space usage of files in the /var directory. The /var directory also commonly houses website and database files making it a prime location for high disk utilization.

Based on the output, you can start deleting unwanted files. To delete a file, use the rm command, like rm path/to/your/file. To delete a directory, use the -d directory flag, like rm -d path/to/a/directory.

After deleting old files, unwanted programs, log rotations, and removing extra packages, run the disk free command (df) with the human-readable format (-h) flag to verify that the disk space has been reduced:

df -h

The command returns output similar to this:

Filesystem      Size  Used Avail Use% Mounted on
udev            474M     0  474M   0% /dev
tmpfs            99M  960K   98M   1% /run
/dev/vda1        25G  2.5G   22G  11% /
tmpfs           491M     0  491M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           491M     0  491M   0% /sys/fs/cgroup

The output displays the size of each file system on the Droplet, the space used in each file system, and how much space is available. The /dev/vda1 represents your Droplet’s hard disk space.

High RAM or CPU usage is normally the result of applications or kernel processes on the Droplet. You can monitor high CPU usage processes on the Droplet and stop them if necessary.
You cannot resize Droplets to smaller plans, but you can migrate your data to a smaller Droplet.
Filesystem tools often don’t report the capacity reserved for metadata and the root user, and some report size in different units.