Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aakash4dev/ac7782f2e6e77ea853083c5f576f3cb6 to your computer and use it in GitHub Desktop.

Select an option

Save aakash4dev/ac7782f2e6e77ea853083c5f576f3cb6 to your computer and use it in GitHub Desktop.

๐Ÿš€ New Node Initialization & Storage Optimization

This guide ensures that new VMs (Ubuntu/Debian) are optimized for Blockchain/AI workloads by limiting log bloat and clearing unnecessary system data.


1. System Log Optimization (Journald)

By default, Ubuntu allows logs to take up to 4GB. This caps it at 500MB.

Commands:

# Set limits in journald.conf
sudo sed -i 's/#SystemMaxUse=/SystemMaxUse=500M/' /etc/systemd/journald.conf
sudo sed -i 's/#RuntimeMaxUse=/RuntimeMaxUse=100M/' /etc/systemd/journald.conf

# Restart service to apply
sudo systemctl restart systemd-journald

# Vacuum existing logs older than 2 days
sudo journalctl --vacuum-time=2d

2. APT Cleanup & Automation

Prevent the .deb installer cache from growing every time you update.

Commands:

# Clear current cache
sudo apt-get clean

# Remove unused dependencies and old kernels
sudo apt-get autoremove --purge -y

3. LVM Partition Expansion

Ubuntu often only allocates 50% of the disk. Use 100% of the available physical space.

Commands:

# Extend the Logical Volume to use 100% of Free PE
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

# Resize the filesystem to match
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

4. Docker Optimization (If used)

Docker logs and dangling images are the #1 cause of disk failure in nodes.

Config (/etc/docker/daemon.json): Create or edit this file to limit container log sizes:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Maintenance Command:

# Periodically run this to clear unused build layers
docker system prune -f

5. Developer Cache Management

Clean these monthly or when switching between projects.

Tool Clean Command Purpose
Go go clean -modcache Clears all downloaded modules.
Rust cargo cache -a Requires cargo-cache crate. Clears old builds.
Foundry forge clean Clears out/ and cache/ artifacts.
Python find . -name "__pycache__" -exec rm -rf {} + Removes AI/Python temp files.

6. Quick Health Check Script

Save this as check.sh for a 1-second status update:

#!/bin/bash
echo "--- DISK USAGE ---"
df -h | grep -E '^Filesystem|/dev/mapper/'
echo -e "\n--- LOG USAGE ---"
journalctl --disk-usage
echo -e "\n--- SWAP STATUS ---"
swapon --show
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment