- Removed 40+ broken/messy scripts, moved to old_scripts/ - Created lvm_block_backup.sh - proper block-level LVM snapshot backup - Uses dd for block-level cloning instead of file-level rsync - Successfully tested: 462GB backup in 33 minutes - Creates exact, bootable clone of internal drive to external drive - Proper LVM snapshot management with cleanup - Clear documentation in README_BACKUP.md - Clean, minimal solution that actually works
75 lines
2.5 KiB
Bash
Executable File
75 lines
2.5 KiB
Bash
Executable File
#!/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}" |