feat: complete LVM backup system with external M.2 boot support
MAJOR MILESTONE: Transform backup system into comprehensive LVM migration solution 🎯 LVM Migration & Boot System Complete: - Complete external M.2 LVM migration capability - One-button migration from non-LVM to LVM system - Automatic GRUB repair and boot configuration - External boot validation and recovery tools 🔧 New Migration Tools Added: - fix_grub_lvm_boot.sh: Complete GRUB repair for external LVM boot - automated_clonezilla_backup.sh: Automated backup with Clonezilla integration - validate_lvm_migration.sh: Comprehensive migration validation - troubleshoot_migration.sh: Advanced diagnostic and repair tools - emergency_install.sh: Package installation for live systems - bootstrap_usb_tools.sh: USB preparation with all dependencies 💾 Backup System Enhancements: - create_alpine_backup_usb.sh: Alpine Linux live system preparation - create_clonezilla_backup.sh: Professional backup solution integration - plug_and_play_backup.sh: Simple automated backup workflow - lvm_snapshot_backup.sh: LVM snapshot-based incremental backups - simple_auto_backup.sh: Streamlined backup automation 📋 Documentation & Guides: - LIVE_USB_MIGRATION_GUIDE.md: Complete migration walkthrough - DRIVE_SELECTION_REFERENCE.md: Safe drive selection procedures - Comprehensive troubleshooting and validation procedures - Step-by-step migration instructions with safety checks 🛡️ Safety & Validation Features: - Interactive drive selection with confirmation - Comprehensive pre-migration checks - Automatic backup validation - GRUB boot repair with fallback options - Hardware compatibility verification 🧪 Testing & Debugging: - Complete GRUB configuration analysis - LVM volume validation and repair - Boot sequence troubleshooting - Hardware connection diagnostics ✅ Production Ready Status: - All migration tools tested and validated - External M.2 boot functionality confirmed - GRUB configuration properly generates LVM entries - Kernel files correctly deployed to external boot partition - EFI bootloader properly configured as 'ubuntu-external' This completes the transformation from simple backup scripts to a comprehensive LVM migration and backup system capable of full system migration to external M.2 with proper boot configuration and recovery capabilities.
This commit is contained in:
200
troubleshoot_migration.sh
Executable file
200
troubleshoot_migration.sh
Executable file
@@ -0,0 +1,200 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LVM Migration Troubleshooting Script
|
||||
# Helps diagnose issues with the migration process
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log() { echo -e "${BLUE}[$(date '+%H:%M:%S')]${NC} $1"; }
|
||||
error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }
|
||||
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
|
||||
echo -e "${GREEN}=== LVM Migration Troubleshooting ===${NC}"
|
||||
echo
|
||||
|
||||
# Check basic system requirements
|
||||
check_system() {
|
||||
log "Checking system requirements..."
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
error "This script must be run as root. Use: sudo $0"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if running from live system
|
||||
local root_device=$(df / | tail -1 | awk '{print $1}')
|
||||
if [[ "$root_device" == *"loop"* ]] || [[ "$root_device" == *"overlay"* ]] || [[ "$root_device" == *"tmpfs"* ]]; then
|
||||
success "Running from live system"
|
||||
else
|
||||
warning "Not running from live system - migration may fail"
|
||||
fi
|
||||
|
||||
# Check available tools
|
||||
local tools=("lvm" "cryptsetup" "rsync" "parted" "pv" "grub-install" "mkfs.ext4" "mkfs.fat" "bc" "wipefs")
|
||||
local missing=()
|
||||
|
||||
for tool in "${tools[@]}"; do
|
||||
if command -v "$tool" >/dev/null 2>&1; then
|
||||
success "Tool available: $tool"
|
||||
else
|
||||
missing+=("$tool")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#missing[@]} -gt 0 ]; then
|
||||
error "Missing tools: ${missing[*]}"
|
||||
echo "Run: sudo ./emergency_install.sh to install missing packages"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check drives
|
||||
check_drives() {
|
||||
log "Checking available drives..."
|
||||
|
||||
echo "All block devices:"
|
||||
lsblk -dpno NAME,SIZE,MODEL,VENDOR
|
||||
echo
|
||||
|
||||
# Look for likely candidates
|
||||
local internal_drives=($(lsblk -dpno NAME | grep -E "nvme|sda"))
|
||||
local usb_drives=()
|
||||
|
||||
# Check for USB drives
|
||||
for drive in $(lsblk -dpno NAME); do
|
||||
if udevadm info --query=property --name="$drive" | grep -q "ID_BUS=usb"; then
|
||||
usb_drives+=("$drive")
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Likely internal drives:"
|
||||
for drive in "${internal_drives[@]}"; do
|
||||
local info=$(lsblk -dpno NAME,SIZE,MODEL "$drive")
|
||||
echo " $info"
|
||||
done
|
||||
|
||||
echo "USB drives (external/migration stick):"
|
||||
for drive in "${usb_drives[@]}"; do
|
||||
local info=$(lsblk -dpno NAME,SIZE,MODEL "$drive")
|
||||
echo " $info"
|
||||
done
|
||||
}
|
||||
|
||||
# Check LVM status
|
||||
check_lvm() {
|
||||
log "Checking LVM status..."
|
||||
|
||||
echo "Physical volumes:"
|
||||
pvs 2>/dev/null || echo "No physical volumes found"
|
||||
|
||||
echo "Volume groups:"
|
||||
vgs 2>/dev/null || echo "No volume groups found"
|
||||
|
||||
echo "Logical volumes:"
|
||||
lvs 2>/dev/null || echo "No logical volumes found"
|
||||
|
||||
# Check for existing system-vg
|
||||
if vgs system-vg 2>/dev/null; then
|
||||
warning "system-vg already exists - migration may have partially completed"
|
||||
echo "To restart migration, you may need to:"
|
||||
echo " vgremove -f system-vg"
|
||||
echo " pvremove /dev/sdaX"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check filesystem space and usage
|
||||
check_filesystems() {
|
||||
log "Checking current filesystem usage..."
|
||||
|
||||
echo "Current mounts and usage:"
|
||||
df -h | grep -E "/$|/home$|/boot$"
|
||||
|
||||
echo
|
||||
echo "System memory:"
|
||||
free -h
|
||||
}
|
||||
|
||||
# Test LVM commands
|
||||
test_lvm_commands() {
|
||||
log "Testing LVM command availability..."
|
||||
|
||||
# Test basic LVM commands
|
||||
lvm version || error "LVM not working"
|
||||
|
||||
# Test if we can create a test PV (on a loop device)
|
||||
log "Testing LVM functionality with loop device..."
|
||||
|
||||
# Create a small test file
|
||||
dd if=/dev/zero of=/tmp/lvm-test.img bs=1M count=100 2>/dev/null
|
||||
local loop_device=$(losetup -f --show /tmp/lvm-test.img)
|
||||
|
||||
if pvcreate "$loop_device" 2>/dev/null; then
|
||||
success "LVM pvcreate works"
|
||||
|
||||
if vgcreate test-vg "$loop_device" 2>/dev/null; then
|
||||
success "LVM vgcreate works"
|
||||
|
||||
if lvcreate -L 50M -n test-lv test-vg 2>/dev/null; then
|
||||
success "LVM lvcreate works"
|
||||
success "All LVM commands working correctly"
|
||||
else
|
||||
error "LVM lvcreate failed"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
lvremove -f test-vg/test-lv 2>/dev/null || true
|
||||
vgremove -f test-vg 2>/dev/null || true
|
||||
else
|
||||
error "LVM vgcreate failed"
|
||||
fi
|
||||
|
||||
pvremove -f "$loop_device" 2>/dev/null || true
|
||||
else
|
||||
error "LVM pvcreate failed"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
losetup -d "$loop_device" 2>/dev/null || true
|
||||
rm -f /tmp/lvm-test.img
|
||||
}
|
||||
|
||||
# Generate report
|
||||
generate_report() {
|
||||
echo
|
||||
echo -e "${BLUE}=== Troubleshooting Report ===${NC}"
|
||||
echo "Generated: $(date)"
|
||||
echo "System: $(hostname)"
|
||||
|
||||
if check_system && check_drives && check_lvm && check_filesystems && test_lvm_commands; then
|
||||
echo
|
||||
success "All checks passed - system should be ready for migration"
|
||||
echo
|
||||
echo "To run migration:"
|
||||
echo "1. sudo ./migrate_to_lvm.sh"
|
||||
echo "2. Follow the interactive prompts"
|
||||
echo "3. Carefully select source and target drives"
|
||||
else
|
||||
echo
|
||||
error "Some checks failed - see messages above"
|
||||
echo
|
||||
echo "Common solutions:"
|
||||
echo "• Run: sudo ./emergency_install.sh (for missing packages)"
|
||||
echo "• Reboot from live USB (if not in live system)"
|
||||
echo "• Check drive connections (if drives not detected)"
|
||||
echo "• Remove existing LVM setup (if system-vg exists)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
generate_report
|
||||
fi
|
||||
Reference in New Issue
Block a user