Skip to content

Napaka pri zagonu sistema Linux in popravilo GRUB: vodnik za obnovitev v ukazni vrstici

Napaka pri zagonu sistema Linux lahko brez opozorila zaustavi delovne postaje, produkcijske strežnike in prenosnike z dvojnim zagonom, kar vas pahne v popolno grub rescue> hitro, minimalno grub> lupina, an (initramfs) oz dracut:/# zasilna konzola, sistemd "You are in emergency mode" poziv za vzdrževanje ali črn zaslon z utripajočim kazalcem.

Za razliko od operacijskih sistemov, ki zagonsko mehaniko skrivajo za nepreglednimi grafičnimi kodami napak, Linux vsako stopnjo zagonskega cevovoda izpostavi neposredno skrbniku. Skoraj vsaka napaka pri zagonu Linuxa izvira iz enega od petih popravljivih vzrokov: prepisan ali napačno konfiguriran zagonski nalagalnik GRUB 2 (običajno se sproži po posodobitvi sistema Windows na računalniku z dvojnim zagonom), umazan ext4/xfs/btrfs korenski datotečni sistem po nenadnem izpadu električne energije, pokvarjen /etc/fstab vnos diska UUID, 100-odstotni polni koren (/) pomnilniško particijo ali prekinjeno nadgradnjo jedra in grafičnega gonilnika. Ujemanje natančnega poziva na zaslonu z ustrezno stopnjo zagona vam omogoča čisto popravilo sistema brez formatiranja pogona ali izgube podatkov.

Naredi to zdaj

Ko se vaš računalnik ali strežnik Linux noče zagnati, sledite tem šestim takojšnjim diagnostičnim in varnostnim korakom, preden zaženete kakršne koli uničujoče ukaze za disk:

  1. Preberite natančen poziv na zaslonu, da ugotovite, katera stopnja zagona ni uspela:
    • grub rescue> oz grub>: Matična plošča UEFI/BIOS je naložila prvo stopnjo GRUB, vendar GRUB ne more najti /boot/grub ali njegovo konfiguracijsko datoteko (grub.cfg).
    • (initramfs) oz dracut:/#: GRUB je dobro naložil jedro Linuxa in začetni disk RAM, vendar jedro ni moglo namestiti vašega glavnega korena (/) datotečni sistem (običajno zato, ker fsck treba popraviti umazan disk).
    • You are in emergency mode / Give root password for maintenance: Korenski datotečni sistem je nameščen, vendar systemd ni uspelo namestiti sekundarnega pogona, navedenega v /etc/fstab.
    • Črn zaslon z utripajočim kazalcem za menijem GRUB: Operacijski sistem se je zagnal, vendar grafični upravitelj zaslona (GDM, SDDM, LightDM) ni uspel zaradi 100-odstotno polnega korenskega diska ali pokvarjenega gonilnika Nvidia/AMD GPE.
  2. Najprej poskusite zagnati prejšnje jedro Linuxa iz menija GRUB: znova zaženite stroj in držite Shift (BIOS) ali tapnite Esc večkrat (UEFI) takoj za logotipom proizvajalca, da prikažete meni GRUB. Izberite "Napredne možnosti za Ubuntu / Debian / Fedora" in izberite drugo najstarejše jedro na seznamu. Če je nedavna posodobitev jedra pokvarila vašo initramfs ali modul GPU, se bo prejšnje jedro zagnalo naravnost v vaše namizje v 10 sekundah.
  3. Preklopi na navidezno besedilno konzolo TTY, če obtiči na črnem zaslonu: Če zagonsko zaporedje zamrzne na črnem zaslonu z utripajočo podčrtajo ali zataknjenim logotipom, pritisnite Ctrl + Alt + F3 (oz Ctrl + Alt + F2 skozi F6). Če a login: prikaže besedilni poziv, se vaš sistem Linux dejansko izvaja, prijavite se s svojim uporabniškim imenom in geslom, da počistite ves prostor na disku ali popravite grafične gonilnike.
  4. Nikoli ne tecite fsck na particiji, ki je trenutno nameščena branje-pisanje: Teče fsck na živem, za branje in pisanje nameščenem datotečnem sistemu pokvari odprte tabele inode in uniči datoteke. Samo teči fsck od (initramfs) lupina (kjer je root odklopljen), na namestitvi samo za branje ali s ključka Live USB.
  5. Odklopite vse nepomembne zunanje trde diske USB in kartice SD: Okvarjeni zunanji pogon USB je naveden v /etc/fstab ali prevzem prioritete zagona v BIOS-u bo zaustavil zagonsko zaporedje. Odklopite zunanje pogone in znova zaženite, da preizkusite.
  6. Pripravite ključek USB Live Linux, če GRUB ali jedro popolnoma manjka: Imejte pri roki zagonski ključ USB Live (Ubuntu, Linux Mint, Fedora ali SystemRescue), da lahko namestite svoje šifrirane ali standardne particije in zaženete chroot popravilo zagonskega nalagalnika.

