Back to Shared Hosting Docs

    Disk Space Management

    Monitor and optimize your hosting storage

    Understanding Disk Space

    Disk space is the storage allocated for your hosting account. It includes website files, databases, email accounts, backups, and logs. Managing it efficiently ensures your site runs smoothly and prevents service interruptions.

    Checking Disk Space Usage

    Via cPanel Dashboard

    1. Log in to cPanel
    2. Check right sidebar for "Disk Usage"
    3. Shows usage in MB/GB and percentage
    4. Bar graph visualization

    Via Disk Usage Tool

    1. cPanel → Files → Disk Usage
    2. Shows breakdown by directory
    3. Interactive chart
    4. Click directories to drill down

    Via SSH

    # Check total usage
    du -sh ~/
    
    # Check specific directory
    du -sh ~/public_html
    
    # List all directories with sizes
    du -h --max-depth=1 ~/public_html | sort -hr
    
    # Check quota
    quota -s

    What Uses Disk Space?

    Common Space Consumers

    • Website Files: HTML, CSS, JS, images
    • Media Library: Images, videos, documents
    • Databases: WordPress, other apps
    • Email Accounts: Stored messages
    • Backups: Site and database backups
    • Log Files: Error logs, access logs
    • Cache Files: Temporary files
    • Themes/Plugins: Inactive installations

    Finding Large Files

    Using File Manager

    1. cPanel → File Manager
    2. Navigate to directory
    3. Click on size column to sort
    4. Identify largest files

    Using SSH

    # Find largest files
    find ~/ -type f -size +10M -exec ls -lh {} \; | sort -k 5 -hr | head -20
    
    # Find large directories
    du -h ~/public_html | sort -hr | head -20
    
    # Find files by type
    find ~/public_html -name "*.zip" -exec ls -lh {} \;

    Cleaning Up Disk Space

    Optimize Images

    • Compress images before uploading
    • Use plugins like ShortPixel or Smush
    • Convert to WebP format
    • Delete unused images from media library
    • Remove image sizes you don't use

    Clean Database

    • Delete post revisions
    • Remove spam comments
    • Clean transients
    • Optimize database tables
    • Use WP-Optimize plugin

    Email Management

    • Delete old emails
    • Empty trash folders
    • Archive to local computer
    • Reduce email retention period
    • Use IMAP and delete from server

    Remove Backups

    • Keep only recent backups
    • Move old backups off-server
    • Delete failed backup files
    • Use incremental backups

    Clean Log Files

    # Find and remove large logs
    find ~/logs -name "*.log" -size +100M -delete
    
    # Truncate error log
    > ~/public_html/error_log
    
    # Clear all log files
    find ~/logs -type f -name "*.log" -exec sh -c '> "$1"' _ {} \;

    WordPress Specific Tips

    Media Library Cleanup

    1. Install "Media Cleaner" plugin
    2. Scan for unused images
    3. Review and delete unused media
    4. Regenerate thumbnails if needed

    Database Optimization via WP-CLI

    wp transient delete --all
    wp post delete $(wp post list --post_type='revision' --format=ids) --force
    wp db optimize

    Limit Post Revisions

    Add to wp-config.php:

    define('WP_POST_REVISIONS', 3);
    define('AUTOSAVE_INTERVAL', 300);
    define('EMPTY_TRASH_DAYS', 7);

    Email Storage Management

    Setting Email Quotas

    1. cPanel → Email Accounts
    2. Find email account
    3. Change quota setting
    4. Save changes

    Email Best Practices

    • Use IMAP and delete after download
    • Don't store attachments on server
    • Archive old emails locally
    • Empty trash regularly
    • Use email forwarding instead of storage

    Database Space Management

    Check Database Sizes

    1. cPanel → phpMyAdmin
    2. Click database name
    3. Check "Size" column for each table

    Identify Large Tables

    SELECT 
        table_name AS 'Table',
        ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)'
    FROM information_schema.TABLES
    WHERE table_schema = 'your_database'
    ORDER BY (data_length + index_length) DESC;

    Preventing Disk Space Issues

    Regular Maintenance

    • Monthly disk space audit
    • Automated cleanup scripts
    • Scheduled database optimization
    • Regular log rotation

    Backup Strategy

    • Store backups externally (cloud storage)
    • Limit on-server backup retention
    • Use incremental backups
    • Compress backups

    Warning Thresholds

    • 70%: Start planning cleanup
    • 80%: Immediate action needed
    • 90%: Critical - urgent cleanup
    • 95%+: Service degradation likely

    Disk Space Optimization Checklist

    1. ✓ Optimize and compress images
    2. ✓ Delete unused media files
    3. ✓ Clean up email accounts
    4. ✓ Optimize database tables
    5. ✓ Delete post revisions
    6. ✓ Remove old backups
    7. ✓ Clear log files
    8. ✓ Delete unused themes/plugins
    9. ✓ Clear cache files
    10. ✓ Remove temp files
    11. ✓ Set up automated cleanup
    12. ✓ Monitor usage regularly

    When Disk Space is Full

    Symptoms:

    • Cannot upload files
    • Cannot receive emails
    • Website errors (500, unable to write)
    • Cannot create databases
    • Backup failures

    Immediate Actions:

    1. Delete largest unnecessary files first
    2. Empty email accounts
    3. Remove old backups
    4. Clear log files
    5. Delete temp files