The following steps will explain you how to setup RAID 1 on a Linux Server:-
Make sure you backup all-important data before using this tutorial. I will be not responsible for data loss.
But what is a RAID 1?
A single hard drive is mirrored i.e. an exact copy is made of the original drive. Thus, it result into the increased fault tolerance and easy data recovery option for single server.
Why I am setting a RAID-1 on running system?
Old system admin did not setup RAID -1 at the time of installation. It is true that the best and easy way to setup a RAID 1 is during installation. Simply create RAID software partition and install the system. Nevertheless, it wasn’t done during installation; so I was asked to do so.
Setting up RAID 1 mirroring is easy on running system. Recently we ordered new dedicated hosting server. But they did not setup mirroring for 2 hard disk. My setup was as follows:
/dev/hdb (/dev/hdb1 40 GB)
/dev/hdc (/dev/hdc1 40 GB)
Each partition has been 40 GB size ext3 formatted (make sure partition id is set to Linux raid auto).
RAID tools and software was installed. It is called mdadm.
Remember first software device will be /dev/md0, second will be /dev/md1 and so.
You need to type following command to setup /dev/md0:
mdadm –create /dev/md0 –level=1 –raid-devices=2 /dev/hdb1 /dev/hdc1
You can see status, health of /dev/md0 at /proc/mdstat. Type the following command:
Better uses watch command to refresh it automatically:
watch cat /proc/mdstat
Format /dev/md0 as ext3 fs:
Mount /dev/md0 at /data2 directory:
mount /dev/md0 /data2
Don’t forget to add /dev/md0 to /etc/fstab:
Append following text:
/dev/md0 /data2 ext3 defaults 0 0