Skip to content

خرابی بوت سیستم لینوکس و تعمیر GRUB: راهنمای بازیابی خط فرمان

خرابی راه‌اندازی سیستم لینوکس می‌تواند ایستگاه‌های کاری، سرورهای تولید و لپ‌تاپ‌های با بوت دوگانه را بدون هیچ هشداری متوقف کند و شما را در وضعیت بدی قرار دهد. grub rescue> سریع، حداقل grub> پوسته، یک (initramfs) یا dracut:/# کنسول اضطراری، یک سیستم "You are in emergency mode" درخواست تعمیر و نگهداری یا یک صفحه سیاه با مکان نما چشمک زن.

برخلاف سیستم‌عامل‌هایی که مکانیک‌های راه‌اندازی را پشت کدهای خطای گرافیکی مات پنهان می‌کنند، لینوکس هر مرحله از خط لوله راه‌اندازی را مستقیماً در معرض دید مدیر قرار می‌دهد. تقریباً هر خرابی بوت لینوکس از یکی از پنج دلیل ریشه‌ای قابل رفع ناشی می‌شود: بوت‌لودر GRUB 2 بازنویسی یا پیکربندی نادرست (معمولاً پس از به‌روزرسانی ویندوز در رایانه شخصی با بوت دوگانه فعال می‌شود)، کثیف بودن. ext4/xfs/btrfs فایل سیستم ریشه پس از قطع ناگهانی برق، خرابی /etc/fstab ورودی UUID دیسک، 100 درصد ریشه کامل (/) پارتیشن ذخیره سازی، یا یک هسته قطع شده و ارتقاء درایور گرافیک. مطابقت دقیق اعلان روی صفحه خود با مرحله بوت مربوطه به شما این امکان را می دهد که سیستم را بدون فرمت کردن درایو یا از دست دادن اطلاعات خود به طور تمیز تعمیر کنید.

همین الان این کار را بکن

هنگامی که رایانه یا سرور لینوکس شما از بوت شدن امتناع می کند، قبل از اجرای هر دستور دیسک مخرب، این شش مرحله تشخیصی و ایمنی فوری را دنبال کنید:

  1. برای تشخیص اینکه کدام مرحله راه‌اندازی انجام نشد، دستور دقیق روی صفحه را بخوانید:
    • grub rescue> یا grub>: The motherboard UEFI/BIOS loaded the first stage of GRUB, but GRUB cannot locate /boot/grub or its configuration file (grub.cfg).
    • (initramfs) یا dracut:/#: GRUB loaded the Linux kernel and initial RAM disk fine, but the kernel could not mount your main root (/) filesystem (usually because fsck needs to repair a dirty disk).
    • You are in emergency mode / Give root password for maintenance: The root filesystem mounted, but systemd failed to mount a secondary drive listed in /etc/fstab.
    • Black screen with a blinking cursor after the GRUB menu: The operating system booted, but the graphical Display Manager (GDM, SDDM, LightDM) failed due to a 100% full root disk or a broken Nvidia/AMD GPU driver.
  2. Try booting the previous Linux kernel from the GRUB menu first: Reboot the machine and hold Shift (BIOS) or tap Esc repeatedly (UEFI) right after the manufacturer logo to reveal the GRUB menu. Select "Advanced options for Ubuntu / Debian / Fedora" and pick the second-oldest kernel on the list. If a recent kernel update broke your initramfs or GPU module, the previous kernel will boot straight into your desktop in 10 seconds.
  3. Switch to a virtual TTY text console if stuck on a black screen: If the boot sequence freezes on a black screen with a blinking underscore or stuck splash logo, press Ctrl + Alt + F3 (or Ctrl + Alt + F2 through F6). If a login: text prompt appears, your Linux system is actually running, log in with your username and password to clean full disk space or fix graphics drivers.
  4. Never run fsck on a partition that is currently mounted read-write: Running fsck on a live, read-write mounted filesystem corrupts open inode tables and destroys files. Only run fsck from the (initramfs) shell (where root is unmounted), on a read-only mount, or from a Live USB stick.
  5. Unplug all non-important external USB hard drives and SD cards: A failing external USB drive listed in /etc/fstab or taking over boot priority in BIOS will halt the boot sequence. Unplug external drives and reboot to test.
  6. اگر GRUB یا هسته آن کاملاً از بین رفته است، یک USB USB Live Linux آماده کنید: یک درایو فلش USB زنده قابل بوت (Ubuntu، Linux Mint، Fedora یا SystemRescue) را در دسترس داشته باشید تا بتوانید پارتیشن های رمزگذاری شده یا استاندارد خود را نصب کنید و یک پارتیشن را اجرا کنید. chroot bootloader repair.

