Minsky session workspaces can consume significant disk space due to duplicated node_modules directories across sessions. By configuring Bun's package manager to use hardlinks, you can achieve 60-90% disk space savings while maintaining full compatibility.
- Default behavior: Each session creates its own copy of
node_modules - Typical usage: 189+ sessions consuming 34GB total
- Duplication: Same packages duplicated across every session workspace
- Impact: Slow installations, excessive disk usage, storage costs
Bun's hardlink backend creates hard links from a global cache to node_modules, meaning:
- One physical copy of each package version exists on disk
- Multiple sessions can reference the same files
- Automatic sharing of dependencies across projects
- No code changes required
Create a global bunfig.toml configuration:
cat > ~/bunfig.toml << 'EOF'
[install]
# Force hardlink backend for maximum disk space savings
backend = "hardlink"
# Optional: Configure cache directory
[install.cache]
dir = "~/.bun/install/cache"
disable = false
disableManifest = false
EOFAdd to your shell profile (.zshrc, .bashrc, etc.):
export BUN_INSTALL_BACKEND=hardlinkTest that the configuration is working:
# Create a test project
mkdir test-hardlink && cd test-hardlink
echo '{"dependencies": {"typescript": "^5.0.0"}}' > package.json
# Install with hardlink backend
bun install
# Verify hardlinks (link count should be > 1)
ls -li node_modules/typescript/lib/typescript.jsUse the provided script to convert all existing sessions:
# Run from minsky project root
./reclaim_space.shConvert individual sessions:
cd /path/to/session/workspace
rm -rf node_modules
bun install # Will use hardlink backend automaticallyBefore Optimization:
- Total sessions: 189
- Total disk usage: 34GB
- Per-session average: ~180MB
After Optimization:
- Total disk usage: 11GB
- Space saved: 23GB (67.6% reduction)
- Per-session effective: ~58MB
- Faster installations: Packages copied from cache via hardlinks
- Reduced download time: Global cache eliminates re-downloading
- Better disk utilization: Physical storage matches logical usage
- No compatibility issues: Standard Node.js module resolution
# Find a common file across sessions
find ~/.local/state/minsky/sessions -name "typescript.js" -path "*/typescript/lib/*" | head -1 | xargs ls -li
# Look for link count > 1 (indicates hardlinking)
# Example output: 42410573 -rw-r--r--@ 15 user staff 9066411 Apr 16 11:59 typescript.js
# ^^ link count# Check total sessions disk usage
du -sh ~/.local/state/minsky/sessions
# Compare individual session sizes
du -sh ~/.local/state/minsky/sessions/*/node_modules | head -5- Check file system: Hardlinks require compatible file systems (not FAT)
- Verify configuration: Ensure
~/bunfig.tomlexists and is correct - Clear cache:
bun pm cache rmand retry installation - Manual backend: Use
bun install --backend hardlinkexplicitly
- macOS: Uses
clonefileby default (copy-on-write), hardlink provides better savings - Linux: Uses hardlink by default
- Windows: Uses hardlink by default
# Session creation automatically benefits from hardlinks
minsky session start --task <task-id>
# Dependencies will be hardlinked automatically- No changes needed: Code editing, testing, and development work identically
- Package modifications: Avoided automatically through copy-on-write semantics
- Git operations: Unaffected by hardlink configuration
# Periodic cache cleanup (optional)
bun pm cache rm
# Re-run bulk reclamation after adding many sessions
./reclaim_space.shThe hardlink configuration integrates seamlessly with:
- ✅ Session creation:
minsky session start - ✅ Task workflows: All existing commands work unchanged
- ✅ Testing:
bun testand test infrastructure - ✅ Building:
bun run buildand compilation - ✅ CI/CD: GitHub Actions and automated workflows
- Setup (5 minutes): Configure global
bunfig.toml - Reclamation (15-30 minutes): Run bulk space reclamation script
- Verification (5 minutes): Confirm hardlinks working and space saved
- Ongoing (automatic): All future operations use optimized storage
Configuring Bun's hardlink backend is a one-time setup that provides:
- Immediate space savings: 60-90% reduction in disk usage
- Ongoing benefits: All future sessions automatically optimized
- Zero maintenance: Works transparently with existing workflows
- Full compatibility: No changes to development practices needed
Recommendation: This configuration should be standard for all Minsky installations to ensure optimal disk space utilization.