How to Boot into Single User Mode in OCI

How to Boot into Single User Mode in OCI

When managing enterprise cloud infrastructure, losing access to a virtual machine due to a misconfigured firewall, corrupted configuration file, or forgotten password can disrupt operations. In Oracle Cloud Infrastructure (OCI), booting into Single User Mode—also referred to as Maintenance Mode—provides a reliable recovery path. This troubleshooting mode boots a Linux operating system with minimal services and grants root access to a single user, allowing administrators to repair critical system errors directly. This guide walks through the complete process of accessing Single User Mode in OCI via a serial console connection.

Prerequisites: Create a Console Connection

Before you can intercept the boot process, you must establish a secure connection to the instance’s serial console. Oracle Cloud Infrastructure allows you to emulate a physical terminal connection even when standard SSH access is unavailable.

Booting into Single User Mode

Once your console connection is active, you can intercept the bootloader and modify the kernel parameters to drop into a root shell.

  • After creating the console connection from the OCI GUI console, initiate a force reboot for the instance.
  • When the reboot process starts, switch back to your terminal window to observe the incoming console boot messages. As soon as the GRUB boot menu appears, immediately use the up or down arrow keys to stop the automatic countdown and freeze the menu.
  • In the GRUB boot menu, highlight the top menu item and press e to edit the boot entry configurations.
  • Locate the line that starts with vmlinuz, append the following parameter to the very end of that line, and then press Ctrl+X to boot using the modified configuration:
init=/bin/bash
  • Once the system drops into the Bash shell, execute the following command to load the Security-Enhanced Linux (SELinux) policies. This ensures that any files you modify preserve their correct security contexts, which is critical for successful SSH and Console authentication later:
/usr/sbin/load_policy -i
  • By default, the root filesystem is mounted as read-only. Run the following command to remount the root partition with read/write permissions so you can apply your fixes:
/bin/mount -o remount, rw /

At this stage, the environment is fully interactive. You can now safely edit configuration files, reset passwords, or perform necessary system modifications.

Exiting Single User Mode and Restarting

After completing your maintenance tasks, you must cleanly revert the environment and restart the virtual machine to apply the changes normally.

Remount the File System to Read-Only Mode

To prevent data corruption during the ungraceful shutdown of the shell, remount the root filesystem back to a read-only state:

mount -o remount,ro /

Reboot the Instance

Force a reboot of the OCI instance to initialize a standard multi-user boot sequence:

/usr/sbin/reboot -f

Utilizing Single User Mode via OCI Console Connections is an essential skill for system administrators managing cloud deployments. By gaining direct access to the GRUB bootloader, you can quickly remediate configuration errors and restore access to isolated instances without resorting to complex volume detaching and reattaching workflows.

Leave a Reply

Your email address will not be published. Required fields are marked *