انتقادی: چه کاری را نباید انجام داد

Never run grub-install، dd، fdisk، یا mkfs until you have verified your exact disk and partition layout using lsblk -f یا blkid. Device node names like /dev/sda and /dev/sdb are assigned dynamically by the Linux kernel at boot and can swap order when a Live USB stick is plugged in. Accidentally formatting or overwriting the partition table of the wrong /dev/sdX drive will destroy your data. In addition, never run filesystem repair utilities like fsck on partitions mounted read-write, never force-power off a system during an active kernel or bootloader package upgrade, and never delete system libraries in /usr/lib یا /lib in an attempt to clear space on a full root drive.

Decision tree: diagnosing the 5 Linux boot failure stages

Use this diagnostic flowchart to trace your exact screen output to the matching command-line fix:

flowchart TD
    A["Linux System Fails to Boot to Desktop / Login"] --> B{"What is displayed on the screen?"}
    B -->|"grub rescue> or grub> prompt"| C["Stage 1 Failure: Use ls to locate /boot/grub, set root & prefix, boot OS, then run grub-install"]
    B -->|"BusyBox (initramfs) یا dracut:/# shell"| D["مرحله 2 شکست: پارتیشن ریشه را با blkid شناسایی کنید و fsck -y /dev/partition را اجرا کنید"]
    B -->|"حالت اضطراری: رمز عبور root را برای تعمیر و نگهداری بدهید"| E["مرحله 3 شکست: mount -o remount،rw / را اجرا کنید و UUID شکسته را در /etc/fstab اصلاح یا نظر دهید"]
    B -->|"صفحه سیاه یا مکان نما چشمک زن بعد از GRUB"| F["مرحله 4 شکست: کلیدهای Ctrl+Alt+F3 (یا بوت اضطراری.target) را فشار دهید تا 100% کامل دیسک یا درایور GPU پاک شود."]
    B -->|"مستقیماً در ویندوز یا «بدون دستگاه قابل بوت شدن» بوت می شود"| G["ترتیب بوت UEFI/EFI پاک شد: USB Live را بوت کنید، Root + EFI را سوار کنید، chroot کنید و GRUB را دوباره نصب کنید"]

مقایسه اعلان ها، علل و دستورات خرابی بوت لینوکس

