This guide ensures that new VMs (Ubuntu/Debian) are optimized for Blockchain/AI workloads by limiting log bloat and clearing unnecessary system data.
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
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
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
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
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. |
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