Kritično: česa NE storiti

Nikoli ne teci grub-install, dd, fdisk, oz mkfs dokler ne preverite svoje natančne postavitve diska in particije z uporabo lsblk -f oz blkid. Imena vozlišč naprav, kot so /dev/sda in /dev/sdb jih dinamično dodeli jedro Linuxa ob zagonu in lahko zamenjajo vrstni red, ko je priključen USB-ključ Live. Nenamerno formatiranje ali prepisovanje particijske tabele napačnega /dev/sdX disk bo uničil vaše podatke. Poleg tega nikoli ne zaženite pripomočkov za popravilo datotečnega sistema, kot je fsck na particijah, nameščenih za branje in pisanje, nikoli ne izklopite sistema na silo med aktivno nadgradnjo paketa jedra ali zagonskega nalagalnika in nikoli ne izbrišite sistemskih knjižnic v /usr/lib oz /lib pri poskusu čiščenja prostora na polnem korenskem pogonu.

Odločitveno drevo: diagnosticiranje 5 stopenj napake pri zagonu Linuxa

Uporabite ta diagram poteka diagnostike, da izsledite natančen izpis zaslona do ustreznega popravka ukazne vrstice:

flowchart TD
    A["Sistem Linux se ne zažene v namizje/prijava"] --> B{"Kaj je prikazano na zaslonu?"}
    B -->|"grub rescue> ali grub> poziv"| C["Napaka 1. stopnje: uporabite ls za iskanje /boot/grub, nastavite koren in predpono, zaženite OS, nato zaženite grub-install"]
    B -->|"BusyBox (initramfs) ali lupina dracut:/#"| D["Napaka 2. stopnje: Identificirajte korensko particijo z blkid in zaženite fsck -y /dev/partition"]
    B -->|"Način v sili: Za vzdrževanje vnesite geslo root"| E["Napaka 3. stopnje: zaženite mount -o remount,rw / in popravite ali komentirajte pokvarjen UUID v /etc/fstab"]
    B -->|"Črn zaslon ali utripajoč kazalec po GRUB"| F["Napaka 4. stopnje: Pritisnite Ctrl+Alt+F3 (ali zaženite Emergency.target), da počistite 100 % poln disk ali gonilnik GPE"]
    B -->|"Zažene se naravnost v Windows ali »Brez zagonske naprave«"| G["Vrstni red zagona UEFI/EFI je izbrisan: zaženite Live USB, namestite Root + EFI, chroot in znova namestite GRUB"]

Primerjava pozivov, vzrokov in ukazov za napake pri zagonu Linuxa