خطای روی صفحه / درخواست به مرحله بوت رسید علت اصلی اولیه سریعترین توالی دستور تعمیر
error: no such partition / grub rescue> مرحله 1 (هسته GRUB) پارتیشن‌های دیسک تغییر اندازه، شبیه‌سازی یا UUID تغییر کرده است. GRUB نمی تواند پیدا کند /boot/grub/normal.mod. ls -> set root=(hdX,gptY) -> set prefix=(hdX,gptY)/boot/grub -> insmod normal -> normal
grub> (GRUB CLI استاندارد) مرحله 1.5 (GRUB نرمال) /boot/grub/grub.cfg وجود ندارد یا حذف شده است، اگرچه ماژول های GRUB به خوبی بارگیری می شوند. set root=(hdX,gptY) -> linux /boot/vmlinuz-... root=/dev/nvme0n1p2 -> initrd /boot/initrd.img-... -> boot
BusyBox (initramfs) یا dracut:/# مرحله 2 (کرنل + Initramfs) ناپاک برق خاموش چپ ext4/xfs ژورنال ریشه کثیف است، نیاز به کتابچه راهنمای کاربر دارد fsck تایید blkid -> fsck -y /dev/nvme0n1p2 (یا xfs_repair -L برای XFS) -> reboot -f
You are in emergency mode (sulogin prompt) مرحله 3 (systemd مانت) درایو ثانویه یا تعویض پارتیشن در /etc/fstab قطع شده، دوباره فرمت شده یا خراب شده است. رمز عبور root را وارد کنید -> mount -o remount,rw / -> nano /etc/fstab (افزودن nofail یا #) -> systemctl daemon-reload -> reboot
[FAILED] Failed to start GNOME Display Manager / چشمک زدن مکان نما مرحله 4 (مدیر نمایش / رابط کاربری گرافیکی) پارتیشن ریشه / 100% پر است (0 بایت رایگان برای /tmp یا سوکت های Xorg) یا ماژول هسته انویدیا شکسته (dkms). را فشار دهید Ctrl+Alt+F3 -> df -h -> journalctl --vacuum-size=100M & apt clean یا ubuntu-drivers autoinstall

سناریو 1: فرار از grub rescue> یا grub> درخواست بدون درایو USB

اگر صفحه نمایش شما نمایش داده می شود error: unknown filesystem، error: no such partition، یا Minimal BASH-like line editing is supported به دنبال آن grub rescue> یا grub>، نصب لینوکس و فایل های شخصی شما معمولاً همچنان دست نخورده روی SSD یا هارد دیسک شما قرار دارند، GRUB به سادگی مسیر پارتیشن را از دست داده است. /boot/grub. می‌توانید در عرض 2 دقیقه مستقیماً از طریق این پیام به سیستم عامل نصب شده خود بوت شوید:

مورد الف: شما در grub rescue> سریع

در grub rescue>، فقط چهار دستور اساسی کار می کند (ls، set، unset، و insmod). این مراحل را با دقت دنبال کنید:

  1. **لیست تمام دیسک ها و پارتیشن های مشاهده شده توسط سیستم عامل مادربرد **:
    grub rescue> ls
    
    GRUB خطی مانند زیر را چاپ می کند: (hd0) (hd0,gpt1) (hd0,gpt2) (hd0,gpt3) (یا (hd0,msdos1) در دیسک های قدیمی MBR).
  2. **هر پارتیشن را تا زمانی که ریشه لینوکس خود را پیدا کنید (یا /boot) دایرکتوری **: (به یاد داشته باشید که اسلش انتهایی را نیز اضافه کنید / در پایان هر کدام ls بررسی کنید تا GRUB نام فایل های داخل آن پارتیشن را لیست کند):
    grub rescue> ls (hd0,gpt1)/
    grub rescue> ls (hd0,gpt2)/
    grub rescue> ls (hd0,gpt3)/
    
  3. اگر (hd0,gpt1)/ نشان می دهد efi/، این پارتیشن سیستم کوچک FAT32 EFI شما است.
  4. وقتی یک پارتیشن خروجی می دهد boot/ etc/ home/ usr/ var/ vmlinuz initrd.img، پارتیشن اصلی لینوکس خود را پیدا کرده اید (به عنوان مثال، (hd0,gpt2)). (نکته: اگر از Btrfs با استفاده می کنید @ زیر جلدها در اوبونتو/فدورا، ls (hd0,gpt2)/ نشان خواهد داد @/ @home/، یعنی پوشه بوت شما در است (hd0,gpt2)/@/boot/grub.)
  5. ** GRUB را به پارتیشن خود نشان دهید و بارگذاری کنید normal ماژول **: Assuming your Linux root is on (hd0,gpt2):
    grub rescue> set root=(hd0,gpt2)
    grub rescue> set prefix=(hd0,gpt2)/boot/grub
    grub rescue> insmod normal
    grub rescue> normal
    
    (If you have a separate dedicated /boot partition on (hd0,gpt2), use set prefix=(hd0,gpt2)/grub without /boot.)
  6. Make the fix permanent once your desktop boots: As soon as normal runs, your regular GRUB menu will appear and boot your Linux system. Important: Those set commands were temporary in RAM. The moment you log into your Linux desktop, open a terminal and permanently write the correct GRUB location to your drive:
    sudo update-grub
    sudo grub-install /dev/nvme0n1   # (Or /dev/sda ,  use your whole disk name, NOT a partition number)
    

Case B: You are at the standard grub> سریع

If you see grub> (without the word rescue), the normal module is already loaded, but your grub.cfg menu file is missing or broken. You can manually boot the Linux kernel in four lines using Tab auto-completion:

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
(Tip: Just type linux /boot/vmlinuz and press the Tab key, GRUB will auto-complete the exact kernel version numbers installed on your disk.) Once booted into your OS, run sudo update-grub (Debian/Ubuntu) or sudo grub2-mkconfig -o /boot/grub2/grub.cfg (Fedora/RHEL) to regenerate the missing menu file.

Scenario 2: Fixing (initramfs) یا dracut shells with fsck

If your PC passes the GRUB menu, shows the Linux boot splash for a few seconds, and then drops into a black text prompt reading:

BusyBox v1.36.1 (Ubuntu) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs) _
Look 3 to 5 lines above the (initramfs) prompt. Nine times out of ten, you will see: The root filesystem on /dev/nvme0n1p2 requires a manual fsck

