Lewati ke konten
Kembali ke Blog

Troubleshooting Linux Boot Problems: GRUB Rescue dan Recovery

· · 6 menit baca

Boot failure adalah masalah yang menakutkan namun bisa diatasi dengan knowledge yang tepat. Artikel ini membahas troubleshooting langkah demi langkah untuk memperbaiki boot problems, termasuk GRUB rescue, filesystem corruption, dan kernel panic.

1. Understanding Boot Process

Linux Boot Sequence

1. BIOS/UEFI → POST (Power On Self Test)
2. Bootloader (GRUB) loaded dari MBR/EFI partition
3. Kernel loaded ke memory
4. Initramfs (initial RAM filesystem) loaded
5. Systemd/SysVinit started (PID 1)
6. Services started sesuai runlevel/target

Common Boot Failure Points

  • GRUB errors: Bootloader corruption atau misconfiguration
  • Kernel panic: Kernel module issues atau hardware problems
  • Filesystem errors: Corruption setelah unclean shutdown
  • Initramfs failure: Missing modules atau disk not found
  • Service failures: Critical service failed to start

2. GRUB Rescue Mode Recovery

Masuk ke GRUB Rescue

Ketika Anda melihat prompt seperti ini:

grub rescue>
# atau
grub>

Basic GRUB Rescue Commands

# List available devices
ls

Contoh output:

(hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3) (hd1)

Inspect partitions

ls (hd0,msdos1)

Cek filesystem

ls (hd0,msdos1)/

Set root partition

set root=(hd0,msdos1)

Load kernel (adjust path sesuai distro)

linux /boot/vmlinuz-5.15.0-91-generic root=/dev/sda1

atau

linux /vmlinuz-linux root=/dev/sda2

Load initramfs

initrd /boot/initrd.img-5.15.0-91-generic

atau

initrd /initramfs-linux.img

Boot

boot

GRUB Rescue untuk UEFI Systems

# List devices
ls

Set prefix (GRUB modules location)

set prefix=(hd0,gpt2)/boot/grub

Load modules

insmod normal insmod linux insmod ext2

Set root

set root=(hd0,gpt2)

Load kernel (UEFI path biasanya berbeda)

linux /vmlinuz-linux root=/dev/nvme0n1p2 rw initrd /initramfs-linux.img

boot

3. Filesystem Repair dan Recovery

Boot ke Recovery Mode

Ubuntu/Debian Recovery Mode

# Saat boot, tekan Shift atau Esc untuk masuk GRUB menu
# Pilih "Advanced options"
# Pilih kernel version dengan "(recovery mode)"

Dalam recovery menu:

1. clean - Free up disk space

2. dpkg - Repair broken packages

3. fsck - Filesystem check

4. grub - Update GRUB bootloader

5. network - Enable networking

6. root - Drop to root shell

Manual Filesystem Check

# Boot dari Live USB/CD
# Open terminal

Identify root partition

sudo fdisk -l

atau

lsblk

Mount filesystem (jika ext4)

sudo fsck -y /dev/sda1

Untuk specific checks

sudo fsck -f -y -v /dev/sda1

Options:

-f: Force check

-y: Auto yes untuk prompts

-v: Verbose

-n: Check only, don't repair (dry-run)

Repair Specific Filesystem Types

# EXT4 filesystem
e2fsck -f -y /dev/sda1

XFS filesystem (requires mount)

mount /dev/sda1 /mnt xfs_repair /dev/sda1

BTRFS filesystem

btrfs check /dev/sda1 btrfs rescue chunk-recover /dev/sda1

FAT32/NTFS (Windows partitions)

dosfsck -a /dev/sda1 ntfsfix /dev/sda1

4. GRUB Reinstall dan Repair

Reinstall GRUB dari Live USB

# Boot dari Live USB
# Open terminal

Mount root partition

sudo mount /dev/sda1 /mnt

Mount boot partition jika terpisah

sudo mount /dev/sda2 /mnt/boot

Mount EFI partition untuk UEFI systems

sudo mount /dev/sda3 /mnt/boot/efi

Mount virtual filesystems

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done

