RAID1 on Ubuntu 6.06.1 Server - Part II - Replacing & Rebuilding

In my previous article I explained the process in both theory and implementation on how to go about having a setup where you have an OS dependent RAID (Soft-RAID) while as the motherboard having features to assist Soft-RAID we still implement it the same way as we would without such pseudo-features.
In this article I will go on with the process of maintaining RAID setups as I have mentioned in my previous article. This includes replacing and rebuilding which are the most important parts of multi disk setups of this kind.

Headstart

By all means the server will continue to function normally when one of the two drives in our array fails. The RAID driver in the Linux kernel will proceed with removing the drive from the array and simply continue to use the other drive in our array for the machine’s functions relative to it. Note this is something done completely by the kernel module.
In the case though that your drive produces errors such as surface errors which will make the machine’s functions suffer but will not fail the machine cannot “flag it” if you will as a dead drive in order to remove it. With the use of the “mdadm” command we can remove the drive manually if we suspect eminent failure or errors on the disk.

Manually failing the drive
If you want to “flag” a drive as failed use the command as examplified below:

mdadm /dev/md0 -fail /dev/sda1

This will remove /dev/sda from the /dev/md0 array by flagging it as a failed drive thus unloading it directly from the kernel.

I think it is vital to make a very important note here. When you have one machine with two drives , identical or not ,they are never the less hard drives. In this machine they experience the same environmental , usage and other factors which will conclude their lifespan. Do not act shocked or amazed if both your drives fail at the same time.

When you have the md driver loaded for RAID in Ubuntu , it automatically detects errors due to its “monitor mode” and sends messages to the root account in the case of any trouble.

Manually Inspecting RAID

cat /proc/mdstat
mdadm –query –detail /dev/md0
mdadm –query –detail /dev/md1
The above are exemplified commands used to inspect various pieces of information on your RAID setup.

Replacing & Rebuilding

Lets move on to replacing the drive. A drive flagged as failed needs to be replaced the soonest. To do this you must destroy all partitions associated with the RAID setup partition. Example below.

mdadm –remove /dev/md0 /dev/sda1
mdadm –remove /dev/md1 /dev/sda2

This removed the first partition of /dev/sda from /dev/md0 and the second partition of /dev/sda from /dev/md1 . md* are the RAID partitions and /dev/sda is the referred drive that is flagged as failed. the appended number to each drive is of course the partition number.
You may now shut down the machine and replace the drive.

Boot Failure?

If you have problems booting it is probable that the drive that failed was the first drive in the array. This is indeed a problem that can be worked out by booting via the Ubuntu Server CD and going into rescue mode or any other boot CD that will allow you to boot via it’s grub. Once you have entered the grub boot screen on the CD use an example as below.

root (hd1,0)
kernel /boot/vmlinuz root=/dev/md0 ro
initrd /boot/initrd.img-
boot

hd1 means the second drive to be booted. If you do not know what to type use tab completion , thats what its there for.

Now that you have booted from the second drive you have to rebuild your first drive. This can be done as follows.

sfdisk –d /dev/sdb | sfdisk /dev/sda

NOTE: make sure you get the drive letters correct or you’ll be looking at two very corrupted drives.

This should copy the partition table from one disk to the other (second to the first). Now we can add them to our array.

mdadm –add /dev/md0 /dev/sda1
mdadm –add /dev/md1 /dev/sda2

That should do it! At this point your drives will start syncing. You may follow the progress by typing “cat /proc/mdstat” .

I hope this has been informative and I would like to thank you for reading.

Mario A. Spinthiras

Related posts:

  1. Software RAID1 on Ubuntu 6.06.1 Server This is a complete walk through of installing Ubuntu 6.06.1...
  2. Re-generating RSA/DSA Keys with OpenSSH The other day I thought it was going to be...
  3. Recovering Windows Vista Boot Records This is how I got into a lot of trouble....
  4. Quick way to install Ubuntu from a USB stick/thumb drive I needed to get Ubuntu 8.04 running as fast as...
  5. Ubuntu and the Ralink rt73 chipset. I’m sure that those who deal in wireless know the...

1 Response to “RAID1 on Ubuntu 6.06.1 Server - Part II - Replacing & Rebuilding”


  1. 1 JohnNo Gravatar

    Great site and useful content! Could you leave some opinion about my sites?
    My pages
    [url=http://ownsite.com/b/]My pages[/url]
    http://ownsite.com/p/ My pages

Leave a Reply