Add snapshot-based LVM migration scripts
- snapshot_migrate_to_internal.sh: Complete snapshot-based migration from external M.2 to internal NVMe - preview_snapshot_migration.sh: Preview script showing snapshot migration process - migrate_lvm_to_internal.sh: Alternative rsync-based migration script - preview_migration.sh: Preview for rsync-based migration Key features: - LVM snapshot creation of ALL logical volumes (root, home, boot, swap) - Block-level dd copying for exact system clone - Automatic LVM structure setup on internal drive - GRUB/EFI boot configuration - Future snapshot management tools - Space-efficient one-at-a-time processing Migration preserves complete live system state with bit-perfect accuracy.
This commit is contained in:
75
preview_migration.sh
Executable file
75
preview_migration.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# LVM Migration Preview Script
|
||||
# Shows current status and what the migration will do
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}=== LVM Migration Preview ===${NC}"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Current Boot Status:${NC}"
|
||||
echo "Root mounted from: $(findmnt -n -o SOURCE /)"
|
||||
echo "Boot mounted from: $(findmnt -n -o SOURCE /boot)"
|
||||
echo "Home mounted from: $(findmnt -n -o SOURCE /home)"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Current LVM Structure (External M.2):${NC}"
|
||||
sudo vgs migration-vg 2>/dev/null || echo "No VG found"
|
||||
echo
|
||||
sudo lvs migration-vg 2>/dev/null || echo "No LVs found"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Current Drive Layout:${NC}"
|
||||
echo "External M.2 (sda):"
|
||||
lsblk /dev/sda
|
||||
echo
|
||||
echo "Internal NVMe (nvme0n1):"
|
||||
lsblk /dev/nvme0n1
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Available Space Analysis:${NC}"
|
||||
echo "External VG size: $(sudo vgs --noheadings --units g -o vg_size migration-vg | tr -d ' ')B"
|
||||
echo "External VG free: $(sudo vgs --noheadings --units g -o vg_free migration-vg | tr -d ' ')B"
|
||||
echo "Internal drive size: $(lsblk -b -n -o SIZE /dev/nvme0n1 | awk '{printf "%.1fGB", $1/1024/1024/1024}')"
|
||||
echo
|
||||
|
||||
echo -e "${YELLOW}Migration Plan:${NC}"
|
||||
echo "1. ✅ Wipe internal NVMe drive completely"
|
||||
echo "2. ✅ Create new GPT partition table"
|
||||
echo "3. ✅ Create EFI boot partition (512MB)"
|
||||
echo "4. ✅ Create LVM partition (remaining space)"
|
||||
echo "5. ✅ Set up LVM with volume group 'internal-vg'"
|
||||
echo "6. ✅ Create logical volumes matching current structure"
|
||||
echo "7. ✅ Copy all data from external to internal"
|
||||
echo "8. ✅ Configure GRUB for LVM boot"
|
||||
echo "9. ✅ Set up LVM snapshot capabilities"
|
||||
echo "10. ✅ Reserve 20% space for snapshots"
|
||||
echo
|
||||
|
||||
echo -e "${RED}⚠️ WARNINGS:${NC}"
|
||||
echo "• This will COMPLETELY WIPE the internal NVMe drive"
|
||||
echo "• All current data on internal drive will be lost"
|
||||
echo "• Make sure you're booted from external M.2 (verified above)"
|
||||
echo "• Ensure external M.2 LED is active/blinking"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Snapshot Features After Migration:${NC}"
|
||||
echo "• lvm-snapshot-manager create - Create system snapshots"
|
||||
echo "• lvm-snapshot-manager list - List existing snapshots"
|
||||
echo "• lvm-snapshot-manager remove - Remove snapshots"
|
||||
echo "• lvm-snapshot-manager merge - Restore from snapshot"
|
||||
echo "• snapshot-backup - Backup using snapshots"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}Ready to proceed?${NC}"
|
||||
echo "Run: sudo ./migrate_lvm_to_internal.sh"
|
||||
echo
|
||||
echo -e "${YELLOW}Estimated time: 2-4 hours depending on data size${NC}"
|
||||
Reference in New Issue
Block a user