Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
220 lines
6.1 KiB
Bash
Executable File
220 lines
6.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Script to migrate pve volume group from sdc/sdd to sda/sdb
|
|
# This prepares sdc/sdd for RAID 10 creation
|
|
|
|
set -u
|
|
|
|
TARGET_NODE="r630-01"
|
|
TARGET_NODE_IP="192.168.11.11"
|
|
TARGET_NODE_PASS="password"
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
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_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
|
|
ssh_r630_01() {
|
|
sshpass -p "$TARGET_NODE_PASS" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 root@"$TARGET_NODE_IP" "$@" 2>&1
|
|
}
|
|
|
|
check_storage() {
|
|
log_info "Checking current storage configuration..."
|
|
|
|
# Check sda/sdb availability
|
|
local sda_size=$(ssh_r630_01 "lsblk -bno SIZE /dev/sda 2>/dev/null | head -1")
|
|
local sdb_size=$(ssh_r630_01 "lsblk -bno SIZE /dev/sdb 2>/dev/null | head -1")
|
|
|
|
log_info "sda size: $sda_size bytes (~$(echo "scale=2; $sda_size/1024/1024/1024" | bc) GB)"
|
|
log_info "sdb size: $sdb_size bytes (~$(echo "scale=2; $sdb_size/1024/1024/1024" | bc) GB)"
|
|
|
|
# Check if sda/sdb are in use
|
|
if ssh_r630_01 "pvs 2>/dev/null | grep -q /dev/sda || mount | grep -q /dev/sda"; then
|
|
log_warn "sda is already in use"
|
|
return 1
|
|
fi
|
|
|
|
if ssh_r630_01 "pvs 2>/dev/null | grep -q /dev/sdb || mount | grep -q /dev/sdb"; then
|
|
log_warn "sdb is already in use"
|
|
return 1
|
|
fi
|
|
|
|
# Check current pve VG usage
|
|
local pve_size=$(ssh_r630_01 "vgs --units g --noheadings -o vg_size pve 2>/dev/null | tr -d ' '")
|
|
local pve_free=$(ssh_r630_01 "vgs --units g --noheadings -o vg_free pve 2>/dev/null | tr -d ' '")
|
|
local pve_used=$(echo "$pve_size - $pve_free" | bc)
|
|
|
|
log_info "Current pve VG: ${pve_size}GB total, ${pve_used}GB used, ${pve_free}GB free"
|
|
|
|
# Check if sda+sdb can hold the data
|
|
local sda_gb=$(echo "scale=2; $sda_size/1024/1024/1024" | bc | cut -d. -f1)
|
|
local sdb_gb=$(echo "scale=2; $sdb_size/1024/1024/1024" | bc | cut -d. -f1)
|
|
local total_available=$(echo "$sda_gb + $sdb_gb" | bc)
|
|
|
|
log_info "Available on sda+sdb: ~${total_available}GB"
|
|
|
|
if [ "$(echo "$total_available < $pve_used" | bc)" -eq 1 ]; then
|
|
log_error "sda+sdb may not have enough space for migration"
|
|
log_warn "Required: ${pve_used}GB, Available: ~${total_available}GB"
|
|
return 1
|
|
fi
|
|
|
|
log_success "Storage check passed"
|
|
return 0
|
|
}
|
|
|
|
prepare_sda_sdb() {
|
|
log_info "Preparing sda and sdb as physical volumes..."
|
|
|
|
# Check if partitions exist
|
|
if ssh_r630_01 "ls /dev/sda1 /dev/sdb1 2>/dev/null"; then
|
|
log_warn "sda and/or sdb have partitions. This script will use the whole disk."
|
|
log_warn "WARNING: This will destroy any existing partitions!"
|
|
read -p "Continue? (yes/no): " confirm
|
|
if [ "$confirm" != "yes" ]; then
|
|
return 1
|
|
fi
|
|
fi
|
|
|
|
# Create physical volumes
|
|
log_info "Creating physical volume on sda..."
|
|
ssh_r630_01 "pvcreate /dev/sda" || {
|
|
log_error "Failed to create PV on sda"
|
|
return 1
|
|
}
|
|
|
|
log_info "Creating physical volume on sdb..."
|
|
ssh_r630_01 "pvcreate /dev/sdb" || {
|
|
log_error "Failed to create PV on sdb"
|
|
return 1
|
|
}
|
|
|
|
log_success "Physical volumes created on sda and sdb"
|
|
return 0
|
|
}
|
|
|
|
extend_pve_vg() {
|
|
log_info "Extending pve volume group to include sda and sdb..."
|
|
|
|
# Extend VG
|
|
ssh_r630_01 "vgextend pve /dev/sda /dev/sdb" || {
|
|
log_error "Failed to extend pve VG"
|
|
return 1
|
|
}
|
|
|
|
log_success "pve VG extended to include sda and sdb"
|
|
|
|
# Show new VG status
|
|
log_info "Updated VG status:"
|
|
ssh_r630_01 "vgs pve"
|
|
|
|
return 0
|
|
}
|
|
|
|
migrate_data() {
|
|
log_info "Migrating data from sdc/sdd to sda/sdb..."
|
|
|
|
# Use pvmove to migrate data
|
|
log_info "Migrating data from sdc..."
|
|
ssh_r630_01 "pvmove /dev/sdc /dev/sda /dev/sdb" || {
|
|
log_error "Failed to migrate data from sdc"
|
|
return 1
|
|
}
|
|
|
|
log_info "Migrating data from sdd..."
|
|
ssh_r630_01 "pvmove /dev/sdd /dev/sda /dev/sdb" || {
|
|
log_error "Failed to migrate data from sdd"
|
|
return 1
|
|
}
|
|
|
|
log_success "Data migration completed"
|
|
return 0
|
|
}
|
|
|
|
remove_pvs() {
|
|
log_info "Removing sdc and sdd from pve volume group..."
|
|
|
|
# Remove PVs from VG
|
|
ssh_r630_01 "vgreduce pve /dev/sdc /dev/sdd" || {
|
|
log_error "Failed to remove PVs from VG"
|
|
return 1
|
|
}
|
|
|
|
# Remove physical volume labels
|
|
ssh_r630_01 "pvremove /dev/sdc /dev/sdd" || {
|
|
log_error "Failed to remove PV labels"
|
|
return 1
|
|
}
|
|
|
|
log_success "sdc and sdd removed from pve VG"
|
|
|
|
# Verify
|
|
log_info "Verifying pve VG status:"
|
|
ssh_r630_01 "vgs pve"
|
|
ssh_r630_01 "pvs | grep pve"
|
|
|
|
return 0
|
|
}
|
|
|
|
main() {
|
|
echo ""
|
|
log_info "=== Migration: pve VG from sdc/sdd to sda/sdb ==="
|
|
log_info "Purpose: Prepare sdc/sdd for RAID 10 creation"
|
|
echo ""
|
|
|
|
# Check storage
|
|
if ! check_storage; then
|
|
log_error "Storage check failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
log_warn "WARNING: This will migrate all data from sdc/sdd to sda/sdb"
|
|
log_warn "This process may take a while depending on data size"
|
|
read -p "Continue with migration? (yes/no): " confirm
|
|
if [ "$confirm" != "yes" ]; then
|
|
log_info "Operation cancelled"
|
|
exit 0
|
|
fi
|
|
|
|
# Prepare sda/sdb
|
|
if ! prepare_sda_sdb; then
|
|
log_error "Failed to prepare sda/sdb"
|
|
exit 1
|
|
fi
|
|
|
|
# Extend VG
|
|
if ! extend_pve_vg; then
|
|
log_error "Failed to extend VG"
|
|
exit 1
|
|
fi
|
|
|
|
# Migrate data
|
|
if ! migrate_data; then
|
|
log_error "Data migration failed"
|
|
log_warn "VG has been extended but migration incomplete"
|
|
exit 1
|
|
fi
|
|
|
|
# Remove old PVs
|
|
if ! remove_pvs; then
|
|
log_error "Failed to remove old PVs"
|
|
log_warn "Data migrated but sdc/sdd still in VG"
|
|
exit 1
|
|
fi
|
|
|
|
log_success "Migration completed successfully!"
|
|
log_info "sdc and sdd are now ready for RAID 10 creation"
|
|
echo ""
|
|
}
|
|
|
|
main "$@"
|