Symptoms
- Odoo crashes with "No space left on device"
- Database operations fail
- Cannot upload files or generate reports
- PostgreSQL refuses connections
- Odoo log file grows to fill disk
Step 1: Check Disk Usage
# Overall disk usage
df -h
# What is using the most space?
du -sh /* 2>/dev/null | sort -rh | head -20
# Common space hogs in Odoo:
du -sh /var/log/odoo/ # Odoo logs
du -sh /var/lib/odoo/ # Filestore (attachments)
du -sh /var/lib/postgresql/ # Database files
du -sh /tmp/ # Temporary filesFix 1: Odoo Log Files
# Check log size
ls -lh /var/log/odoo/odoo.log
# If log is multiple GB:
# Truncate (keep file descriptor open)
truncate -s 0 /var/log/odoo/odoo.log
# Set up log rotation
cat > /etc/logrotate.d/odoo << 'EOF'
/var/log/odoo/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
copytruncate
}
EOF
# Also reduce log verbosity:
# odoo.conf: log_level = warning (production)Fix 2: Filestore (Attachments)
# Check filestore size
du -sh /var/lib/odoo/.local/share/Odoo/filestore/*/
# Find orphaned attachments (no database reference)
# In Odoo shell:
orphans = env['ir.attachment'].search([
('res_model', '=', False),
('res_id', '=', 0),
('create_date', '<', '2025-01-01'),
])
print(f"Found {len(orphans)} orphaned attachments")
# orphans.unlink() # Uncomment to delete
# Clean up old report PDFs
old_reports = env['ir.attachment'].search([
('name', 'like', '%.pdf'),
('res_model', 'in', ['account.move', 'sale.order']),
('create_date', '<', '2024-01-01'),
])
print(f"Found {len(old_reports)} old report PDFs")Fix 3: PostgreSQL Bloat
# Check database size
SELECT pg_size_pretty(pg_database_size('odoo'));
# Check table sizes
SELECT relname, pg_size_pretty(pg_total_relation_size(relid))
FROM pg_catalog.pg_statio_user_tables
ORDER BY pg_total_relation_size(relid) DESC
LIMIT 20;
# Common bloated tables:
# ir_logging — Odoo internal logs
# mail_message — Chatter messages
# bus_bus — Live notifications
# ir_attachment — File metadata
# auditlog_log — Audit trail (if installed)
# Clean ir_logging (safe to truncate)
TRUNCATE ir_logging;
# Clean old bus_bus entries (safe)
DELETE FROM bus_bus WHERE create_date < NOW() - INTERVAL '7 days';
# Clean old mail tracking (safe)
DELETE FROM mail_tracking_value WHERE create_date < NOW() - INTERVAL '365 days';
# Vacuum after cleanup
VACUUM FULL; -- WARNING: locks tables, do during maintenance windowFix 4: Temporary Files
# Clean /tmp
find /tmp -type f -mtime +7 -delete
# Clean Odoo sessions
find /var/lib/odoo/.local/share/Odoo/sessions/ -type f -mtime +7 -delete
# Clean pip cache
pip cache purgeFix 5: Old Backups
# Check for old backups consuming space
find / -name "*.dump" -o -name "*.sql.gz" | xargs ls -lh 2>/dev/null
# Move old backups to object storage
# Or delete if already uploaded to S3/Spaces/GCSPrevention
# 1. Log rotation (see Fix 1)
# 2. Monitoring alert
# Alert when disk usage > 80%
# Ubuntu: install monit or use cloud provider alerts
# 3. Scheduled cleanup cron
# Create Odoo cron job that cleans:
# - ir_logging older than 30 days
# - bus_bus older than 7 days
# - Orphaned attachments older than 90 days
# 4. Separate disk for PostgreSQL
# Mount /var/lib/postgresql on its own partition/volume
# Easier to resize independently
# 5. Filestore on object storage
# For large installations, move filestore to S3/MinIO
# Reduces local disk pressureEmergency Recovery
# If disk is 100% full and Odoo won't start:
# 1. Delete Odoo log immediately
truncate -s 0 /var/log/odoo/odoo.log
# 2. Clear /tmp
rm -rf /tmp/odoo-*
# 3. Clear old sessions
rm -rf /var/lib/odoo/.local/share/Odoo/sessions/*
# 4. Start Odoo
systemctl start odoo
# 5. Then do proper cleanup (steps above)DeployMonkey
DeployMonkey monitors disk usage automatically. The AI agent alerts at 80% usage, identifies what is consuming space, and suggests cleanup actions — before your Odoo instance crashes.