Technology Encyclopedia Home >How to boot into safe mode from bootloader in Linux?

How to boot into safe mode from bootloader in Linux?

To boot into safe mode from the bootloader in Linux, you typically use GRUB (GRand Unified Bootloader). Here’s how you can do it:

  1. Access GRUB Menu: During the boot process, press and hold the Shift key (or Esc in some distributions) to display the GRUB menu. If you miss the timing, you can usually access it by restarting and trying again.

  2. Select Kernel: From the GRUB menu, highlight the kernel you wish to boot with and press e to edit the boot parameters.

  3. Edit Boot Parameters: In the editor, locate the line starting with linux or linux16. This line specifies the kernel and its parameters.

  4. Add Safe Mode Parameter: At the end of this line, add single or init=/bin/bash to boot into single-user mode or a root shell, respectively. For example:

    linux /boot/vmlinuz-5.4.0-42-generic root=/dev/sda1 single
    
  5. Boot with Changes: Press Ctrl+x or F10 to boot with the modified parameters.

  6. Verify Safe Mode: If successful, you will boot into a minimal environment with root privileges, allowing you to perform system repairs or diagnostics.

Example: Suppose you are using Ubuntu and want to boot into safe mode. During boot, you press Shift to see the GRUB menu. You select the latest kernel and press e. In the editor, you find the line:

linux /boot/vmlinuz-5.4.0-42-generic root=/dev/sda1 ro quiet splash

You modify it to:

linux /boot/vmlinuz-5.4.0-42-generic root=/dev/sda1 ro quiet splash single

Then, you press Ctrl+x to boot into safe mode.

For cloud-related tasks, consider using services like Tencent Cloud’s Elastic Compute Service (ECS), which provides scalable and reliable cloud servers, ideal for development, testing, and production environments.