#!/bin/bash # Clear Lenovo BIOS Boot Flags # This script helps clear the "reset system" message shown before GRUB set -e echo "=== Lenovo BIOS Boot Flag Clear Utility ===" echo "" echo "The 'reset system' message you see before GRUB is from the Lenovo BIOS/UEFI firmware." echo "This typically indicates the BIOS detected an improper shutdown or boot failure." echo "" echo "Current boot configuration:" echo "- Root: internal-vg on nvme0n1 (internal drive)" echo "- Boot: internal-vg on nvme0n1 (internal drive)" echo "- EFI: nvme0n1p1 (internal drive)" echo "- Home: migration-vg on sda (external drive)" echo "" echo "Checking GRUB installation on internal drive..." if [ -f /boot/efi/EFI/ubuntu/shimx64.efi ]; then echo "✓ GRUB bootloader is properly installed on internal nvme0n1" else echo "✗ GRUB bootloader missing - need to reinstall" exit 1 fi echo "" echo "Checking EFI boot entries..." if efibootmgr | grep -q "ubuntu"; then echo "✓ Ubuntu boot entry exists in UEFI firmware" efibootmgr | grep ubuntu else echo "✗ Ubuntu boot entry missing" exit 1 fi echo "" echo "=== Solutions to Clear BIOS 'Reset System' Message ===" echo "" echo "OPTION 1: Clean Shutdown and Boot Sequence (Recommended)" echo " 1. Disconnect the external M.2 USB drive (sda)" echo " 2. Perform a clean shutdown: sudo shutdown -h now" echo " 3. Wait 10 seconds after system powers off" echo " 4. Power on the system" echo " 5. The BIOS should recognize the clean boot and clear the flag" echo "" echo "OPTION 2: Enter BIOS Setup" echo " 1. Reboot and press F1 (or F2) during POST to enter BIOS" echo " 2. Go to 'Startup' or 'Boot' menu" echo " 3. Check for any warnings or errors" echo " 4. Save and exit BIOS (F10)" echo " 5. This acknowledges any BIOS messages and clears flags" echo "" echo "OPTION 3: Reset BIOS Boot Order" echo " 1. Enter BIOS (F1 during boot)" echo " 2. Go to Startup → Boot menu" echo " 3. Ensure 'Ubuntu' is at the top of boot order" echo " 4. Disable 'Fast Boot' if enabled (can cause issues with dual boot)" echo " 5. Save and exit" echo "" echo "OPTION 4: Update UEFI Boot Entry Priority (from Linux)" echo " This will ensure Ubuntu on internal drive is the first boot option:" echo "" read -p "Do you want to set Ubuntu as the first boot option now? [y/N] " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then UBUNTU_ENTRY=$(efibootmgr | grep -i ubuntu | cut -d'*' -f1 | cut -d't' -f2 | head -1) if [ -n "$UBUNTU_ENTRY" ]; then echo "Setting Boot$UBUNTU_ENTRY (Ubuntu) as first boot option..." sudo efibootmgr -n $UBUNTU_ENTRY echo "✓ Next boot will use Ubuntu entry" echo "" echo "To make this permanent:" BOOT_ORDER=$(efibootmgr | grep BootOrder | cut -d':' -f2 | tr -d ' ') NEW_ORDER="$UBUNTU_ENTRY,${BOOT_ORDER//,${UBUNTU_ENTRY}/}" NEW_ORDER="${NEW_ORDER//${UBUNTU_ENTRY},,/,}" echo "Run: sudo efibootmgr -o $NEW_ORDER" else echo "Could not find Ubuntu boot entry" fi fi echo "" echo "=== Additional Diagnostics ===" echo "" echo "Check system journal for boot issues:" echo " sudo journalctl -b -p err" echo "" echo "Check hardware clock:" echo " sudo hwclock --show" echo "" echo "Verify GRUB is working:" echo " sudo grub-editenv list" echo "" echo "=== Why This Happens ===" echo "" echo "The Lenovo BIOS shows 'reset system' when:" echo "1. System was not shut down properly (power loss, crash, forced shutdown)" echo "2. BIOS detected a boot failure and wants you to acknowledge it" echo "3. Hardware configuration changed (like resizing partitions)" echo "4. BIOS boot counter wasn't properly reset after successful boot" echo "" echo "Since your GRUB is properly installed and working, this is just a BIOS" echo "notification that needs to be acknowledged through clean boot cycle."