Complete Linux system optimization suite with tmpfs, zram, and German locale support
- Fixed missing setup_tmpfs() function that was causing silent failures - Added comprehensive system scanning for browsers, IDEs, gaming caches - Implemented detailed optimization information display for transparency - Added German locale compatibility for 'free' command (Speicher: vs Mem:) - Fixed division by zero errors in RAM calculations - Created tmpfs-info.sh helper script for detailed status reporting - Enhanced scanning to work on already-optimized systems - Added comprehensive optimization breakdowns with purpose explanations
This commit is contained in:
229
tmpfs-info.sh
Executable file
229
tmpfs-info.sh
Executable file
@@ -0,0 +1,229 @@
|
||||
#!/bin/bash
|
||||
# tmpfs Information and Configuration Helper
|
||||
# Shows detailed information about tmpfs setup and how to use it
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
show_tmpfs_status() {
|
||||
echo -e "${BLUE}🚀 tmpfs Cache System Status${NC}"
|
||||
echo "============================="
|
||||
echo ""
|
||||
|
||||
# Check if tmpfs mounts exist
|
||||
local tmpfs_count=$(mount | grep "tmpfs.*tmpfs-cache" | wc -l)
|
||||
|
||||
if [[ $tmpfs_count -eq 0 ]]; then
|
||||
echo -e "${RED}❌ No tmpfs cache mounts found${NC}"
|
||||
echo "Run: sudo ./one-button-optimizer.sh to set up tmpfs caches"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Found $tmpfs_count tmpfs cache mounts${NC}"
|
||||
echo ""
|
||||
|
||||
# Show detailed mount information
|
||||
echo "📁 Active tmpfs Mounts:"
|
||||
echo "======================"
|
||||
printf "%-20s %-10s %-10s %-10s %s\n" "Mount Point" "Size" "Used" "Avail" "Use%"
|
||||
echo "--------------------------------------------------------------------------------"
|
||||
|
||||
mount | grep "tmpfs.*tmpfs-cache" | while read -r line; do
|
||||
local mount_point=$(echo "$line" | awk '{print $3}')
|
||||
local df_info=$(df -h "$mount_point" 2>/dev/null | tail -1)
|
||||
local name=$(basename "$mount_point")
|
||||
local size=$(echo "$df_info" | awk '{print $2}')
|
||||
local used=$(echo "$df_info" | awk '{print $3}')
|
||||
local avail=$(echo "$df_info" | awk '{print $4}')
|
||||
local use_percent=$(echo "$df_info" | awk '{print $5}')
|
||||
|
||||
printf "%-20s %-10s %-10s %-10s %s\n" "$name" "$size" "$used" "$avail" "$use_percent"
|
||||
done
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
show_configuration_guide() {
|
||||
echo -e "${BLUE}💡 Configuration Guide${NC}"
|
||||
echo "======================"
|
||||
echo ""
|
||||
|
||||
# Browser configuration
|
||||
if mount | grep -q "tmpfs-cache/browser"; then
|
||||
echo -e "${YELLOW}🌐 Browser Cache Configuration:${NC}"
|
||||
echo ""
|
||||
echo "Google Chrome/Chromium:"
|
||||
echo " google-chrome --disk-cache-dir=/tmp/tmpfs-cache/browser/chrome"
|
||||
echo " Or add to ~/.config/google-chrome/Default/Preferences:"
|
||||
echo ' "browser": {"cache_directory": "/tmp/tmpfs-cache/browser/chrome"}'
|
||||
echo ""
|
||||
echo "Firefox:"
|
||||
echo " 1. Type about:config in address bar"
|
||||
echo " 2. Set browser.cache.disk.parent_directory = /tmp/tmpfs-cache/browser/firefox"
|
||||
echo " 3. Restart Firefox"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Development tools
|
||||
if mount | grep -q "tmpfs-cache/development"; then
|
||||
echo -e "${YELLOW}💻 Development Tools Configuration:${NC}"
|
||||
echo ""
|
||||
echo "NPM (Node.js):"
|
||||
echo " npm config set cache /tmp/tmpfs-cache/development/npm"
|
||||
echo " npm config set tmp /tmp/tmpfs-cache/development/npm-tmp"
|
||||
echo ""
|
||||
echo "Python pip:"
|
||||
echo " echo 'export PIP_CACHE_DIR=/tmp/tmpfs-cache/development/pip' >> ~/.bashrc"
|
||||
echo " source ~/.bashrc"
|
||||
echo ""
|
||||
echo "Docker build cache:"
|
||||
echo " docker build --build-arg BUILDKIT_INLINE_CACHE=1 ."
|
||||
echo " export DOCKER_BUILDKIT=1"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# IDE configuration
|
||||
if mount | grep -q "tmpfs-cache/ide"; then
|
||||
echo -e "${YELLOW}🎨 IDE Configuration:${NC}"
|
||||
echo ""
|
||||
echo "VS Code:"
|
||||
echo " mkdir -p /tmp/tmpfs-cache/ide/vscode"
|
||||
echo " ln -sf /tmp/tmpfs-cache/ide/vscode ~/.vscode/extensions/.cache"
|
||||
echo ""
|
||||
echo "JetBrains IDEs (IntelliJ, PyCharm, etc.):"
|
||||
echo " Add to vmoptions file: -Djava.io.tmpdir=/tmp/tmpfs-cache/ide/jetbrains"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# KDE configuration
|
||||
if mount | grep -q "tmpfs-cache/kde"; then
|
||||
echo -e "${YELLOW}🖥️ KDE/Plasma Configuration:${NC}"
|
||||
echo ""
|
||||
echo "Thumbnail cache:"
|
||||
echo " mkdir -p /tmp/tmpfs-cache/kde/thumbnails"
|
||||
echo " rm -rf ~/.cache/thumbnails"
|
||||
echo " ln -sf /tmp/tmpfs-cache/kde/thumbnails ~/.cache/thumbnails"
|
||||
echo ""
|
||||
echo "Baloo search index (optional - disables file indexing):"
|
||||
echo " balooctl disable"
|
||||
echo " rm -rf ~/.local/share/baloo"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage_tips() {
|
||||
echo -e "${BLUE}📊 Usage Tips and Monitoring${NC}"
|
||||
echo "============================="
|
||||
echo ""
|
||||
|
||||
echo "Monitoring Commands:"
|
||||
echo " df -h /tmp/tmpfs-cache/* # Check usage of all tmpfs mounts"
|
||||
echo " watch -n 5 'df -h | grep tmpfs-cache' # Monitor in real-time"
|
||||
echo " du -sh /tmp/tmpfs-cache/* # Check actual data in each mount"
|
||||
echo ""
|
||||
|
||||
echo "Performance Monitoring:"
|
||||
echo " iotop -ao # Monitor I/O to see reduced disk usage"
|
||||
echo " htop # Monitor RAM usage"
|
||||
echo " free -h # Check available memory"
|
||||
echo ""
|
||||
|
||||
echo "Maintenance:"
|
||||
echo " sudo sync # Force write pending data to disk"
|
||||
echo " sudo systemctl restart system-optimization.service # Recreate mounts"
|
||||
echo ""
|
||||
|
||||
echo -e "${GREEN}💡 Performance Benefits:${NC}"
|
||||
echo " 🚀 Cache operations run at RAM speed (~50-100x faster than SSD)"
|
||||
echo " 💿 Reduced SSD wear from frequent cache writes"
|
||||
echo " 🧹 Automatic cache cleanup on reboot"
|
||||
echo " ⚡ Lower latency for application launches and file operations"
|
||||
echo ""
|
||||
|
||||
# Calculate total tmpfs usage
|
||||
local total_allocated=0
|
||||
local total_used=0
|
||||
|
||||
while read -r line; do
|
||||
local mount_point=$(echo "$line" | awk '{print $3}')
|
||||
local allocated_kb=$(echo "$line" | grep -o 'size=[^,]*' | cut -d= -f2 | sed 's/k$//')
|
||||
local used_kb=$(df "$mount_point" 2>/dev/null | tail -1 | awk '{print $3}' || echo "0")
|
||||
|
||||
total_allocated=$((total_allocated + allocated_kb))
|
||||
total_used=$((total_used + used_kb))
|
||||
done < <(mount | grep "tmpfs.*tmpfs-cache")
|
||||
|
||||
local total_allocated_mb=$((total_allocated / 1024))
|
||||
local total_used_mb=$((total_used / 1024))
|
||||
|
||||
echo -e "${BLUE}📈 Current Resource Usage:${NC}"
|
||||
echo " Total tmpfs allocated: ${total_allocated_mb}MB"
|
||||
echo " Total tmpfs used: ${total_used_mb}MB"
|
||||
echo " RAM efficiency: $(( (total_allocated_mb * 100) / ($(free -m | awk '/^Mem:/{print $2}')) ))% of total RAM allocated to caches"
|
||||
}
|
||||
|
||||
show_troubleshooting() {
|
||||
echo -e "${BLUE}🔧 Troubleshooting${NC}"
|
||||
echo "=================="
|
||||
echo ""
|
||||
|
||||
echo "If tmpfs mounts are missing after reboot:"
|
||||
echo " sudo systemctl status system-optimization.service"
|
||||
echo " sudo systemctl restart system-optimization.service"
|
||||
echo ""
|
||||
|
||||
echo "If running out of tmpfs space:"
|
||||
echo " df -h /tmp/tmpfs-cache/* # Check which mount is full"
|
||||
echo " sudo umount /tmp/tmpfs-cache/[mount] # Temporarily unmount"
|
||||
echo " sudo mount -t tmpfs -o size=NEWSIZE tmpfs /tmp/tmpfs-cache/[mount]"
|
||||
echo ""
|
||||
|
||||
echo "If applications aren't using tmpfs:"
|
||||
echo " Check application-specific configuration files"
|
||||
echo " Some apps need restart after cache directory changes"
|
||||
echo " Use 'lsof /tmp/tmpfs-cache/*' to see which processes are using tmpfs"
|
||||
echo ""
|
||||
}
|
||||
|
||||
main() {
|
||||
case "${1:-status}" in
|
||||
"status"|"")
|
||||
show_tmpfs_status
|
||||
;;
|
||||
"config"|"configure")
|
||||
show_tmpfs_status
|
||||
echo ""
|
||||
show_configuration_guide
|
||||
;;
|
||||
"usage"|"monitor")
|
||||
show_tmpfs_status
|
||||
echo ""
|
||||
show_usage_tips
|
||||
;;
|
||||
"help"|"troubleshoot")
|
||||
show_tmpfs_status
|
||||
echo ""
|
||||
show_configuration_guide
|
||||
echo ""
|
||||
show_usage_tips
|
||||
echo ""
|
||||
show_troubleshooting
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [status|config|usage|help]"
|
||||
echo ""
|
||||
echo " status - Show tmpfs mount status (default)"
|
||||
echo " config - Show configuration guide for applications"
|
||||
echo " usage - Show monitoring and usage tips"
|
||||
echo " help - Show all information including troubleshooting"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user