How to use Rescue Mode

Rescue Mode grants you full access to a non-bootable slice's filesystem. You can use it to modify problem configuration files or to use scp to copy data from the slice to a remote location.


Rescue Mode gives you full access to a non-bootable slice's fileystem so that you can repair it. Typically, you will use it to remove startup scripts in /etc/init.d/, or to modify problem configuration files, or - at worst - to use scp to copy off data from the slice to a remote location.

For long-time Linux users, rescue mode is similar to booting into single-user mode with networking enabled.

Get the slice into Rescue Mode

To get a slice into Rescue Mode, log into Slice Manager at: https://manage.slicehost.com

Then click on the slice name (if you have more than one slice).

Then click on the 'Rescue' link which is at the top right.

This should display a page of text with two options. Read and understand the text and click on the top 'Rescue' button.

Watch the page to see the temporary root password that will be displayed at the top against a green background. Make a note of that password. You will be able to ssh in to the slice as the 'root' user using this temporary root password. The Rescue Mode IP will be the usual primary IP for the slice.

Mounting the file system

Before you can access the files on your server you'll need to mount the server's file system. To do that we'll need to determine your file system's device. Once you've logged into your server in Rescue Mode, run the command:

fdisk -l

You'll get output that looks something like this:

Disk /dev/sdb1: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

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

Disk /dev/sda1: 10.2 GB, 10200547328 bytes
255 heads, 63 sectors/track, 1240 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

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

Disk /dev/sda2: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Don't panic. We don't need all of that, we're only going to skim.

The chunks of text we care about are the ones that start out like:

Disk /dev/sdb1: 2147 MB

That's all we're looking for, the "Disk" part (which shows us the device) and the size of the disk. You should see three blocks of text that start out that way.

The first block, the one with the size of about 2GB, is the rescue mode filesystem.

The second block, the one in the screenshot with a size of 10.2GB, is your server's file system. Its size will be different depending on the size of your server, of course.

The third block will be your swap space. Don't worry about that bit unless you know you need to.

Once you've identified the block for your server's file system check out that part after "Disk" that looks like a file path. That's the device (leave out the colon). In the example above, the device is:

/dev/sda1

That could also be "/dev/sdb1" or "/dev/xvda1". It will differ depending on the distribution image used to build your server.

Now that you know your file system's device you can assign it a directory and mount it for access. Plug your file system device into the following command in place of "/dev/diskdevice":

mount /dev/diskdevice /mnt

For example, for /dev/sda1 the command would be:

mount /dev/sda1 /mnt

Working with files

Your slice files will now be visible in /mnt/.

Now you can carry out repairs. For example, if your slice has been booting straight into swapping mode and thus denying access via the usual ssh and Console methods, you might use Rescue Mode access to temporarily remove the MySQL start up script - bearing in mind that the startup script's location is now:

/mnt/etc/init.d/

Similarly, any configuration files you want to modify are in their normal location but with the /mnt/ directory prepended to the directory path.

You will also now be able to use 'scp' and 'sftp' to securely copy files on to and off of the slice.

You will be able to transfer files over the slice's normal public network interface, or over its normal private interface to another slice (if you have another slice).

Note: You can also use Slice Manager's Console mode to access the slice in Rescue Mode. If you do, you will also be able to see the slice booting into Rescue mode. This may help you understand the process a slice goes through to get into Rescue Mode.

How to get out of Rescue Mode

Once you are done, unmount the '/mnt' filesystem with:

umount /mnt

To exit Rescue Mode go to the Slice Manager and, once again, click on the 'Rescue' link at the top right. This should display a page of text with two options. Read and understand the text and click on the top 'Exit Rescue Mode' button.

And your slice should now be out of Rescue Mode!

Summary

Slicehost's Rescue Mode is quite easy to use once you understand what it does and how to access your root filesystem.

Further Information:

The original Slicehost announcement concerning the addition of Rescue Mode to the Slice Manager can make for good background.

For more on Rescue Mode, read page 11 of our Slice Administration Guide.

Lee

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)