Napaka na zaslonu/poziv Dosežena stopnja zagona Primarni vzrok Najhitrejše zaporedje ukazov za popravilo
error: no such partition / grub rescue> 1. stopnja (Jedro GRUB) Diskovne particije spremenjene velikosti, klonirane ali UUID spremenjen; GRUB ne najde /boot/grub/normal.mod. ls -> set root=(hdX,gptY) -> set prefix=(hdX,gptY)/boot/grub -> insmod normal -> normal
grub> (Standardni GRUB CLI) Stopnja 1.5 (normalno GRUB) /boot/grub/grub.cfg manjka ali je izbrisan, čeprav so se moduli GRUB dobro naložili. set root=(hdX,gptY) -> linux /boot/vmlinuz-... root=/dev/nvme0n1p2 -> initrd /boot/initrd.img-... -> boot
BusyBox (initramfs) ali dracut:/# 2. stopnja (jedro + Initramfs) Nečist izklop levo ext4/xfs korenski dnevnik umazan, potreben je priročnik fsck odobritev. blkid -> fsck -y /dev/nvme0n1p2 (oz xfs_repair -L za XFS) -> reboot -f
You are in emergency mode (sulogin hitro) 3. stopnja (systemd nosilci) Sekundarni pogon ali izmenjalna particija /etc/fstab je bil odklopljen, preoblikovan ali poškodovan. Vnesite root geslo -> mount -o remount,rw / -> nano /etc/fstab (dodaj nofail oz #) -> systemctl daemon-reload -> reboot
[FAILED] Failed to start GNOME Display Manager / Utripajoč kazalec Faza 4 (Upravitelj zaslona / GUI) Korenska particija / je 100 % polno (0 bajtov prostih za /tmp ali vtičnice Xorg) ALI pokvarjen modul jedra Nvidia (dkms). Pritisnite Ctrl+Alt+F3 -> df -h -> journalctl --vacuum-size=100M & apt clean ALI ubuntu-drivers autoinstall

Scenarij 1: Pobeg iz grub rescue> oz grub> poziv brez ključka USB

Če se vaš zaslon prikaže error: unknown filesystem, error: no such partition, oz Minimal BASH-like line editing is supported sledi grub rescue> oz grub>vaša namestitev Linuxa in osebne datoteke običajno še vedno nedotaknjene na vašem SSD ali trdem disku, je GRUB preprosto izgubil sled, katera particija je /boot/grub. Iz tega poziva se lahko v 2 minutah neposredno zaženete v nameščen OS:

Primer A: Ste na grub rescue> poziv

pri grub rescue>delujejo samo štirje osnovni ukazi (ls, set, unset, in insmod). Pazljivo sledite tem korakom:

  1. Seznam vseh diskov in particij, ki jih vidi vdelana programska oprema matične plošče:
    grub rescue> ls
    
    GRUB bo natisnil vrstico, kot je: (hd0) (hd0,gpt1) (hd0,gpt2) (hd0,gpt3) (oz (hd0,msdos1) na starejših diskih MBR).
  2. Preglejte vsako particijo, dokler ne najdete korena Linuxa (ali /boot) imenik: (Ne pozabite vključiti končne poševnice / na koncu vsakega ls preverite, da GRUB izpiše imena datotek znotraj te particije):
    grub rescue> ls (hd0,gpt1)/
    grub rescue> ls (hd0,gpt2)/
    grub rescue> ls (hd0,gpt3)/
    
  3. če (hd0,gpt1)/ kaže efi/, to je vaša majhna sistemska particija FAT32 EFI.
  4. Ko particija izpiše boot/ etc/ home/ usr/ var/ vmlinuz initrd.img, ste našli glavno korensko particijo Linuxa (npr. (hd0,gpt2)). (Opomba: če uporabljate Btrfs z @ podvolume na Ubuntu/Fedora, ls (hd0,gpt2)/ bo pokazal @/ @home/, kar pomeni, da je vaša zagonska mapa na (hd0,gpt2)/@/boot/grub.)
  5. Pokažite GRUB na svojo particijo in naložite normal modul: Ob predpostavki, da je vaš root Linux vklopljen (hd0,gpt2):
    grub rescue> set root=(hd0,gpt2)
    grub rescue> set prefix=(hd0,gpt2)/boot/grub
    grub rescue> insmod normal
    grub rescue> normal
    
    (Če imate ločen namenski /boot particija na (hd0,gpt2), uporabite set prefix=(hd0,gpt2)/grub brez /boot.)
  6. Naj bo popravek trajen, ko se namizje zažene: Takoj ko normal zažene, se prikaže vaš običajni meni GRUB in zažene vaš sistem Linux. Pomembno: Tisti set ukazi so bili začasni v RAM-u. V trenutku, ko se prijavite v namizje Linux, odprite terminal in trajno zapišite pravilno lokacijo GRUB na svoj pogon:
    sudo update-grub
    sudo grub-install /dev/nvme0n1   # (Or /dev/sda ,  use your whole disk name, NOT a partition number)
    

Primer B: Ste na standardu grub> poziv

Če vidite grub> (brez besede rescue), the normal modul je že naložen, vaš grub.cfg menijska datoteka manjka ali je pokvarjena. Jedro Linuxa lahko ročno zaženete v štirih vrsticah z uporabo samodejnega dokončanja zavihkov:

grub> set root=(hd0,gpt2)
grub> linux /boot/vmlinuz-6.8.0-45-generic root=/dev/nvme0n1p2 ro
grub> initrd /boot/initrd.img-6.8.0-45-generic
grub> boot
(Nasvet: Samo vnesite linux /boot/vmlinuz in pritisnite tabulatorsko tipko, bo GRUB samodejno dokončal točne številke različice jedra, nameščenega na vašem disku.) Ko se zaženete v vaš OS, zaženite sudo update-grub (Debian/Ubuntu) oz sudo grub2-mkconfig -o /boot/grub2/grub.cfg (Fedora/RHEL), da ponovno ustvarite manjkajočo datoteko menija.

Scenarij 2: Popravljanje (initramfs) oz dracut školjke z fsck

Če vaš računalnik preide mimo menija GRUB, se za nekaj sekund prikaže zagonsko sporočilo Linuxa, nato pa preide v črno besedilo:

BusyBox v1.36.1 (Ubuntu) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs) _
Poglejte 3 do 5 vrstic nad (initramfs) poziv. Devetkrat od desetih boste videli: The root filesystem on /dev/nvme0n1p2 requires a manual fsck