Chroot into system

sudo chroot /mnt

Reinstall GRUB (Legacy BIOS)

grub-install /dev/sda update-grub

Reinstall GRUB (UEFI)

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu update-grub

Exit chroot

exit

Unmount

for i in /mnt/run /mnt/sys /mnt/proc /mnt/dev/pts /mnt/dev; do sudo umount $i; done sudo umount /mnt

Reboot

reboot

Fix Common GRUB Issues

# GRUB prompt appears tanpa menu
# Boot ke live USB, chroot seperti di atas

Regenerate GRUB config

grub-mkconfig -o /boot/grub/grub.cfg

Set default entry

grub-set-default 0

Update GRUB dengan verbose

update-grub -v

Check GRUB configuration

cat /boot/grub/grub.cfg | less

5. Kernel Panic dan Module Recovery

Troubleshoot Kernel Panic

# Boot dengan safe mode
# Di GRUB, edit entry dengan 'e'
# Tambahkan ke kernel line: nomodeset single
# Press F10 atau Ctrl+X untuk boot

Atau tambahkan parameter kernel:

systemd.unit=rescue.target init=/bin/bash

Setelah masuk sistem:

Check kernel messages

dmesg | tail -100

Check loaded modules

lsmod

Rebuild initramfs

update-initramfs -u

Atau untuk specific kernel

update-initramfs -u -k 5.15.0-91-generic

Fix Broken Kernel Modules

# Boot ke recovery mode

Rebuild all initramfs images

update-initramfs -c -k all

Atau untuk specific version

update-initramfs -c -k $(uname -r)

Check module dependencies

depmod -a

Reinstall kernel packages (Ubuntu/Debian)

apt-get install --reinstall linux-image-generic

Regenerate GRUB

update-grub

6. Advanced Recovery Techniques

Reset Root Password

# Boot ke recovery mode atau edit GRUB entry
# Tambahkan init=/bin/bash ke kernel line

Mount filesystem dengan write access

mount -o remount,rw /

Change root password

passwd root

Atau untuk user lain

passwd username

Sync dan reboot

sync exec /sbin/reboot

Recover dari LVM/LUKS Encrypted System

# Boot dari Live USB

Unlock LUKS partition

sudo cryptsetup luksOpen /dev/sda3 cryptroot

Activate LVM volumes

sudo vgchange -ay

Mount filesystems

sudo mount /dev/mapper/ubuntu--vg-root /mnt sudo mount /dev/mapper/ubuntu--vg-boot /mnt/boot

Mount EFI jika UEFI

sudo mount /dev/sda1 /mnt/boot/efi

Chroot dan repair

sudo chroot /mnt update-grub grub-install /dev/sda exit

Cleanup

sudo umount -R /mnt sudo cryptsetup luksClose cryptroot

Repair Bootloader tanpa Chroot

# Direct GRUB repair dari Live USB
# Mount partitions
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys

Reinstall GRUB

sudo grub-install --root-directory=/mnt /dev/sda

Generate config

sudo chroot /mnt update-grub

Cleanup

sudo umount /mnt/dev sudo umount /mnt/proc sudo umount /mnt/sys sudo umount /mnt

Kesimpulan

Boot problems dapat diatasi dengan pendekatan yang systematic. Mulailah dengan diagnosis yang tepat: apakah ini GRUB issue, filesystem corruption, atau kernel problem. Gunakan Live USB sebagai tools recovery utama dan dokumentasikan setiap langkah.

Prevention Tips:
1. Selalu backup /boot dan /etc directory
2. Keep rescue Live USB ready
3. Jangan update kernel tanpa backup
4. Test GRUB changes di VM terlebih dahulu
5. Monitor disk space untuk /boot partition

Essential Recovery Commands:
fsck -y /dev/sda1 – Repair filesystem
grub-install /dev/sda – Reinstall GRUB
update-grub – Update GRUB configuration
update-initramfs -u – Rebuild initramfs
chroot /mnt – Access installed system

Ditulis oleh

Hendra Wijaya

Tinggalkan Komentar

Email tidak akan ditampilkan.