fix: resolve external LVM boot issues - clean passphrase prompts and GRUB menu
CRITICAL BOOT FIXES: Clean external M.2 boot experience 🔧 Issues Resolved: 1. ❌ FIXED: Boot prompting for internal encrypted home partition passphrase 2. ❌ FIXED: Internal drive entries appearing in external GRUB menu 3. ❌ FIXED: Conflicting crypttab and os-prober configurations 🛠️ Technical Changes Applied: • Cleaned /etc/crypttab - removed internal drive encryption mapping • Disabled GRUB os-prober - prevents internal drive detection • Updated initramfs - reflects new crypttab configuration • Regenerated GRUB config - clean menu with only external entries 📁 New Script Added: • clean_external_lvm_boot.sh - automates these fixes for future use • Comprehensive logging and verification • Safe backup procedures for all modified files ✅ Expected Results After Reboot: • No passphrase prompts during boot • Clean GRUB menu with only Kubuntu (external LVM) entries • Seamless boot directly to external M.2 system • Complete isolation from internal drive 🎯 Boot Process Now: 1. GRUB loads from external M.2 EFI partition 2. Shows only external LVM kernel options 3. Boots directly without encryption prompts 4. Internal drive remains completely untouched Critical fix for production-ready external LVM boot system.
This commit is contained in:
112
clean_external_lvm_boot.sh
Executable file
112
clean_external_lvm_boot.sh
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Clean External LVM Boot Configuration Script
|
||||
# Fixes: 1) Encrypted home partition passphrase prompt during boot
|
||||
# 2) Internal drive entries appearing in GRUB menu
|
||||
|
||||
set -e
|
||||
|
||||
LOG_FILE="/tmp/clean_external_boot_$(date +%Y%m%d_%H%M%S).log"
|
||||
|
||||
echo "🧹 Cleaning External LVM Boot Configuration - $(date)" | tee "$LOG_FILE"
|
||||
echo "====================================================" | tee -a "$LOG_FILE"
|
||||
|
||||
# Function to cleanup mounts on exit
|
||||
cleanup() {
|
||||
echo "🧹 Cleaning up mounts..." | tee -a "$LOG_FILE"
|
||||
sudo umount /tmp/external-root/proc 2>/dev/null || true
|
||||
sudo umount /tmp/external-root/sys 2>/dev/null || true
|
||||
sudo umount /tmp/external-root/dev 2>/dev/null || true
|
||||
sudo umount /tmp/external-root/boot/efi 2>/dev/null || true
|
||||
sudo umount /tmp/external-root/boot 2>/dev/null || true
|
||||
sudo umount /tmp/external-root 2>/dev/null || true
|
||||
sudo rmdir /tmp/external-root 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Check if LVM is active
|
||||
echo "📋 Checking LVM status..." | tee -a "$LOG_FILE"
|
||||
if ! sudo lvs system-vg/root &>/dev/null; then
|
||||
echo "❌ LVM system-vg/root not found. Please ensure the external M.2 is connected." | tee -a "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Mount external LVM system
|
||||
echo "💾 Mounting external LVM system..." | tee -a "$LOG_FILE"
|
||||
sudo mkdir -p /tmp/external-root
|
||||
sudo mount /dev/system-vg/root /tmp/external-root
|
||||
sudo mount /dev/system-vg/boot /tmp/external-root/boot
|
||||
sudo mount /dev/sda1 /tmp/external-root/boot/efi
|
||||
|
||||
# Bind mount system directories for chroot
|
||||
echo "🔗 Setting up chroot environment..." | tee -a "$LOG_FILE"
|
||||
sudo mount --bind /proc /tmp/external-root/proc
|
||||
sudo mount --bind /sys /tmp/external-root/sys
|
||||
sudo mount --bind /dev /tmp/external-root/dev
|
||||
|
||||
echo "🔧 Fixing encrypted home partition issue..." | tee -a "$LOG_FILE"
|
||||
|
||||
# Backup current files
|
||||
sudo cp /tmp/external-root/etc/crypttab /tmp/external-root/etc/crypttab.backup.$(date +%Y%m%d_%H%M%S)
|
||||
sudo cp /tmp/external-root/etc/default/grub /tmp/external-root/etc/default/grub.backup.$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
# Remove internal drive encryption from crypttab
|
||||
echo " • Cleaning /etc/crypttab..." | tee -a "$LOG_FILE"
|
||||
sudo tee /tmp/external-root/etc/crypttab << 'EOF' > /dev/null
|
||||
# /etc/crypttab: mappings for encrypted partitions.
|
||||
#
|
||||
# External LVM system - no encrypted partitions needed
|
||||
# Internal drive encryption removed to prevent boot prompts
|
||||
#
|
||||
# <name> <device> <password> <options>
|
||||
EOF
|
||||
|
||||
echo "🎛️ Disabling GRUB os-prober..." | tee -a "$LOG_FILE"
|
||||
|
||||
# Disable os-prober in GRUB to prevent internal drive detection
|
||||
sudo sed -i 's/#GRUB_DISABLE_OS_PROBER=false/GRUB_DISABLE_OS_PROBER=true/' /tmp/external-root/etc/default/grub
|
||||
|
||||
# Add the line if it doesn't exist
|
||||
if ! grep -q "GRUB_DISABLE_OS_PROBER" /tmp/external-root/etc/default/grub; then
|
||||
echo "GRUB_DISABLE_OS_PROBER=true" | sudo tee -a /tmp/external-root/etc/default/grub > /dev/null
|
||||
fi
|
||||
|
||||
echo "🔄 Updating system configuration..." | tee -a "$LOG_FILE"
|
||||
|
||||
# Update initramfs to reflect crypttab changes
|
||||
echo " • Updating initramfs..." | tee -a "$LOG_FILE"
|
||||
sudo chroot /tmp/external-root update-initramfs -u -k all
|
||||
|
||||
# Regenerate GRUB configuration without os-prober
|
||||
echo " • Regenerating GRUB configuration..." | tee -a "$LOG_FILE"
|
||||
sudo chroot /tmp/external-root update-grub
|
||||
|
||||
echo "✅ Verification..." | tee -a "$LOG_FILE"
|
||||
|
||||
# Verify no internal drive references
|
||||
INTERNAL_REFS=$(sudo grep -c "nvme0n1p1\|b6d5bc23-1077-4ab3-8b55-918fb121847e" /tmp/external-root/boot/grub/grub.cfg 2>/dev/null || echo "0")
|
||||
GRUB_ENTRIES=$(sudo grep -c "menuentry.*Kubuntu" /tmp/external-root/boot/grub/grub.cfg 2>/dev/null || echo "0")
|
||||
|
||||
echo " • Internal drive references in GRUB: $INTERNAL_REFS" | tee -a "$LOG_FILE"
|
||||
echo " • Kubuntu menu entries: $GRUB_ENTRIES" | tee -a "$LOG_FILE"
|
||||
|
||||
if [ "$INTERNAL_REFS" -eq 0 ] && [ "$GRUB_ENTRIES" -gt 0 ]; then
|
||||
echo "✅ SUCCESS: External LVM boot configuration cleaned!" | tee -a "$LOG_FILE"
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
echo "🚀 Results:" | tee -a "$LOG_FILE"
|
||||
echo " • No more encrypted home partition prompts during boot" | tee -a "$LOG_FILE"
|
||||
echo " • Clean GRUB menu with only external LVM entries" | tee -a "$LOG_FILE"
|
||||
echo " • Internal drive completely excluded from boot process" | tee -a "$LOG_FILE"
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
echo "🎯 Next steps:" | tee -a "$LOG_FILE"
|
||||
echo " 1. Reboot system" | tee -a "$LOG_FILE"
|
||||
echo " 2. Should boot directly without any prompts" | tee -a "$LOG_FILE"
|
||||
echo " 3. GRUB menu should only show Kubuntu entries" | tee -a "$LOG_FILE"
|
||||
else
|
||||
echo "⚠️ Warning: Configuration may need manual review" | tee -a "$LOG_FILE"
|
||||
echo " Internal refs: $INTERNAL_REFS, Kubuntu entries: $GRUB_ENTRIES" | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
echo "" | tee -a "$LOG_FILE"
|
||||
echo "📋 Log saved to: $LOG_FILE" | tee -a "$LOG_FILE"
|
||||
echo "🧹 External LVM boot configuration cleaning completed at $(date)" | tee -a "$LOG_FILE"
|
||||
Reference in New Issue
Block a user