Introduction ============================================================== This document explains how to install Nakshatra Linux on a software RAID root filesystem. It is meant to cover only software raid. If you are using a RAID expansion card, or the RAID functionality that came with your motherboard, this document will not be useful for you. The raid levels supported are 0,1 and 5 In order to make this work, your machine must have two or more empty hard drives. While it is possible to be creative and create RAID arrays on drives that already contain data, it can be error prone. ============================================================== Warning: Following the below instructions drives with data on them WILL DESTROY ALL YOUR EXISTING DATA. So please backup any data that is important. =============================================================================== First, determine which RAID level you want to use. Here's a quick summary of the supported RAID levels: - RAID 0: Requires minimum 2 drives. Can usemore. Has no redundancy but improves performance by "striping", or interleaving, data between all drives. This setup is NOT fault tolerant. If you lose one drive, all of your data is lost. - RAID 1: Requires minimum 2 drives. Can use more. Offers data redundancy by mirroring data across all drives. This RAID level is by far the simplest way to protect your data, but is not the most space-efficient method. eg: If you use 3 drives in a RAID 1 array you gain redundancy, but you still have only 1 disk's worth of space available for use. - RAID 5: Requires 3 or more hard drives. Offers data redundancy by storing parity data on each drive. Exactly one disk's worth of space will be used to hold parity data, so while this RAID level is heaviest on the CPU, it is also the most space efficient way of protecting your data. For example, if you use 5 drives to create a RAID 5 array, you will only lose 1 disk's worth of space (unlike RAID 1), so you will end up with 4 disk's worth of space available for use. While simple to setup, this level is not quite as straightforward as setting up RAID 1. Setup =============================================================================== === Partition hard drives === Once you have logged in as root in the installer, the first step is to partition the hard drives that will be used in the RAID array(s). Let us assume the hard drive is /dev/sda. In case it is different adjust the following commands accordingly. You can see your drives by running: cat /proc/partitions - /boot : RAID 0 and RAID 5 users will require a separate boot partition as the computer's BIOS will not understand striped devices. For the sake of simplicity, we will make /boot a small RAID 1 (mirror) array. This means that in the case of RAID 0, it will not matter which drive your BIOS attempts to boot, and in the case of RAID 5, losing one drive will not result in losing your /boot partition. We recommend 500MB for this partition so that, should the need arise, you can install multiple kernels. Create a small boot partition now on /dev/sda via cfdisk/fdisk. Ensure that the partition type is Linux RAID Autodetect (type FD). - / : Every setup will require a root partition. You will likely want to create a partition takes up most of the rest of the drive. Remember to save some space (say 500MB) after this partition (see below) If you are not creating a swap partition, We recommend leaving 500MB of unused space at the end of the drive. (see "safety" for explanation) Go ahead and create your main partition now on /dev/sda. Again Ensure that the partition type is Linux RAID Autodetect (type FD). - swap : Swap space is where Linux stores data when you're running low on available RAM. For fairly obvious reasons, building this on RAID 0 could be painful (if that array develops a bad sector, for example), so I tend to build swap on RAID 1 as well. If you understand the danger and still want to build swap on RAID 0 to eke out as much performance as possible, go for it. For RAID 1 swap, create a partition that is the exact size that you want your swap space to be (say 2GB). For RAID 0 swap is not recommended, create a partition that is equivalent to the swap size you want, divided by the number of drives that will be in the array. For example, 2GB / 3 drives = 683MB swap partition on /dev/sda. Ensure that the partition type is Linux RAID Autodetect (type FD). I recommend leaving 500MB of unused space at the end of the drive. (see "safety" for explanation) See also: Appendix A - Striping swap space without RAID 0. =============================================================== safety! We highly recommend leaving 500MB of unpartitioned space at the end of each drive that will be used in the RAID array(s). In the event that you need to replace one of the drives in the array, there is no guarantee that the new drive will be exactly the same size as the drive that you are replacing. For example, even if both drives are 750GB, they may be different revisions or manufacturers, and thus have a size difference of some small number of megabytes. So having that small 500MB buffer just may be useful. =============================================================== === Copy and review partitions === Now that /dev/sda is partitioned as appropriate, copy the partitions to all the other drives to be used in your RAID arrays. After this, your partitions should look something like the following: - RAID 0: /dev/sda1 500MB /dev/sdb1 500MB /dev/sda2 100GB /dev/sdb2 100GB /dev/sda3 2GB /dev/sdb3 2GB - RAID 1: /dev/sda1 100GB /dev/sdb1 100GB /dev/sda2 2GB /dev/sdb2 2GB - RAID 5: /dev/sda1 500MB /dev/sdb1 500MB /dev/sdc1 500MB /dev/sda2 100GB /dev/sdb2 100GB /dev/sdc2 100GB /dev/sda3 2GB /dev/sdb3 2GB /dev/sdc3 2GB All partition types should be Linux RAID Autodetect (type fd). === Create RAID arrays === Now it's time to create the actual RAID arrays based on the partitions that were created. The parameters for each of these RAID commands specifies, in order: - the RAID device node to create (--create /dev/mdX) - the name to use for this array (--name=X) Note that there is no requirement that you use this format, i.e. /dev/md0 --> name=0 ; the result is that /dev/md0 will be /dev/md/0, which means you could also do e.g. --name=root and get /dev/md/root - the RAID level to use for this array (--level X) - how many devices (partitions) to use in the array (--raid-devices X) - the actual list of devices (/dev/sdaX /dev/sdbX /dev/sdcX) - OPTIONAL: if you know the hostname you plan to give the system, you could also specify "--homehost=hostname" when creating the arrays. Start by creating the RAID array for your root filesystem. RAID 0: # mdadm --create /dev/md0 --name=0 --level 0 --raid-devices 2 \ /dev/sda2 /dev/sdb2 RAID 1: # mdadm --create /dev/md0 --level 1 --raid-devices 2 \ /dev/sda1 /dev/sdb1 RAID 5: # mdadm --create /dev/md0 --name=0 --level 5 --raid-devices 3 \ /dev/sda2 /dev/sdb2 /dev/sdc2 Next, let's create the array for the swap partition. This will be RAID 1 regardless of which RAID level your root filesystem uses, but given our partition layouts, each command will still be slightly different. - RAID 0: # mdadm --create /dev/md1 --name=1 --level 1 --raid-devices 2 \ /dev/sda3 /dev/sdb3 - RAID 1: # mdadm --create /dev/md1 --name=1 --level 1 --raid-devices 2 \ /dev/sda2 /dev/sdb2 - RAID 5: # mdadm --create /dev/md1 --name=1 --level 1 --raid-devices 3 \ /dev/sda3 /dev/sdb3 /dev/sdc3 Finally, RAID 0 and RAID 5 users will need to create their /boot array. RAID 1 users do not need to do this. - RAID 0: # mdadm --create /dev/md2 --name=2 --level 1 --raid-devices 2 \ /dev/sda1 /dev/sdb1 - RAID 5: # mdadm --create /dev/md2 --name=2 --level 1 --raid-devices 3 \ /dev/sda1 /dev/sdb1 /dev/sdc1 Finally we are done with creating our RAID arrays. Before we can run setup, we need to format our swap array, so the installer recognizes it, So : # mkswap /dev/md1 Now we can run setup to install Nakshatra Linux. # setup When you choose to setup your swap partitions, /dev/md1 will show up. When asked for the target partition, choose the root array (/dev/md0). You may choose the format method and filesystem of your choice. We recommend the traditional linux ext4 filesystem. RAID 0 and RAID 5 users must also setup /boot. When asked about setting up extra partitions, choose /dev/md2. When asked where to mount this device, enter "/boot". After this, continue installation as normal. Once the installation completes, GRUB will be installed as the bootloader. This completes the RAID mode installation for Nakshatra Linux. ===============================================================================