Skip to main content

Recovery Mode. Interaction examples

What is "Recovery Mode"?

warning

Please note, this is not the same as Windows Recovery Mode.

When recovery mode is activated, a special version of Linux is loaded. This is an operating system that runs in RAM and allows access to the disk partitions of your server. It is useful for tasks such as resetting passwords or recovering configurations.

What is file system mounting?

File system mounting is the process that makes a disk partition accessible to the operating system. For example, if you need to access data on the server in recovery mode. The following command is used for mounting:

mount

Working in Recovery Mode

Determining the disk structure

First, you need to determine how your disk system is organized. Run the following command:

lsblk

It will show a list of disks and partitions on your server. Example output of the command:

sda       8:0    0   477G  0 disk
├─sda1 8:1 0 12G 0 part
│ └─md0 9:0 0 12G 0 raid1
├─sda2 8:2 0 512M 0 part
│ └─md1 9:1 0 511.4M 0 raid1
└─sda3 8:3 0 453.3G 0 part
└─md2 9:2 0 453.1G 0 raid1

In this example, the root partition is located on md2, but your partition may have a different name.

tip

On our servers, with standard partitioning, the root partition is most often located on md2 or md1, depending on the server configuration.

Mounting the file system

Now, mount the root partition to access it. Use the command:

mount /dev/md2 /mnt

(Replace md2 with your partition if it's different)

This command makes the data on this partition accessible for work.

Connecting to the file system

After mounting the file system, you need to enter it to work as if it were the primary system. To do this, run the following commands:

chroot-prepare /mnt
  • This command prepares the system for working with the mounted partition.
chroot /mnt
  • With this command, you "enter" the file system and can execute commands as if it were the main operating system.

Example: Resetting the root password

Now, let's go through an example of resetting the root user password in recovery mode.

Booting the server into recovery mode

Go to the control panel, open the server card, select "Management" and click on the option "Recovery mode (rescue)" Then, reboot the server.

Connecting to the server via SSH

Connect to the server through SSH using the root user and the password you will receive via email after recovery mode is activated.

Mounting the file system

Enter the command to mount the root partition:

mount /dev/md2 /mnt

Entering the file system

Connect to the mounted file system using the following commands:

chroot-prepare /mnt
chroot /mnt

Resetting the root password

Run the following command to reset the password:

passwd root

Note: While entering the new password, no characters will appear on the screen.

Exiting chroot

To exit chroot mode, enter the command:

exit

Unmounting the file system

Unmount the file system to complete the process:

umount /mnt/*
umount /mnt

Rebooting the server

Reboot the server to load into the installed operating system.