Popravilo datotečnega sistema po korakih iz (initramfs)

  1. Potrdite, katera particija potrebuje popravilo: Če ime particije ni natisnjeno tik nad pozivom, vnesite blkid in pritisnite Enter, da prikažete svoje ext4, xfs, oz btrfs predelne stene.
  2. Zaženite ustrezno orodje za popravilo datotečnega sistema:
    • Za ext4 / ext3 datotečni sistemi (privzeto na Ubuntu, Debian, Mint):
      (initramfs) fsck -y /dev/nvme0n1p2
      
      The -y zastavica samodejno odgovori z "da" na vsak poškodovan inode, osirotel blok in poziv za ponovno predvajanje dnevnika, namesto da pritisnete y 500-krat.
    • Za XFS datotečni sistemi (privzeto na RHEL, AlmaLinux, Rocky Linux, CentOS): Standardno fsck na XFS ne naredi ničesar. V a dracut:/# lupino v sistemu XFS zaženite:
      dracut:/# xfs_repair /dev/mapper/rhel-root
      
      (Only pass the -L flag to zero the XFS metadata log if xfs_repair refuses to run due to an unmountable dirty log and you have no other option).
    • Za Btrfs filesystems (default on Fedora, openSUSE): First try clearing the Btrfs log tree safely with btrfs rescue zero-log /dev/nvme0n1p2. Never run btrfs check --repair unless instructed by a Btrfs developer or after backing up data from a Live USB, as --repair is considered dangerous on Btrfs.
  3. Exit and reboot: Once fsck prints ***** FILE SYSTEM WAS MODIFIED *****, type exit (oz reboot -f) and press Enter. Your system will mount the clean partition and boot normally.

Scenario 3: Fixing /etc/fstab errors in systemd Emergency Mode

If your screen stops mid-boot with:

You are in emergency mode. After logging in, type "journalctl -xb" to view system logs,
"systemctl reboot" to reboot, or "exit" to continue bootup.
Give root password for maintenance (or press Control-D to continue):
This almost always happens because you edited /etc/fstab, formatted a swap partition (which changed its UUID), or unplugged a secondary internal/external hard drive that is listed in /etc/fstab without the nofail option. By default, systemd halts the entire operating system boot if any disk listed in /etc/fstab fails to respond within 90 seconds.

