Enter single-user mode on Linux and FreeBSD systems

更新时间:
复制 MD 格式

If you cannot remotely connect to an ECS instance using Workbench, Session Manager, or a third-party client due to system configuration errors or driver issues, you can boot into single-user mode, also known as maintenance mode. This mode interrupts the normal boot process and provides a minimal system environment with root privileges for emergency maintenance.

Procedure

Important

Single-user mode grants full control over the system. Incorrect operations can corrupt system files. Before you perform maintenance, we recommend that you manually create a snapshot of the system disk.

Alibaba Cloud Linux

Important

This procedure applies only to Alibaba Cloud Linux 3.

  1. Connect to an instance using VNC.

  2. Run the reboot command to restart the operating system.

    If you cannot log on to the instance using VNC, restart the instance from the console.
  3. During the restart, press and hold the E key to edit the boot parameters.

  4. Locate the kernel boot line that starts with linux. Replace the content from ro to the end of the line with rw init=/bin/sh crashkernel=auto. This enables read-write permissions and specifies the init process.

    • Original content:

      linux (Sroot) /boot/umlinuz-5.10.134-19.1.a18.x86_64 root=UUID=********-****-**\
      **-****-************ ro rhgb quiet cgroup-memory=nokmem crashkernel=0M-2G:0M, \
      2G-8G: 192M, 8G-128G:256M, 128G-3766:384M,376G- :448M spec_rstack overflow-off uri\
      ng_force_dma_api kence-sample_interval=100 kfence.booting_max=0-2G:0,2G-32G :2\
      M.32G-:32M preempt=none biosdeuname=0 net. ifnames=0 console=tty0 console=ttySO\
      , 115200n8 noibrs nume_core.io_timeout=4294967295 nume_core.admin_timeout=42949\
      67295 cryptongr.notests rcupdate.rcu_cpu_stall_timeout=300
    • Modified content:

      linux (Sroot) /boot/umlinuz-5.10.134-19.1.a18.x86_64 root=UUID=********-****-**\
      **-****-************ rw init=/bin/sh crashkernel=auto
  5. Press Ctrl+x or F10 to boot into single-user mode.

CentOS, Debian, SLES, and Anolis OS

This example uses a CentOS system.

  1. Connect to an instance using VNC.

  2. In the VNC window, log on and run the reboot command to restart the instance.

  3. During the restart, press and hold the E key to edit the boot parameters.image

  4. Locate the kernel boot line that starts with linux16 and append single to the end of the line.

    • Original content:

      linux16 /boot/vmlinuz-*.**.*-****.***.*.***.***_** root=UUID=********-\
      ****-****-****-************ ro crashkernel-auto spectre_v2=retpoline rhgb quie\
      t net. ifnames=0 console=tty0 console=ttySo, 115200n8 noibrs nume_core.io_timeous\
      t=4294967295 nume_core.admin_timeout=4294967295
    • Modified content:

      linux16 /boot/vmlinuz-*.**.*-****.***.*.***.***_** root=UUID=********-\
      ****-****-****-************ ro crashkernel-auto spectre_v2=retpoline rhgb quie\
      t net. ifnames=0 console=tty0 console=ttySo, 115200n8 noibrs nume_core.io_timeous\
      t=4294967295 nume_core.admin_timeout=4294967295 single
  5. Press Ctrl+x or F10. When prompted, enter the root password to boot the system into single-user mode.

Ubuntu

Important

This procedure applies only to Ubuntu 18.04.

  1. Connect to an instance using VNC.

  2. Run the reboot command to restart the operating system.

    If you cannot log on to the instance using VNC, restart the instance from the console.
  3. During the restart, press and hold the Shift key to enter the GRUB menu.

  4. In the GRUB menu, select Advanced options for Ubuntu. On the next screen, select the recovery mode entry, then press E to edit the boot entry.

  5. Locate the kernel boot line that starts with linux. Replace the content from ro to the end of the line with rw single init=/bin/bash. This grants read-write permissions and starts a /bin/bash shell for single-user mode.

    • Original content:

      linux /boot/vmlinuz-4.15.0-213-generic root=UUID=d406d971-bc6d-40f2-b\
      572-6+74ac689736 ro recovery nomodeset dis_ucode_ldr
      vga=792 console=tty@ console=ttySo, 115\
      200n8 net. ifnames=0 noibrs iommu=pt nvme_core.multipathen nvme_core.io_timeout=4294967295 nv\
      me_core.admin_timeout=4294967295
    • Modified content:

      linux /boot/vmlinuz-4.15.0-213-generic root=UUID=********-****-****-*\
      ***-*+********** rw single init=/bin/bash
  6. Press Ctrl+x or F10 to boot into single-user mode.

FreeBSD

  1. Connect to an instance using VNC.

  2. Run the reboot command to restart the operating system.

    If you cannot log on to the instance using VNC, restart the instance from the console.
  3. After the system restarts, the VNC terminal shows the Boot Menu. Press 5 to switch the Cons output mode to Video primary.

    ______               ____   _____ _____
     |  ____|             |  _ \ / ____|  __ \
     | |___ _ __ ___  ___ | |_) | (___ | |  | |
     |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
     | |   | | |  __/  __/| |_) |____) | |__| |
     |_|   |_|  \___|\___||____/|_____/|_____/
           Welcome to FreeBSD
    1. Boot Multi user [Enter]
    2. Boot Single user
    3. Escape to loader prompt
    4. Reboot
    5. Cons: Dual (Video primary)
    Options:
    6. Kernel: default/kernel (1 of 1)
    7. Boot Options
  4. Press 2 to select Boot Single User to enter single-user mode.

Next steps

In single-user mode, you can check system logs, inspect service status, and test network connectivity to diagnose and resolve issues. For example, if a driver conflict prevents the system from booting, you can uninstall the conflicting driver to restore normal operation.