Files
backup_to_external_m.2/lvm-migration-tools/check_packages.sh
Migration Tools 9d25520de9 Initial commit: Complete LVM migration toolset with fixes
- Fixed partition size calculation bugs in migrate_to_lvm.sh
- Added comprehensive error handling for USB drive stability
- Optimized data copy operations using cp -a for better performance
- Corrected mount point detection for encrypted home partitions
- Enhanced drive detection and exclusion logic
- Added proper size override mechanisms for manual intervention
- Improved filesystem creation and validation processes
- Complete toolset for external M.2 drive migration scenarios

Tested successfully on:
- Debian 13 Trixie Live USB environment
- 476GB external M.2 drives via USB 3.0
- Complex partition layouts (root/home/EFI + encryption)
- Large data transfers (314GB+ encrypted home directories)
2025-09-25 05:53:12 +00:00

92 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Package Availability Checker for Live Systems
# Checks what packages are available before attempting installation
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[FOUND]${NC} $1"; }
warning() { echo -e "${YELLOW}[MISSING]${NC} $1"; }
echo -e "${GREEN}=== Package Availability Checker ===${NC}"
echo "Checking package availability for LVM migration..."
echo
# Detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "Distribution: $PRETTY_NAME"
echo "ID: $ID"
echo "Version: $VERSION_ID"
echo
fi
# Function to check if a package exists in repositories
check_package() {
local pkg="$1"
if apt-cache show "$pkg" >/dev/null 2>&1; then
success "$pkg"
return 0
else
warning "$pkg"
return 1
fi
}
# Function to check multiple package alternatives
check_alternatives() {
local desc="$1"
shift
local packages=("$@")
echo -e "${BLUE}$desc:${NC}"
local found=0
for pkg in "${packages[@]}"; do
if check_package "$pkg"; then
((found++))
fi
done
if [ $found -eq 0 ]; then
echo -e " ${RED}⚠ No packages found for $desc${NC}"
fi
echo
}
echo "Updating package cache..."
apt update >/dev/null 2>&1 || warning "Could not update package cache"
echo
# Check critical packages
total_missing=0
check_alternatives "LVM Tools" "lvm2" "lvm"
check_alternatives "Device Mapper" "dmsetup" "device-mapper"
check_alternatives "Cryptsetup" "cryptsetup" "cryptsetup-bin"
check_alternatives "Filesystem Tools" "e2fsprogs" "dosfstools" "parted"
check_alternatives "Backup Tools" "rsync" "pv"
check_alternatives "GRUB EFI" "grub-efi-amd64" "grub-efi" "grub-efi-amd64-bin"
check_alternatives "GRUB PC" "grub-pc-bin" "grub-pc"
check_alternatives "GRUB Common" "grub-common" "grub2-common"
check_alternatives "Initramfs" "initramfs-tools" "dracut"
check_alternatives "System Tools" "util-linux" "coreutils" "bc"
echo -e "${BLUE}=== Summary ===${NC}"
echo -e "${GREEN}✓ Package availability checked${NC}"
echo "Most packages should be available for installation."
echo
echo "To install packages, run:"
echo " sudo ./emergency_install.sh"
echo
echo "To check individual commands after installation:"
echo " command -v lvm && echo 'LVM available'"
echo " command -v cryptsetup && echo 'Cryptsetup available'"
echo " command -v grub-install && echo 'GRUB available'"