How to fix /etc/fstab in 90 seconds

  1. Type your root password (or press Enter if on Ubuntu where the root account is locked and it drops you in directly; if Ubuntu says Cannot open access to console, the root account is locked, see the init=/bin/bash note below).
  2. Remount the root filesystem as Read-Write: In emergency mode, / is often mounted Read-Only, so if you try to save /etc/fstab, nano will say Error writing /etc/fstab: Read-only file system. Run this first:
    mount -o remount,rw /
    
  3. Find out which line in /etc/fstab is broken: Run mount -a. Whatever drive is broken will immediately print an error (for example, mount: /mnt/backup: can't find UUID=4a8b...). You can also compare your real drive UUIDs against /etc/fstab by running:
    blkid
    cat /etc/fstab
    
  4. Edit /etc/fstab and add nofail or comment out the bad line:
    nano /etc/fstab
    
    Put a # at the start of the broken secondary drive or swap line to disable it (or add ,nofail to the mount options column such as defaults,nofail so Linux never refuses to boot when that external drive is unplugged). Save with Ctrl+O, press Enter, and exit with Ctrl+X.
  5. Reload systemd and verify before rebooting:
    systemctl daemon-reload
    mount -a
    
    če mount -a returns zero errors, type reboot and your computer will boot cleanly.

Warning

What if Ubuntu/Debian says "Cannot open access to console, the root account is locked" at the Emergency Mode prompt? Because Ubuntu disables the root password by default in favor of sudo, sulogin sometimes locks you out of Emergency Mode if a disk in /etc/fstab fails. To bypass that lock in 30 seconds: reboot, hold Shift or tap Esc to open the GRUB menu, highlight Ubuntu, press e to edit the boot command, find the line starting with linux /boot/vmlinuz..., replace ro quiet splash at the end of that line with rw init=/bin/bash, and press Ctrl+X ali F10. This bypasses systemd completely and drops you straight into an unlocked # root shell with read-write access so you can run nano /etc/fstab.

Scenario 4: Recovering from a 100% full root (/) disk or broken GPU driver

If your PC passes GRUB smoothly, shows no filesystem errors, and then hangs forever on a black screen with a blinking cursor in the top-left corner (or loops back to the login screen every time you type your password and press Enter), your root partition (/) is almost certainly 100% full. When / has 0 megabytes of free space, Xorg, Wayland, and GNOME/KDE cannot create a 4-kilobyte session lock file in /tmp oz /var/lib, causing the desktop to silently crash.

How to free gigabytes of space from the TTY console

  1. At the black blinking cursor screen (or looping login screen), press Ctrl + Alt + F3 (on laptops, you may need Ctrl + Alt + Fn + F3) to switch from the frozen graphical screen (TTY1/TTY2) to a pure text terminal (TTY3).
  2. Log in with your normal username and password, then check disk usage:
    df -h /
    
  3. če Use% kaže 100% (oz Avail kaže 0), run these four safe cleanup commands to free 2 GB to 25 GB of space immediately:
    # 1. Clear downloaded package cache (.deb / .rpm archives sitting in /var/cache):
    sudo apt-get clean                       # (Ubuntu/Debian/Mint)
    # sudo dnf clean all                     # (Fedora/RHEL)
    
    # 2. Shrink bloated systemd system logs down to 100 MB:
    sudo journalctl --vacuum-size=100M
    
    # 3. Remove old unused Linux kernel versions and orphaned packages:
    sudo apt-get autoremove --purge -y
    
    # 4. Find the top 10 largest folders inside /var (e.g., Docker, Snap, or runaway /var/log/syslog):
    sudo du -xh /var | sort -rh | head -n 15
    
    (If a runaway log file like /var/log/syslog oz /var/log/ufw.log has ballooned to 50 GB, empty it instantly with sudo truncate -s 0 /var/log/syslog.)
  4. Why does df -h sometimes show Avail: 0 (100% full) when only 95% of the disk is used? By default, ext4 reserves 5 percent of the entire partition exclusively for the root uporabnik, tako da lahko korenske storitve še vedno delujejo, ko običajni uporabnik napolni disk. Na 1-terabajtnem SSD-ju je 5 % ogromnih 50 GB talcev. Takoj lahko povrnete 40+ GB tega rezerviranega medpomnilnika za svoj običajni uporabniški račun, tako da zaženete:
    sudo tune2fs -m 1 /dev/nvme0n1p2   # Reduces reserved root blocks from 5% to 1% immediately
    
  5. Enkrat df -h / prikaže nekaj razpoložljivih gigabajtov, zaženite sudo reboot in vaše grafično namizje se bo normalno prijavilo.

Kaj če df -h ima dovolj prostega prostora in črn zaslon se je začel po posodobitvi gonilnika ali jedra Nvidia?

Če vaš disk ni poln in se je črn zaslon začel takoj po posodobitvi na osebnem računalniku z grafično kartico Nvidia, lastniški modul jedra Nvidia (nvidia.ko) ni uspelo prevesti prek dkms za vaše novo jedro ali pa je Secure Boot blokiral nepodpisan modul:

  1. Od Ctrl + Alt + F3 Konzola TTY, preverite, ali je modul gonilnika naložen z zagonom nvidia-smi.
  2. če nvidia-smi pravi NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver, bodisi onemogočite Secure Boot v nastavitvah UEFI/BIOS matične plošče (če varni zagon blokira nepodpisan modul DKMS) ali znova sestavite glave in gonilnik jedra:
    # Install missing kernel headers for your currently running kernel and rebuild DKMS:
    sudo apt update
    sudo apt install --reinstall linux-headers-$(uname -r) build-important dkms
    sudo dpkg-reconfigure nvidia-dkms-*   # Or run: sudo ubuntu-drivers autoinstall
    sudo update-initramfs -u
    sudo reboot
    

Scenarij 5: Dokončaj Live USB chroot reševanje (za izbrisane EFI/GRUB, LVM, LUKS in Btrfs)

Ko posodobitev sistema Windows 11 prepiše vaše zagonske vnose UEFI, se posodobitev jedra med delovanjem zruši, medtem ko zmanjka električne energije ali grub rescue> ne more brati vaše particije, zaženite računalnik s pogona Live Linux USB USB (izberite "Poskusi Ubuntu" ali način namizja v živo) in izvedite chroot (Change Root) popravilo. A chroot omogoča, da vaš Live USB terminal stopi v vašo pokvarjeno namestitev SSD in zažene apt, dnf, update-initramfs, in grub-install kot da bi se sistem normalno zagnal.

1. korak: Prepoznajte in odklenite postavitev shrambe (lsblk -f)

Odprite terminal znotraj namizja Live USB in zaženite:

sudo lsblk -f
Poglej na FSTYPE stolpec, da vidite, katero od štirih običajnih arhitektur za shranjevanje uporablja vaša namestitev Linuxa, in jo namestite /mnt z uporabo spodnjega ujemajočega se bloka:

  • 1. primer: standardno ext4 oz xfs particija (npr. Root je /dev/nvme0n1p2 in EFI je /dev/nvme0n1p1):
    sudo mount /dev/nvme0n1p2 /mnt
    sudo mount /dev/nvme0n1p1 /mnt/boot/efi
    
  • Case 2: Encrypted LUKS root partition (crypto_LUKS) (default when "Encrypt my disk" was checked during install): You must decrypt the LUKS container first before mounting:
    sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptroot
    sudo vgchange -ay                        # Activates LVM volumes inside LUKS if used
    sudo mount /dev/mapper/cryptroot /mnt    # (Or /dev/mapper/ubuntu--vg-ubuntu--lv)
    sudo mount /dev/nvme0n1p2 /mnt/boot      # Mount separate unencrypted /boot partition
    sudo mount /dev/nvme0n1p1 /mnt/boot/efi  # Mount FAT32 EFI partition
    
  • Case 3: Btrfs filesystem with @ subvolumes (default on Fedora, openSUSE, and Ubuntu Btrfs installs): If you mount a Btrfs partition without specifying subvol=@, /mnt will only show @ in @home folders instead of /bin in /etc, in chroot /mnt will fail with failed to run command '/bin/bash': No such file or directory. Mount the @ subvolume explicitly:
    sudo mount -o subvol=@ /dev/nvme0n1p2 /mnt          # (Use subvol=root on Fedora)
    sudo mount /dev/nvme0n1p1 /mnt/boot/efi
    

Step 2: Bind virtual kernel filesystems (including UEFI efivars) and enter chroot

For grub-install in apt (DNS internet access) to work inside chroot, bind-mount the Live USB's virtual kernel directories and UEFI NVRAM variables into /mnt:

# Bind-mount virtual device, process, sysfs, run (for DNS resolv.conf), and UEFI variables:
for dir in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do
    sudo mount --bind $dir /mnt$dir
done

# Step inside your installed Linux system:
sudo chroot /mnt /bin/bash

Step 3: Repair packages, rebuild initramfs, and reinstall GRUB inside chroot

Now that your prompt shows root@ubuntu:/#, run the repair commands for your distribution:

# 1. Fix any half-installed kernel upgrades (Ubuntu/Debian):
dpkg --configure -a
apt-get install -f -y

# 2. Rebuild the initial ramdisk for all installed kernels:
update-initramfs -c -k all                  # (Debian / Ubuntu / Mint)
# dracut --regenerate-all --force           # (Fedora / RHEL / Rocky)
# mkinitcpio -P                             # (Arch / Manjaro)

# 3. Reinstall GRUB to the EFI System Partition and regenerate grub.cfg:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB --recheck
update-grub                                 # (Or: grub2-mkconfig -o /boot/grub2/grub.cfg on Fedora)

Step 4: Exit cleanly and reboot

exit
sudo umount -R /mnt
sudo reboot
Unplug the Live USB drive when requested. Your system will boot straight into your repaired GRUB menu and Linux desktop.

Regional enterprise standards, data center compliance, and hardware certification

Enterprise Linux bootloader management and firmware security are subject to rigorous national standards and cybersecurity frameworks:

  • United States: Government and enterprise infrastructure adheres to the National Institute of Standards and Technology (NIST) Special Publication 800-147B (BIOS Protection Guidelines for Servers) and SP 800-193 (Platform Firmware Resiliency Guidelines). Federal installations operating Red Hat Enterprise Linux (RHEL) or Rocky Linux must comply with Defense Information Systems Agency (DISA) Security Technical Implementation Guides (STIGs). These standards require password protection on GRUB 2 boot menus, disabling interactive kernel parameter editing, enabling UEFI Secure Boot with Shim first-stage loaders, and encrypting root storage with FIPS 140-⅔ validated LUKS cryptographic modules.
  • United Kingdom: The National Cyber Security Centre (NCSC) publishes device security guidance for enterprise Linux platforms, mandating hardware-rooted platform integrity. Systems deployed across government or critical national infrastructure must use Trusted Platform Module (TPM 2.0) measurements to seal LUKS disk encryption keys against Platform Configuration Registers (PCRs), ensuring the drive unlocks automatically only when the UEFI firmware, Secure Boot keys, and GRUB binary remain completely untampered.
  • European Union: In the European Union, the Federal Office for Information Security in Germany (BSI) establishes baseline security through IT-Grundschutz building block SYS.1.3 (Server Linux and Unix). BSI guidelines require strict separation of boot partitions, immutable bootloader configurations, and audited maintenance procedures. Under the EU Network and Information Security Directive (NIS 2), entities operating essential digital services must maintain validated bare-metal disaster recovery procedures to satisfy Recovery Time Objectives (RTO) during operating system failures.
  • Canada: The Canadian Centre for Cyber Security (CCCS) provides guidance under ITSG-33 (IT Security Risk Management), specifying controls for enterprise Linux operating environments. In compliance with the Personal Information Protection and Electronic Documents Act (PIPEDA), physical server hard drives undergoing bootloader recovery or controller replacement must utilize hardware or volume-level encryption to prevent data exposure during servicing.
  • Australia: The Australian Signals Directorate (ASD) publishes the Information Security Manual (ISM), which sets forth requirements for enterprise Linux systems. The ISM mandates that organizations enforce UEFI Secure Boot, protect bootloader configurations against unauthenticated changes, and log emergency maintenance shell access into centralized audit repositories to maintain compliance with the Essential Eight mitigation strategies.

Pogosta vprašanja

Why did my dual-boot Linux GRUB menu disappear after a Windows 10 or Windows 11 update?

Major Windows feature updates frequently reset the motherboard's UEFI NVRAM boot priority order, placing "Windows Boot Manager" back at #1 above "ubuntu" or "fedora" without actually deleting your Linux files. Before booting a Live USB, first enter your motherboard BIOS/UEFI settings at startup (press `F2`, `F12`, or `Del`) and check the **Boot Order / UEFI Boot Priority** list, often you can simply move `ubuntu` or `GRUB` back above `Windows Boot Manager`, save with `F10`, and your GRUB menu returns immediately. You can also run `bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi` inside an Administrator Command Prompt in Windows to restore GRUB without a USB stick.

Why does `chroot /mnt` say `failed to run command '/bin/bash': No such file or directory` when I try to rescue my system?

This error happens for one of three reasons: (1) You accidentally mounted your small `/boot` or `EFI` partition to `/mnt` instead of your main Linux root partition (verify with `ls /mnt`, you should see `bin`, `etc`, `usr`, and `var`); (2) your system uses the **Btrfs** filesystem with subvolumes, so `ls /mnt` only shows `@` and `@home`, unmount `/mnt` and remount with `sudo mount -o subvol=@ /dev/nvme0n1p2 /mnt` (or `subvol=root` on Fedora); or (3) you accidentally booted a 32-bit Live USB stick while trying to `chroot` into a 64-bit (`x86_64`) Linux installation.

What does the kernel panic message `VFS: Unable to mount root fs on unknown-block(0,0)` mean at boot?

This kernel panic means the Linux kernel started without a valid `initramfs` (initial RAM disk) image, usually because a system update was interrupted while generating `/boot/initrd.img-...` or because your `/boot` partition ran out of space during a kernel upgrade. Reboot, hold `Shift` or tap `Esc` to open the GRUB menu, select **"Advanced options"**, and boot into the previous older kernel listed right below the newest one. Once logged into your desktop on the older kernel, free up space in `/boot` with `sudo apt autoremove --purge` and rebuild the broken ramdisk with `sudo update-initramfs -c -k all && sudo update-grub`.

How can I temporarily bypass broken graphics drivers from the GRUB menu using `nomodeset`?

If your monitor turns completely black or loses signal right after the GRUB menu due to a GPU driver problem, reboot and tap `Esc` or hold `Shift` to open the GRUB menu. Highlight your Linux entry and press **`e`** on your keyboard. Use the arrow keys to find the line starting with `linux /boot/vmlinuz...`, move to the end of that line where it says `quiet splash`, and replace `quiet splash` with **`nomodeset`**. Press **`Ctrl + X`** or **`F10`** to boot. The `nomodeset` parameter tells the Linux kernel not to load hardware video drivers until after Xorg starts, using basic BIOS framebuffer graphics so you can see your screen and fix your GPU drivers.

Why did `grub-install` inside `chroot` warn that `EFI variables are not supported on this system`?

That error occurs for one of two reasons: either you accidentally booted your Live USB flash drive in **Legacy BIOS / CSM mode** instead of **UEFI mode** when selecting it in your motherboard's F12 boot menu (check by running `ls /sys/firmware/efi`, if that folder does not exist on the Live USB, reboot and select the `"UEFI: [USB Drive Name]"` entry in your BIOS boot menu), OR you forgot to bind-mount `/sys/firmware/efi/efivars` into `/mnt/sys/firmware/efi/efivars` before running `chroot /mnt`.

How do I prevent a secondary external or internal hard drive in `/etc/fstab` from ever crashing my Linux boot again?

Whenever you add any non-root storage drive (such as a second SSD, a RAID array, an external USB backup drive, or a network Samba/NFS share) to `/etc/fstab`, always include **`nofail,x-systemd.device-timeout=10`** in the fourth column (mount options), and set the sixth column (`pass` / `fsck` order) to **`0`** or **`2`**. With `nofail` enabled, if that drive is ever unplugged or fails, `systemd` waits only 10 seconds, logs a non-fatal warning, and boots normally into your desktop instead of dropping you into Emergency Mode.

First aid certification and technical workplace safety

Hardware-level boot diagnostics often require opening desktop cases, replacing power supplies, or inspecting server rack equipment. Technicians face acute electrical hazards from damaged capacitors, lacerations from sharp sheet-metal chassis, and crushing injuries from heavy rack-mounted hardware. If an electric shock occurs, immediately disconnect the circuit breaker before touching the victim and call emergency services. Knowing how to deliver CPR and manage severe bleeding or shock is as critical in a server room as technical troubleshooting. We recommend completing an accredited first aid, CPR/AED, and workplace health and safety course through the Red Cross, St John Ambulance, or a national safety authority.

Viri preverjeni

  • GNU Project / Free Software Foundation (International): Official GNU GRUB Manual 2.12 , Booting from grub> in grub rescue> Command Shells (gnu.org/software/grub/manual).
  • The Linux Kernel Archives & Kernel.org (International): Kernel Parameters (admin-guide/kernel-parameters.txt), initramfs Early Userspace, and Filesystem Administration (docs.kernel.org).
  • Canonical / Ubuntu Server & Desktop Documentation (United Kingdom / International): GRUB2 Bootloader Recovery, LiveCD Chroot Procedures, and Disk Space Management (help.ubuntu.com, ubuntu.com/server/docs).
  • Red Hat Enterprise Linux (RHEL) & Fedora Project Documentation (United States): Troubleshooting Boot Issues with dracut, xfs_repair, in grub2-mkconfig (docs.redhat.com, docs.fedoraproject.org).
  • Arch Linux Wiki (mednarodno): GRUB, Chroot, fstab, in mkinitcpio Technical Reference (wiki.archlinux.org).
  • Freedesktop.org / systemd Documentation (International): systemd.unit Emergency and Rescue Targets, journalctl Vacuuming, and systemd.mount Options (freedesktop.org/software/systemd/man).

Sorodni vodniki