Step-by-step filesystem repair from (initramfs)

  1. Confirm which partition needs repair: If the partition name is not printed right above the prompt, type blkid and press Enter to list your ext4، xfs، یا btrfs partitions.
  2. Run the matching filesystem repair tool:
    • For ext4 / ext3 filesystems (default on Ubuntu, Debian, Mint):
      (initramfs) fsck -y /dev/nvme0n1p2
      
      The -y flag automatically answers "yes" to every corrupted inode, orphaned block, and journal replay prompt instead of making you press y 500 times.
    • For XFS filesystems (default on RHEL, AlmaLinux, Rocky Linux, CentOS): Standard fsck does nothing on XFS. In a dracut:/# shell on an XFS system, run:
      dracut:/# xfs_repair /dev/mapper/rhel-root
      
      (Only pass the -L اگر گزارش فراداده XFS را صفر کنید xfs_repair به دلیل یک سیاهه کثیف غیرقابل نصب از اجرا امتناع می کند و شما گزینه دیگری ندارید).
    • For Btrfs سیستم های فایل (پیش فرض در فدورا، openSUSE): ابتدا درخت log Btrfs را با خیال راحت پاک کنید btrfs rescue zero-log /dev/nvme0n1p2. هرگز اجرا نکنید btrfs check --repair مگر اینکه توسط یک توسعه دهنده Btrfs دستور داده شده باشد یا پس از پشتیبان گیری از داده ها از یک Live USB، به عنوان --repair در Btrfs خطرناک در نظر گرفته می شود.
  3. **خروج و راه اندازی مجدد **: یک بار fsck چاپ می کند ***** FILE SYSTEM WAS MODIFIED *****، نوع exit (یا reboot -f) و Enter را فشار دهید. سیستم شما پارتیشن تمیز را سوار می کند و به طور معمول بوت می شود.

سناریو 3: تعمیر /etc/fstab خطاها در systemd حالت اضطراری

اگر صفحه شما در اواسط بوت متوقف شد با:

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):
این تقریباً همیشه اتفاق می افتد زیرا شما ویرایش کرده اید /etc/fstab، یک پارتیشن swap را فرمت کرد (که UUID آن را تغییر داد)، یا یک هارد دیسک داخلی/اکسترنال ثانویه را که در /etc/fstab بدون nofail گزینه به طور پیش فرض، systemd در صورتی که دیسکی در لیست باشد، کل بوت سیستم عامل را متوقف می کند /etc/fstab در عرض 90 ثانیه پاسخ نمی دهد.

