Purpose

Comprehensive guide for safely cleaning up disk space on Linux systems with NVMe SSDs, targeting developer environments with Docker, Node.js/pnpm, Python tools, and application caches.

Key Findings

Common Storage Consumers in Developer Environments

  1. Docker artifacts - Images, build cache, and volumes can consume 100GB+
  2. Language package managers - uv (Python), pnpm/npm (Node.js) maintain global caches
  3. Application caches - JetBrains, Chrome, Whisper AI models, etc.
  4. Trash directory - Often forgotten, can accumulate 50GB+
  5. Project dependencies - node_modules directories across projects

Safe Cleanup Priority Levels

High Priority (Safe, High Impact):

  • Empty trash
  • Docker build cache and unused images
  • Package manager caches (uv, pnpm, npm)
  • Application caches (browser, IDE)
  • Old downloads

Medium Priority (Requires Review):

  • Docker volumes
  • AI model caches (if not actively used)
  • Project build artifacts
  • Large unused projects

Low Priority (Risky, Manual Review):

  • System logs (journalctl)
  • Project source code

Cleanup Commands & Strategies

1. Empty Trash (Immediate ~61GB Recovery)

Terminal window
# Check trash size first
du -sh ~/.local/share/Trash
# Empty trash
rm -rf ~/.local/share/Trash/*

Impact: Can reclaim 50-100GB+ depending on accumulated deletions.

2. Docker Cleanup (~170GB Potential)

Terminal window
# Show Docker disk usage
docker system df
# Remove unused containers, networks, images, and build cache
docker system prune -a --volumes
# More targeted cleanup:
docker image prune -a # Remove unused images only
docker builder prune -a # Remove build cache only
docker volume prune # Remove unused volumes

Impact:

  • Build cache: ~78GB
  • Unused images: ~86GB
  • Volumes: Variable, check before removing

Important: Ensure Docker is running before executing cleanup commands.

3. Python uv Cache Cleanup (~65GB)

Terminal window
# Check uv cache size
du -sh ~/.cache/uv
# Clean uv cache (safe - will re-download as needed)
uv cache clean
# Or manually remove
rm -rf ~/.cache/uv

Impact: ~65GB immediate recovery. Cache rebuilds automatically when needed.

4. pnpm Package Manager Cleanup (~8GB Store)

Terminal window
# Prune unreferenced packages
pnpm store prune
# Check store size
du -sh ~/.local/share/pnpm/store
# Check cache
du -sh ~/.cache/pnpm
rm -rf ~/.cache/pnpm # Safe to remove

Impact:

  • Store pruning: Variable (removes orphaned packages)
  • Cache: ~236MB+

Important: Unlike npm, pnpm uses symlinks. Never delete the entire store directory without pnpm store prune as it will break existing node_modules across all projects.

5. npm Cache Cleanup

Terminal window
# Verify and clean npm cache
npm cache verify
npm cache clean --force

Impact: Variable, typically a few GB.

6. Browser & Application Caches

Terminal window
# Chrome cache (~5GB)
rm -rf ~/.cache/google-chrome
# GitHub Copilot cache (~6GB)
rm -rf ~/.cache/github-copilot
# Whisper AI models (~5GB - only if not used)
rm -rf ~/.cache/whisper
# HuggingFace models (~3GB - only if not used)
rm -rf ~/.cache/huggingface
# JetBrains cache (~16GB)
rm -rf ~/.cache/JetBrains

Impact: 10-30GB total. Caches rebuild automatically when needed.

Warning: Only remove AI model caches (whisper, huggingface) if you’re not actively using them, as redownloading can be time-consuming.

7. Playwright & Puppeteer Browsers

Terminal window
# Playwright browsers (~2GB)
rm -rf ~/.cache/ms-playwright
# Puppeteer browsers (~1.1GB)
rm -rf ~/.cache/puppeteer

Impact: ~3GB. Browsers reinstall when needed.

8. System Journal Logs

Terminal window
# Check journal size
journalctl --disk-usage
# Keep only last 3 days
sudo journalctl --vacuum-time=3d
# Or limit to size (e.g., 500MB)
sudo journalctl --vacuum-size=500M

Impact: Variable, typically 1-5GB. Safe to reduce.

9. Downloads Folder Review

Terminal window
# Check downloads size
du -sh ~/Downloads
# Review and delete manually
ls -lhS ~/Downloads | head -20 # Show largest files

Impact: Variable. Manual review recommended.

10. Find Large node_modules Directories

Terminal window
# Find all node_modules directories and their sizes
find ~ -name "node_modules" -type d -prune -exec du -sh {} \; 2>/dev/null | sort -hr
# Remove specific project's node_modules (can reinstall with pnpm install)
rm -rf /path/to/project/node_modules

Impact: Variable. Each node_modules can be 100MB-1GB+. Safe to remove as they can be reinstalled.

Quick Win (15 minutes, ~150GB+)

Terminal window
# 1. Empty trash
rm -rf ~/.local/share/Trash/*
# 2. Clean Docker
docker system prune -a --volumes
# 3. Clean Python uv cache
uv cache clean
# 4. Clean pnpm
pnpm store prune
# 5. Clean npm
npm cache clean --force
# 6. Clean browser cache
rm -rf ~/.cache/google-chrome
# 7. Trim system logs
sudo journalctl --vacuum-time=7d

Deep Clean (1 hour, additional ~50GB)

  1. Review and clean AI model caches (whisper, huggingface)
  2. Clean JetBrains cache (rebuilds on next launch)
  3. Find and remove old project node_modules
  4. Review Downloads folder
  5. Audit large projects for old branches/build artifacts

NVMe SSD Specific Considerations

TRIM Support

Ensure TRIM is enabled for optimal SSD performance:

Terminal window
# Check if TRIM is enabled
sudo systemctl status fstrim.timer
# Enable weekly TRIM
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer

Secure Erase (Data Sanitization)

For complete drive wipe only (backup data first!):

Terminal window
# Check drive capabilities
nvme id-ctrl /dev/nvme0 -H | grep -E 'Format |Crypto Erase|Sanitize'
# Use nvme-sanitize (most thorough, NVMe 1.3+)
sudo nvme sanitize /dev/nvme0 -a 0x02
# Or nvme-format (faster, less thorough)
sudo nvme format /dev/nvme0 -s 1

Important Warnings:

  • Never use on USB-connected drives (can brick device)
  • Avoid “Overwrite” action on SSDs (reduces endurance)
  • Self-Encrypting Drives (OPAL): Crypto erase changes encryption key, making all data unrecoverable
  • Always backup before any secure erase operation

Tools

  • nvme-cli: NVMe-specific utilities for format and sanitize operations
  • hdparm: Legacy tool for SATA SSDs (not for NVMe)
  • Parted Magic: Bootable secure erase utility ($15, comprehensive GUI)
  • Vendor tools: Samsung Magician, Dell BIOS Data Wipe, etc.

Monitoring & Prevention

Regular Maintenance

Terminal window
# Weekly: Check disk usage
df -h /
# Monthly: Review largest directories
du -h --max-depth=1 ~ | sort -hr | head -20
# Quarterly: Deep clean caches and Docker
docker system prune -a --volumes
pnpm store prune

Automated Cleanup

Consider adding to crontab or systemd timer:

~/.local/bin/cleanup-caches.sh
#!/bin/bash
docker system prune -f
pnpm store prune
npm cache clean --force
journalctl --vacuum-time=7d
rm -rf ~/.cache/google-chrome

Storage Monitoring Tools

Terminal window
# Install ncdu for interactive disk usage
sudo apt install ncdu
# Use to explore large directories
ncdu ~
ncdu /

Package Manager Cache Comparison

ToolCache LocationSafe to DeletePrune Command
uv (Python)~/.cache/uvYesuv cache clean
pnpm~/.local/share/pnpm/storePrune onlypnpm store prune
npm~/.cache/npmYesnpm cache clean --force
pip~/.cache/pipYespip cache purge

Key Difference: pnpm uses symlinks, so never delete the entire store directory manually. Always use pnpm store prune to safely remove orphaned packages.

Sources

  1. Solid state drive/Memory cell clearing - ArchWiki
  2. How to Securely Recycle or Dispose of Your SSD – Linux Hint
  3. Securely wiping NVMe SSD drives using Linux · GitHub
  4. Secure Erase on Linux - Safely Wipe Drives for Data Security
  5. How to clear/clean .pnpm-store cache · pnpm Discussion
  6. How to Clear the npm Cache on Linux, macOS, and Windows
  7. pnpm cache delete | pnpm
  8. How to clean npm junk from disk | dTech
  9. Dockerfile good practices for Node and NPM