Files
proxmox/scripts/maintenance/make-validator-vmids-writable-via-ssh.sh
defiQUG bea1903ac9
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Sync all local changes: docs, config, scripts, submodule refs, verification evidence
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-21 15:46:06 -08:00

78 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Make validator VMIDs (1000-1004) writable by running e2fsck on their rootfs.
# Fixes "Read-only file system" / JNA UnsatisfiedLinkError when Besu tries to write temp files.
# SSHs to r630-01 (1000,1001,1002) and ml110 (1003,1004), stops each CT, e2fsck, starts.
#
# Usage: ./scripts/maintenance/make-validator-vmids-writable-via-ssh.sh [--dry-run]
# Run from project root. Requires SSH to r630-01 and ml110 (root, key-based).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
[[ -f "${PROJECT_ROOT}/config/ip-addresses.conf" ]] && source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
R630_01="${PROXMOX_HOST_R630_01:-192.168.11.11}"
ML110="${PROXMOX_ML110:-192.168.11.10}"
SSH_OPTS="-o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new"
# Validators: 1000,1001,1002 on r630-01; 1003,1004 on ml110
VALIDATORS=(
"1000:$R630_01"
"1001:$R630_01"
"1002:$R630_01"
"1003:$ML110"
"1004:$ML110"
)
DRY_RUN=false
[[ "${1:-}" == "--dry-run" ]] && DRY_RUN=true
log_info() { echo -e "\033[0;34m[INFO]\033[0m $1"; }
log_ok() { echo -e "\033[0;32m[✓]\033[0m $1"; }
log_warn() { echo -e "\033[0;33m[⚠]\033[0m $1"; }
echo ""
echo "=== Make validator VMIDs writable (e2fsck) ==="
echo " dry-run=$DRY_RUN"
echo ""
for entry in "${VALIDATORS[@]}"; do
IFS=':' read -r vmid host <<< "$entry"
if ! ssh $SSH_OPTS "root@$host" "echo OK" 2>/dev/null; then
log_warn "Cannot SSH to $host; skip VMID $vmid"
continue
fi
log_info "VMID $vmid @ $host: stop, e2fsck, start..."
status=$(ssh $SSH_OPTS "root@$host" "pct status $vmid 2>/dev/null | awk '{print \$2}'" 2>/dev/null || echo "missing")
if [[ "$status" == "missing" || -z "$status" ]]; then
log_warn " VMID $vmid not found; skip"
continue
fi
if $DRY_RUN; then
log_info " [dry-run] would: pct stop $vmid; e2fsck -f -y /dev/pve/vm-${vmid}-disk-0; pct start $vmid"
continue
fi
ssh $SSH_OPTS "root@$host" "pct stop $vmid 2>/dev/null || true"
sleep 2
out=$(ssh $SSH_OPTS "root@$host" "lvchange -ay /dev/pve/vm-${vmid}-disk-0 2>/dev/null; e2fsck -f -y /dev/pve/vm-${vmid}-disk-0 2>&1" || true)
echo "$out" | tail -2
if echo "$out" | grep -q "FILE SYSTEM WAS MODIFIED\|No errors detected\|e2fsck"; then
log_ok " e2fsck done for $vmid"
else
log_warn " e2fsck may have failed for $vmid (LV name may differ)"
fi
ssh $SSH_OPTS "root@$host" "pct start $vmid 2>/dev/null" || log_warn " pct start $vmid failed"
sleep 2
if ssh $SSH_OPTS "root@$host" "pct exec $vmid -- touch /tmp/.w 2>/dev/null && pct exec $vmid -- rm -f /tmp/.w 2>/dev/null"; then
log_ok " VMID $vmid writable"
else
log_warn " VMID $vmid /tmp may still be read-only"
fi
done
echo ""
log_ok "Done. Restart validators: bash scripts/fix-all-validators-and-txpool.sh"
log_info "Then: bash scripts/monitoring/monitor-blockchain-health.sh"
echo ""