چگونه رفع کنیم /etc/fstab در 90 ثانیه

  1. رمز عبور ریشه خود را تایپ کنید (یا اگر در اوبونتو است Enter را فشار دهید، جایی که حساب root قفل شده است و شما را مستقیماً وارد می کند؛ اگر اوبونتو می گوید Cannot open access to console, the root account is locked، ببینید init=/bin/bash یادداشت زیر).
  2. فایل سیستم ریشه را به صورت Read-Write نصب مجدد کنید: در حالت اضطراری، / اغلب به صورت Read-Only نصب می شود، بنابراین اگر سعی کنید ذخیره کنید /etc/fstab، nano خواهد گفت Error writing /etc/fstab: Read-only file system. ابتدا این را اجرا کنید:
    mount -o remount,rw /
    
  3. **بیابید در کدام خط است /etc/fstab خراب است **: اجرا کنید mount -a. هر درایوی خراب باشد، فورا یک خطا چاپ می کند (به عنوان مثال، mount: /mnt/backup: can't find UUID=4a8b...). همچنین می توانید UUID های درایو واقعی خود را با آنها مقایسه کنید /etc/fstab با دویدن:
    blkid
    cat /etc/fstab
    
  4. **ویرایش /etc/fstab و اضافه کنید nofail یا خط بد را نظر دهید **:
    nano /etc/fstab
    
    یک را قرار دهید # 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
    
    اگر 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 یا 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 یا /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. اگر Use% نشان می دهد 100% (یا Avail نشان می دهد 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 یا /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 user so root services can still run when a normal user fills the disk. On a 1-terabyte SSD, 5% is a massive 50 GB held hostage. You can immediately reclaim 40+ GB of that reserved buffer for your normal user account by running:
    sudo tune2fs -m 1 /dev/nvme0n1p2   # Reduces reserved root blocks from 5% to 1% immediately
    
  5. Once df -h / چند گیگابایت موجود را نشان می دهد، اجرا کنید sudo reboot و دسکتاپ گرافیکی شما به طور معمول وارد سیستم می شود.

چه می شود اگر df -h فضای خالی زیادی دارد و صفحه سیاه بعد از درایور یا به‌روزرسانی هسته Nvidia شروع به کار کرد؟

اگر دیسک شما پر نیست و صفحه سیاه بلافاصله پس از به روز رسانی در رایانه شخصی با کارت گرافیک Nvidia شروع به کار کرد، ماژول هسته اختصاصی Nvidia (nvidia.ko) از طریق کامپایل نشد dkms برای هسته جدید شما، یا Secure Boot ماژول بدون امضا را مسدود کرد:

  1. از Ctrl + Alt + F3 کنسول TTY، بررسی کنید که آیا ماژول درایور با اجرا بارگذاری شده است یا خیر nvidia-smi.
  2. اگر nvidia-smi می گوید NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver، یا Secure Boot را در تنظیمات UEFI/BIOS مادربرد خود غیرفعال کنید (اگر Secure Boot ماژول DKMS امضا نشده را مسدود می کند)، یا هدر و درایور هسته را دوباره بسازید:
    # 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
    

سناریو 5: USB زنده را کامل کنید chroot نجات (برای EFI/GRUB، LVM، LUKS و Btrf پاک شده)

هنگامی که یک به‌روزرسانی ویندوز 11 ورودی‌های بوت UEFI شما را بازنویسی می‌کند، به‌روزرسانی هسته در اواسط پرواز از کار می‌افتد در حالی که برق قطع می‌شود، یا grub rescue> نمی تواند پارتیشن شما را بخواند، رایانه خود را از درایو USB Live Linux (با انتخاب "Try Ubuntu" یا live desktop mode) بوت کنید و یک ** انجام دهید.chroot** (تغییر ریشه) تعمیر. الف chroot به ترمینال Live USB شما اجازه می دهد تا داخل SSD خراب شما را نصب کرده و اجرا کند apt، dnf، update-initramfs، و grub-install مثل اینکه سیستم به طور معمول بوت شده است.

مرحله 1: طرح بندی فضای ذخیره سازی خود را شناسایی و باز کنید (lsblk -f)

یک ترمینال را در داخل دسکتاپ Live USB باز کنید و اجرا کنید:

sudo lsblk -f
نگاه کن FSTYPE ستون را ببینید تا ببینید نصب لینوکس شما از کدام یک از چهار معماری رایج ذخیره سازی استفاده می کند و آن را روی آن نصب کنید /mnt با استفاده از بلوک تطبیق زیر:

  • مورد 1: استاندارد ext4 یا xfs پارتیشن (به عنوان مثال، Root است /dev/nvme0n1p2 و EFI است /dev/nvme0n1p1):
    sudo mount /dev/nvme0n1p2 /mnt
    sudo mount /dev/nvme0n1p1 /mnt/boot/efi
    
  • مورد 2: پارتیشن ریشه رمزگذاری شده LUKS (crypto_LUKS) (پیش‌فرض زمانی که "Encrypt my disk" در حین نصب بررسی شد): قبل از نصب، ابتدا باید ظرف LUKS را رمزگشایی کنید:
    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
    
  • مورد 3: فایل سیستم Btrfs با @ حجم های فرعی (پیش فرض در نصب های فدورا، openSUSE و اوبونتو Btrfs): اگر پارتیشن Btrfs را بدون تعیین مونت کنید subvol=@، /mnt فقط نشان خواهد داد @ and @home پوشه ها به جای /bin and /etc، و chroot /mnt با شکست مواجه خواهد شد failed to run command '/bin/bash': No such file or directory. را سوار کنید @ زیر جلد به صراحت:
    sudo mount -o subvol=@ /dev/nvme0n1p2 /mnt          # (Use subvol=root on Fedora)
    sudo mount /dev/nvme0n1p1 /mnt/boot/efi
    

مرحله 2: سیستم فایل هسته مجازی (از جمله UEFI) را متصل کنید efivars) و وارد شوید chroot

برای grub-install and apt (دسترسی به اینترنت DNS) برای کار در داخل 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و GRUB را مجدداً در داخل نصب کنید chroot

اکنون که درخواست شما نشان داده می شود root@ubuntu:/#، دستورات تعمیر را برای توزیع خود اجرا کنید:

# 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)

مرحله 4: به طور تمیز خارج شوید و راه اندازی مجدد کنید

exit
sudo umount -R /mnt
sudo reboot
در صورت درخواست، درایو USB زنده را جدا کنید. سیستم شما مستقیماً در منوی GRUB تعمیر شده و دسکتاپ لینوکس بوت می شود.

استانداردهای سازمانی منطقه ای، انطباق با مرکز داده، و گواهی سخت افزار

مدیریت بوت لودر لینوکس سازمانی و امنیت میان‌افزار تابع استانداردهای ملی سختگیرانه و چارچوب‌های امنیت سایبری است:

  • ایالات متحده: زیرساخت های دولتی و سازمانی از انتشارات ویژه 800-147B مؤسسه ملی استانداردها و فناوری (NIST) (دستورالعمل های حفاظت از BIOS برای سرورها) و SP 800-193 (دستورالعمل های انعطاف پذیری سیستم عامل پلت فرم) تبعیت می کنند. تأسیسات فدرال که Red Hat Enterprise Linux (RHEL) یا Rocky Linux را اجرا می کنند، باید با راهنمای پیاده سازی فنی امنیتی آژانس اطلاعات دفاعی (DISA) مطابقت داشته باشند. این استانداردها به محافظت از رمز عبور در منوهای راه‌اندازی GRUB 2، غیرفعال کردن ویرایش پارامترهای هسته تعاملی، فعال کردن راه‌اندازی امن UEFI با لودرهای مرحله اول Shim و رمزگذاری فضای ذخیره‌سازی ریشه با ماژول‌های رمزنگاری LUKS تأیید شده با استاندارد FIPS 140-⅔ نیاز دارند.
  • بریتانیا: مرکز امنیت سایبری ملی (NCSC) دستورالعمل های امنیتی دستگاه را برای پلتفرم های لینوکس سازمانی منتشر می کند که یکپارچگی پلت فرم مبتنی بر سخت افزار را الزامی می کند. سیستم‌هایی که در سراسر زیرساخت‌های دولتی یا حیاتی ملی مستقر می‌شوند باید از اندازه‌گیری‌های ماژول پلتفرم مورد اعتماد (TPM 2.0) برای مهر و موم کردن کلیدهای رمزگذاری دیسک LUKS در برابر ثبت‌های پیکربندی پلتفرم (PCR) استفاده کنند، و اطمینان حاصل شود که قفل درایو تنها زمانی به طور خودکار باز می‌شود که سفت‌افزار UEFI، کلیدهای Secure Boot و باینری GRUB کاملاً دست نخورده باقی بمانند.
  • 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.

سوالات متداول

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.

منابع بررسی شد

  • GNU Project / Free Software Foundation (International): Official GNU GRUB Manual 2.12 , Booting from grub> and 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، و grub2-mkconfig (docs.redhat.com، docs.fedoraproject.org).
  • Arch Linux Wiki (International): GRUB, Chroot, fstab، و 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).

راهنماهای مرتبط