SystemRescueCD is a powerful, expansive live cd which is useful for recovering broken systems. This tutorial will guide you through how to get it up and running and how to perform some basic recovery procedures.
First of all, download the latest disc image from the SystemRescueCD website:
http://www.sysresccd.org/Main_Page
Burn it to disc, pop it in the CD drive of the server and boot. Check in BIOS to make sure the cdrom drive has boot priority. Then reboot and the server should boot into SystemRescueCD.
You can pass a number of options to the operating system before it boots; I find the following the most useful:
docache – Load the entire OS into RAM, freeing up the CD drive
rootpass – Define the root password, useful for SSH
dodhcp – Try to enable networking via DHCP
These parameters are passed like so:
rescuecd rootpass=password docache
More options can be viewed by pressing the F keys.
Once you have entered the options you want (always remember to put rescuecd first), press enter to boot. Once the system has booted, you will be presented with a standard root command prompt. If you did not choose DHCP at the boot prompt, you can either do it now by typing:
dhcpcd eth0 (replace eth0 with another network device if necessary)
Alternatively, you can set up the network manually by using this command:
net-setup eth0
Once the network is setup, you can SSH into the server; SSH is started automatically on boot.
Probably the most useful aspect of a live cd is copying files from a partition on the server hard disk, which is otherwise inaccessible. To mount a partition, first of all get a list of existing partitions:
fdisk -l
Here is an example output:
Disk /dev/sda: 150.0 GB, 150039945216 bytes
255 heads, 63 sectors/track, 18241 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009e255
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 586 4192965 82 Linux swap / Solaris
/dev/sda3 587 1108 4192965 83 Linux
/dev/sda4 1109 18241 137620822+ 5 Extended
/dev/sda5 1109 18241 137620791 83 Linux
In this case, we will mount the partition sda5. Navigate to the mnt directory:
cd /mnt
Create a directory with the same name as the partition:
mkdir sda5
Now mount the partition with the following command:
mount /dev/sda5 /mnt/sda5
This command should work for most Linux filesystems (ext2, ext3 etc). NTFS filesystems must be mounted by using the NTFS-3g driver; here is an example:
mount -t ntfs-3g /dev/sda5 /mnt/sda5
Once the disk is mounted, you can perform all the usual filesystem operations e.g. read, copy, write, delete. An example scenario would be if a web server had died due to hardware failure and you need to recover a specific home directory. A fast way of doing this is to simply plug in a USB stick using the instructions above and transfer the directory across to that.
Once the USB stick is mounted, browse to the home folder and locate the folder you want to transfer. Then, use the following command:
cp -v -R examplefolder /mnt/sdc1/
Replace examplefolder with the folder name, and sdc1 with the partition name. The -v switch enables verbose mode (so it tells you what its doing in a detail), and -R enables recursive mode, so it goes into the directory and copies all files within it.
There are a number of partitioning tools included in SystemRescueCD such as cfdisk and parted.
There is also a full graphical environment including tools like gparted for graphical manipulation of partitions. To start the graphical system, just type wizard at the command line.