boot-fix/QUICK_REFERENCE.md
2025-08-28 11:30:41 -07:00

5.4 KiB

GRUB Repair Quick Reference

Essential Commands

1. System Detection

sudo ./grub-repair.sh detect

What this does: Shows all available disks, partitions, and identifies which ones are bootable Linux systems. When to use: First step - always run this to see what systems are available before attempting repairs. Output: Lists disks, partitions, filesystem types, and mount points.

sudo ./grub-repair.sh -d /dev/sda -p 1 -b fix-boot

What this does: Mounts your system, installs GRUB, updates configuration, and repairs EFI - all in one command with automatic backup. When to use: Your system won't boot, GRUB is missing/corrupted, or you need a complete boot recovery. Device note: Replace /dev/sda with your actual disk (use lsblk to find it).

3. Check Status

sudo ./grub-repair.sh status

What this does: Shows current mount status, available GRUB configurations, EFI partition status, and backup information. When to use: After mounting or during troubleshooting to see what's currently available and mounted. Output: Current system state, mounted filesystems, and backup locations.

4. Clean Up

sudo ./grub-repair.sh clean

What this does: Safely unmounts all systems, removes temporary mount points, and cleans up resources. When to use: After completing repairs, when switching between systems, or if something goes wrong. Safety: Automatically unmounts everything in the correct order to prevent data loss.

Common Scenarios

Fresh Boot Repair

# Detect your system first
sudo ./grub-repair.sh detect

# Then repair (replace /dev/sda with your device)
sudo ./grub-repair.sh -d /dev/sda -p 1 -b fix-boot

Step-by-step process:

  1. Detect: Identify available systems and their locations
  2. Repair: Complete boot repair with automatic backup
  3. Reboot: Restart your system to test the repair

Device identification: Use lsblk or fdisk -l to find your disk name if unsure.

GRUB Reinstall Only

# Mount system
sudo ./grub-repair.sh -d /dev/sda -p 1 mount

# Install GRUB
sudo ./grub-repair.sh install-grub

# Update config
sudo ./grub-repair.sh update-grub

# Unmount
sudo ./grub-repair.sh unmount

When to use: You only need to reinstall GRUB, not perform a complete repair. Manual control: Gives you step-by-step control over the GRUB installation process. Safety: Each step can be verified before proceeding to the next.

EFI Partition Check and Repair

sudo ./grub-repair.sh -d /dev/sda check-efi

What this does: Checks EFI partition health, repairs boot entries, and creates new GRUB boot entries if needed. When to use: EFI boot issues, missing boot entries, or when GRUB isn't showing up in UEFI boot menu. Advanced: Automatically detects your Linux distribution for proper bootloader ID.

Device Identification

  • Find your disk: lsblk or fdisk -l
  • EFI partition: Usually the first partition (e.g., /dev/sda1)
  • Root partition: Usually the second partition (e.g., /dev/sda2)

Common device names:

  • SATA drives: /dev/sda, /dev/sdb, /dev/sdc
  • NVMe drives: /dev/nvme0n1, /dev/nvme1n1
  • USB drives: /dev/sdd, /dev/sde (when booted from USB)

Safety Tips

  • Always use -b flag for backup - Creates automatic backups before making changes
  • Test on non-critical systems first - Verify the script works in your environment
  • Keep live ISO handy for recovery - You may need to boot from it again if issues arise
  • Document your partition layout - Note down which partitions are which before starting
  • Use -v flag for verbose output - Get detailed information during operations for troubleshooting

Troubleshooting

  • Permission denied: Use sudo - Script requires root access for system operations
  • Device not found: Check with lsblk - Verify device names and partition layout
  • Mount fails: Use clean command first - Cleans up any partial mounts
  • Verbose output: Add -v flag - Shows detailed operation information
  • Force mode: Use -f flag - Bypass live ISO detection if needed
  • Custom mount point: Use -m /path - Specify custom mount location

Additional Useful Commands

Manual Mounting

# Mount a specific system
sudo ./grub-repair.sh -d /dev/sda -p 1 mount

# Unmount current system
sudo ./grub-repair.sh unmount

# Check what's mounted
sudo ./grub-repair.sh status

Backup and Recovery

# Create backup only
sudo ./grub-repair.sh backup

# Check backup status
sudo ./grub-repair.sh status

Advanced Options

# Force mode (bypass live ISO check)
sudo ./grub-repair.sh -f -d /dev/sda detect

# Verbose output for debugging
sudo ./grub-repair.sh -v -d /dev/sda check-efi

# Custom mount point
sudo ./grub-repair.sh -m /mnt/custom -d /dev/sda mount

Quick Recovery Workflow

  1. Boot from Live ISO - Start your system from a live Linux ISO
  2. Detect Systems - sudo ./grub-repair.sh detect
  3. Identify Target - Note the device name and partition number
  4. Complete Repair - sudo ./grub-repair.sh -d /dev/DEVICE -p PARTITION -b fix-boot
  5. Clean Up - sudo ./grub-repair.sh clean
  6. Reboot - Restart and test your system

Pro tip: The -b flag creates automatic backups, so you can always restore if something goes wrong!