- Organized 252 files across project - Root directory: 187 → 2 files (98.9% reduction) - Moved configuration guides to docs/04-configuration/ - Moved troubleshooting guides to docs/09-troubleshooting/ - Moved quick start guides to docs/01-getting-started/ - Moved reports to reports/ directory - Archived temporary files - Generated comprehensive reports and documentation - Created maintenance scripts and guides All files organized according to established standards.
140 lines
4.6 KiB
Bash
Executable File
140 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Activate storage on r630-02 (local-lvm and thin1-thin6)
|
|
# Usage: ./scripts/activate-storage-r630-02.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
# Host configuration
|
|
R630_02_IP="192.168.11.12"
|
|
R630_02_PASSWORD="password"
|
|
R630_02_HOSTNAME="r630-02"
|
|
|
|
log_info "========================================="
|
|
log_info "Activating Storage on r630-02"
|
|
log_info "========================================="
|
|
echo ""
|
|
|
|
# Test connectivity
|
|
log_info "1. Testing connectivity to ${R630_02_IP}..."
|
|
if ping -c 2 -W 2 "$R630_02_IP" >/dev/null 2>&1; then
|
|
log_success "Host is reachable"
|
|
else
|
|
log_error "Host is NOT reachable"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Test SSH
|
|
log_info "2. Testing SSH access..."
|
|
if sshpass -p "$R630_02_PASSWORD" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@"$R630_02_IP" "echo 'SSH OK'" >/dev/null 2>&1; then
|
|
log_success "SSH access works"
|
|
else
|
|
log_error "SSH access failed"
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Activate storage
|
|
log_info "3. Activating storage..."
|
|
echo ""
|
|
|
|
sshpass -p "$R630_02_PASSWORD" ssh -o StrictHostKeyChecking=no root@"$R630_02_IP" bash <<'ENDSSH'
|
|
set -e
|
|
|
|
echo "=== Current Storage Status ==="
|
|
pvesm status 2>&1 || echo "Cannot list storage"
|
|
echo ""
|
|
|
|
echo "=== Available Volume Groups ==="
|
|
vgs 2>&1 || echo "No volume groups found"
|
|
echo ""
|
|
|
|
echo "=== Available Thin Pools ==="
|
|
lvs -o lv_name,vg_name,lv_size,data_percent,metadata_percent,pool_lv 2>&1 | grep -E "LV|thin" || echo "No thin pools found"
|
|
echo ""
|
|
|
|
echo "=== Current Storage Configuration ==="
|
|
cat /etc/pve/storage.cfg 2>/dev/null | grep -E "r630-02|local-lvm|thin[1-6]" || echo "No relevant storage config found"
|
|
echo ""
|
|
|
|
echo "=== Step 1: Updating storage.cfg node references ==="
|
|
# Backup
|
|
cp /etc/pve/storage.cfg /etc/pve/storage.cfg.backup.$(date +%Y%m%d_%H%M%S) 2>/dev/null || echo "Cannot backup storage.cfg"
|
|
|
|
# Update node references from "pve2" to "r630-02"
|
|
sed -i 's/nodes pve2$/nodes r630-02/' /etc/pve/storage.cfg 2>/dev/null || true
|
|
sed -i 's/nodes pve2 /nodes r630-02 /' /etc/pve/storage.cfg 2>/dev/null || true
|
|
sed -i 's/nodes pve2,/nodes r630-02,/' /etc/pve/storage.cfg 2>/dev/null || true
|
|
|
|
echo "Updated storage.cfg:"
|
|
cat /etc/pve/storage.cfg 2>/dev/null | grep -E "r630-02|local-lvm|thin[1-6]" || echo "No relevant entries found"
|
|
echo ""
|
|
|
|
echo "=== Step 2: Enabling local-lvm storage ==="
|
|
# Check if local-lvm exists
|
|
if pvesm status 2>/dev/null | grep -q "local-lvm"; then
|
|
echo "local-lvm storage found, enabling..."
|
|
pvesm set local-lvm --disable 0 2>&1 || echo "Failed to enable local-lvm (may already be enabled)"
|
|
else
|
|
echo "local-lvm storage not found in storage list"
|
|
echo "Checking if volume group exists..."
|
|
if vgs | grep -q "pve\|data"; then
|
|
echo "Volume group found. Storage may need to be added to storage.cfg"
|
|
fi
|
|
fi
|
|
echo ""
|
|
|
|
echo "=== Step 3: Enabling thin storage pools (thin1-thin6) ==="
|
|
for thin in thin1 thin2 thin3 thin4 thin5 thin6; do
|
|
if pvesm status 2>/dev/null | grep -q "$thin"; then
|
|
echo "Enabling $thin..."
|
|
pvesm set $thin --disable 0 2>&1 || echo "Failed to enable $thin (may already be enabled)"
|
|
else
|
|
echo "$thin storage not found in storage list"
|
|
echo "Checking if thin pool exists..."
|
|
if lvs | grep -q "$thin"; then
|
|
echo "$thin pool found. Storage may need to be added to storage.cfg"
|
|
fi
|
|
fi
|
|
done
|
|
echo ""
|
|
|
|
echo "=== Step 4: Verifying storage status ==="
|
|
echo "Storage Status:"
|
|
pvesm status 2>&1 || echo "Cannot list storage"
|
|
echo ""
|
|
|
|
echo "=== Step 5: Storage Details ==="
|
|
for storage in local-lvm thin1 thin2 thin3 thin4 thin5 thin6; do
|
|
if pvesm status 2>/dev/null | grep -q "$storage"; then
|
|
echo "--- $storage ---"
|
|
pvesm status 2>/dev/null | grep "$storage" || true
|
|
fi
|
|
done
|
|
echo ""
|
|
ENDSSH
|
|
|
|
echo ""
|
|
log_success "Storage activation complete for r630-02"
|
|
echo ""
|
|
log_info "Verification:"
|
|
log_info " - Check storage status above"
|
|
log_info " - Verify storage is enabled and accessible"
|
|
log_info " - Storage should now be available for VM/container creation"
|
|
echo ""
|