We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

[How-To] Rescue Mode


Simon.L
04/05/2016, 11h47
The rescue mod is a survival mode that permits us to fix a big error such as a paranoid firewall which slapped the door in our face, etc...
There is an official guide online: http://help.ovh.co.uk/RescueMode, but some information is missing about how to use it with SSH.

First, go into the Manager, Netboot, and choose «Rescue-pro», the reboot the server.
The access codes will be sent to your email, and will only be valid for this time.
Then, connect to your server with Putty (or any terminal depending on your OS).

Start with :
Code:
fdisk -l
Which will give you something like this (on this example : 2 disks in Raid1) :
Code:
root@rescue:~# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000cff0b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        4096    40962047    20478976   fd  Linux raid autodetect
/dev/sda2        40962048  1952471039   955754496   fd  Linux raid autodetect
/dev/sda3      1952471040  1953517567      523264   82  Linux swap / Solaris

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0002b644

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        4096    40962047    20478976   fd  Linux raid autodetect
/dev/sdb2        40962048  1952471039   955754496   fd  Linux raid autodetect
/dev/sdb3      1952471040  1953517567      523264   82  Linux swap / Solaris

Disk /dev/md2: 978.7 GB, 978692538368 bytes
2 heads, 4 sectors/track, 238938608 cylinders, total 1911508864 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/md2 doesn't contain a valid partition table

Disk /dev/md1: 21.0 GB, 20970405888 bytes
2 heads, 4 sectors/track, 5119728 cylinders, total 40957824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

Disk /dev/md1 doesn't contain a valid partition table
We can see that md1 is the system, the partition / , and md2 the partition /home, where you have your datas, sites, etc...

Then, to access it, you will have to mount these 2 partitions.
First, partition /
Code:
mount /dev/md1 /mnt/
Then, partition /home
Code:
mount /dev/md2 /mnt/home
From there, we can do all the modifications we need.

First check the partitions are correctly mounted, if the result is empty, that means it is not the cast (result on Debian), to do before a potential chroot
Code:
ls -alh /mnt
total 556K
drwxr-xr-x  22 root root 4,0K janv. 29 09:52 .
drwxr-xr-x  22 root root 4,0K janv. 29 09:52 ..
drwxr-xr-x   2 root root 4,0K oct.  13 17:05 bin
drwxr-xr-x   3 root root 4,0K janv. 12 01:26 boot
drwxr-xr-x  12 root root  14K janv. 10 09:06 dev
drwxr-xr-x 113 root root  12K janv. 24 22:17 etc
drwxr-xr-x   3 root root 4,0K nov.  13 23:51 home
drwxr-xr-x  16 root root  12K déc.  23 13:27 lib
drwxr-x---   2 root root 4,0K mars   8  2013 .LOCK
drwx------   2 root root  16K déc.   4  2010 lost+found
drwxr-xr-x   3 root root 4,0K févr.  9  2009 media
drwxr-xr-x   4 root root 4,0K juil. 11  2012 mnt
drwxr-xr-x   7 root root 4,0K déc.  13 19:03 opt
dr-xr-xr-x 177 root root    0 janv. 10 09:06 proc
drwxr-xr-x  26 root root 432K janv. 28 20:33 root
drwxr-xr-x  24 root root  720 janv. 30 03:16 run
drwxr-xr-x   2 root root 4,0K janv. 10 13:50 sbin
drwxr-xr-x   2 root root 4,0K sept. 16  2008 selinux
dr-xr-xr-x  11 root root    0 janv. 10 09:06 sys
drwxrwxrwt   3 root root  28K janv. 30 16:10 tmp
drwxr-xr-x  10 root root 4,0K mai   28  2013 usr
drwxr-xr-x  13 root root 4,0K janv. 29 09:51 var
We do a chroot in case we need to modify some system files :
Code:
chroot /mnt/
For instance, if you loose your root password :
Code:
passwd root
Enter the new password twice: we are saved!

This rescue mode is often usefull to check the state of the drives, see for the orders to do so the support can intervene.

If only have one single disk, put « sda » instead of « md »
Mount the partition /
Code:
mount /dev/sda1 /mnt/
Then now, partition /home
Code:
mount /dev/sda2 /mnt/home
And how to get out of the « rescue » ?
Very easy : Manager, Netboot (on HD or Netboot), then reboot the server. If you don't do that,you will reboot in rescue.

Your server is in rescue mode, and you want to recover your datas :
Mount the partitions

Then, connect with a FTP client (host = IP, user = root, password for rescue mode, port 22), and you will find your files.
You will be connected to the root folder. Go back to the root, to recover your datas in /home

Usually, the databases are located in /var/lib/mysql (standard distribs) or in /home/mysql (release OVH 2 and 3). It is not possible to make a dump in rescue mode, you have to copy the files.

You can also copy the files to an other server with SSH :
Code:
scp -r /path/ofthe/folders/toupload root@ip.of.newserver:/path/ofyour/choise
Survival tip :
never use on the manager an email address configured on this server : in case there is an issue, you will not be able to receive the emails with the rescue IDs. Choose a personal/standard email not related to your server.