Fakeraid mirror

From MEPIS Documentation Wiki

Jump to: navigation, search

Setting up a raid 1 mirror on a fakeraid controller

A couple of requirements

This manual is based on procedures pertaining to Simplymepis 3.4.3 (rc3). More specifically, the section 'Make initrd image' cannot be used for version 3.3. or lower!

You should be familiar with the concept of disk partitions and fstab.

You are supposed to be familiar with installing packages, editing files from the command line and setting up the BIOS.

Some definitions

RAID sets are made up of two or more disks, and serve to enhance performance and / or data security. Most common RAID solutions are:

  • RAID 0, which allows you to join an array of disks into one virtual device. This solution is used to improve disk performance and capacity.
  • RAID 1, which allows you to setup two disks that are identical mirrors. If one disk fails, the second disk allows you to keep on working, thus preventing data loss and downtime.
  • RAID 5, which consists of a minimum of three disks. Data is partitioned in blocks, which are spread over two disks. The third disk contains parity information, which serves to rebuild the data blocks should one disk fail. This solution is typically used in server environments. It is used for building large capacity disk arrays and data protection.

RAID flavours

  • Hardware RAID. Based on a hardware controller in the PC, which takes care of the way data are written to the disks. This solution is completely transparent to the OS, i.e. the OS will see the disk as if it were only one physical device, whereas the underlying hardware may consist of a great number of disks.
  • Software RAID. This RAID solution is set up from within the OS. It does not require special disk controllers but is of course OS dependent.
  • Fake RAID. This is a hybrid solution. The disk controller will add some meta information to the disks and allows you to synchronize the disks when you build up the RAID set (typically a mirror set of two disks). It requires a device driver within the OS to map the disk set to a virtual device that is seen by the OS as one disk. Fake raid is typically used with SATA disks. In linux, the tool to map your raid set to a virtual device on your file system is dmraid.


To begin with, you can connect both drives to the controller. However, you should not set them up as a mirror set in the BIOS. This manual will not explain how to do that either. Consult the manual that came with your motherboard or the disk controller.

Boot your PC off the Simplymepis CD and start the installation. You can choose if you want to partition the disk yourself or let the installer do it for you. Assuming you only have to SATA disks in your PC, you will have the option to install on sda1 or sda2. Pick sda1, since this will be the source disk to later create the mirror. When asked for the grub installation, install it in the MBR.

Once the installation has finished, reboot the PC. Login to Mepis and fire up Synaptic to install the package 'dmraid'. Also, write down the partition numbers that were created (eg. sda1 for root, sda2 for home etc.) Reboot the PC.

When the proper message is shown by the BIOS, enter setup mode for the raid set. Build the mirror set and make sure to set the disk on channel 0 (sda1) as the source. The controller will now start to make an exact copy of the disk, which will take quite a while (an hour or more is normal).

Configure Mepis to use fake raid

When the mirror set has been created, you can boot the machine again. If you watch the boot messages, you will likely see a message that dmraid has detected a raid set. This shows that the controller is recognized. Should dmraid tell you no raid set was found, you will probably have a non-supported controller.

Login, open a console and su to root. Give the command dmraid -s. You should get some information on the raid set that is found on your system. One of the items will be the name of the device. Write this down, since you will need it a couple of times.

To make sure that dmraid properly detected the device, do 'ls /dev/mapper'. /dev/mapper will be the location in the file system where you can later access the raid device. The content of /dev/mapper should be one file with the name that you just wrote down. I will use the fictitious name <fake_raiddevice> from now on. So /dev/mapper/<fake_raiddevice> should be read as the name of your raid device.

If the device was detected, we now have to make some adjustments in /etc/fstab. This holds the names of the physical disks, which should be replaced by the name of raid set. Find the fstab entries that point to swap, root and home, and change the device names. E.g.:

/dev/sda1 / reiserfs defaults,noatime,notail 0 0

should be changed to:

/dev/mapper/<fake_raiddevice>1 / reiserfs defaults,noatime,notail 0 0

Create initrd image

The Mepis boot process is a two step process. Before the actual kernel is booted, the system boots off an initrd image. This will create a temporary ram disk that loads a couple of modules and drivers that are necessary for the rest of the boot process. In our case, this allows us to load the dmraid fakeraid driver and create the devices for it, so that the file system can be mounted on top of the raid set, rather than the physical disks. We need therefore to create an image that loads the modules required by dmraid and a couple of scripts to load the device mapper.

Go to the directory /etc/mkinitramfs (as root) and edit the file modules. Add the following lines:


Save the file.

Now go to /etc/mkinitramfs/hooks and create a file called dmraid. Edit it and paste in the following content:

              echo "$PREREQ"
       case $1 in
       # get pre-requisites
       exit 0
       . /usr/share/initramfs-tools/hook-functions
       copy_exec /sbin/dmraid /sbin
       exit 0

Save the file and make it executable (chmod +x dmraid).

Go to /etc/mkinitramfs/scripts/local-top and create a file called dmraid. Paste in the following content:

       echo "$PREREQ"
       case $1 in
       # get pre-requisites
       exit 0
       modprobe -q dm-mod
       modprobe -q dm-mirror
       /sbin/dmraid -ay

Save the file and make executable as well.

Now create the new image: mkinitramfs -o initrd_raid.img. When this command has finished, there should be a shiny new image in /boot with the name initrd_raid.img.

Modifying grub The last part we should do is to tell grub to start the boot process with the new image, and to use the root directory off the raid set.

From the console, as root, go to /boot/grub. Open the file device.map for editing. It will contain a line that says:

(hd0) 	/dev/sda. 

Change this to:

(hd0)	/dev/mapper/<fake_raiddevice>

Save the file.

Now edit the file menu.lst. It will show something like this (may vary):

Title Mepis 3.4.3-1-586.tsc
kernel /boot/vmlinuz-2.6.12 root=/dev/hda1 nomce quiet vga=791 
initrd /boot/initrd.img

Copy and paste, and change the new entry to

Title: Mepis RAID
kernel /boot/vmlinuz-2.6.12 root=/dev/mapper/<fake_raiddevice> nomce quiet vga=791 
initrd /boot/init_raid.img

Save the file.

Before rebooting, copy the modified files (fstab, device.map, menu.lst, init_raid.img) to the mirror disk in the corresponding directories. That way, you will be sure that you can use the disk directly in case the source should fail.

Reboot the machine and choose the new grub entry. You should now boot into the mirror set.


In the first place, on my 3.4.3 RC3 installation, I got a bootup message telling me there was some script missing for LVM. I ignored this message and it did not seem to affect the correct workings.

In the second place: the fakeraid implementation is still a bit flaky. Instead of just reporting the raid device to the OS, I also had entries in fstab for the physical disks. If you look in /dev, you will see that there are /dev/sda and /dev/sdb entries with their corresponding partitions. This means that e.g. the media list in Konqueror still shows all partitions for both disks. You will not be able to mount them, but still, they'll be there.

In the third place: the fakeraid does not allow you to flexibly use your disks. I like to have different partitions on the disk so I can use them to install different distros in a multi boot setup. However, once the mirror set has been created, you can only use the partitions from within the modified Mepis OS. The mirror solution is therefore especially interesting if you wish to absolutely make sure to minimize data loss and downtime. If you want to setup a mirror as a backup alternative, I would recommend using rsync to copy your /home partition to a 2nd disk via a periodic cron job.

Useful links

The document I used as a basis for this howto:


General info regarding SATA and fakeraid:


Personal tools
In other languages