SOP: WordPress Digitalocen - Disk Space Error

Here is a professional SOP for resolving disk expansion issues on DigitalOcean.


SOP: Resolving "No Space Left on Device" After Droplet Resize

Issue: WordPress/Database fails with errno: 28 or Disk Full error. The Droplet was resized in the dashboard, but the OS does not recognize the new space, and the disk remains at 100% usage.


Phase 1: Verification

Before making changes, confirm that the partition is the bottleneck.

  1. Access the Server: Log in via SSH or the DigitalOcean Console.

  2. Check Disk Usage: Run df -h.

    • Indicator: If /dev/vda1 shows 100% Use, the partition needs manual expansion.

  3. Check Physical Disk: Run lsblk.

    • Indicator: If vda (the disk) is larger than vda1 (the partition), you have unallocated space.


Phase 2: Manual Expansion (Online Method)

In most cases, you can do this while the server is running.

  1. Expand the Partition:

    sudo growpart /dev/vda 1

    (Note: This tells the partition table to take up the rest of the disk.)

  2. Resize the Filesystem:

    sudo resize2fs /dev/vda1

    (Note: This grows the actual data layer to fill the new partition size.)

  3. Confirm: Run df -h again to verify "Avail" space has increased.


Phase 3: Emergency Recovery (If Login Fails)

If the disk is so full that you cannot log in (session creation fails), use the Recovery ISO.

  1. Mount Recovery ISO: Go to Droplet > Recovery > Mount Recovery ISO.

  2. Power Cycle: Turn the Droplet OFF and then ON.

  3. Launch Console:

    • Select Option 1 (Mount your Disk Image).

    • Select Option 6 (Interactive Shell).

  4. Repair via Shell:

    • growpart /dev/vda 1

    • resize2fs /dev/vda1

  5. Clean Temporary Files:

    rm -rf /mnt/tmp/*

  6. Revert and Reboot:

    • Go to Recovery > Boot from Hard Drive.

    • Power cycle (OFF/ON) the Droplet.


Phase 4: Maintenance & Prevention

To prevent a total site crash in the future:

  • Monitor Inodes: Occasionally run df -i. If you have millions of tiny files (cache/sessions), the disk will "fill up" even if GBs are free.

  • Log Rotation: Ensure your logs aren't growing indefinitely. Check /var/log.

  • Set Up Alerts: In DigitalOcean, go to Monitoring > Create Alert Policy and set an alert for Disk Utilization > 85%. This gives you time to resize before the site crashes.

  • Database Hygiene: Periodically clear the wp_options table of expired transients using a plugin like WP-Optimize.


Final Result: Disk increased from 80GB to 160GB (50% utilization). Site restored.