Disclaimer
RAID
RAID (Redundant Array of Independent Disks) is designed to prevent data loss in the event of a hard disk failure. There are different “levels” of RAID. RAID 0 (striping) isn’t really RAID at all, because it provides no redundancy. It does, however, provide a speed benefit. The example will utilize RAID 0 for swap, on the assumption that a desktop system is being used, where the speed increase is worth the possibility of system crash if one of your drives fails. On a server, a RAID 1 or RAID 5 array is more appropriate. The size of a RAID 0 array block device is the size of the smallest component partition times the number of component partitions.
RAID 1 is the most straightforward RAID level: straight mirroring. As with other RAID levels, it only makes sense if the partitions are on different physical disk drives. If one of those drives fails, the block device provided by the RAID array will continue to function as normal. The example will be using RAID 1 for everything except swap. Note that RAID 1 is the only option for the boot partition, because bootloaders (which read the boot partition) do not understand RAID, but a RAID 1 component partition can be read as a normal partition. The size of a RAID 1 array block device is the size of the smallest component partition.
RAID 5 requires 3 or more physical drives, and provides the redundancy of RAID 1 combined with the speed and size benefits of RAID 0. RAID 5 uses striping, like RAID 0, but also stores parity blocks distributed across each member disk. In the event of a failed disk, these parity blocks are used to reconstruct the data on a replacement disk. RAID 5 can withstand the loss of one member disk.
ATTENTION: Do not be lulled into a false sense of security. Using RAID does not mean that you do not need backups – read the CAVEATS section below!
Procedure
Boot the Installer CD
First, load all your drives in the machine. Then boot the Arch Linux installation CD.
At the syslinux boot prompt, hit enter: we want to use the SCSI kernel, which has support for RAID and LVM built in.
So far, this is easy. Don’t worry, it gets harder.
Partition the Hard Drives
I recommend use cfdisk to do this partitioning. The cfdisk partitioning utility will open and allow you to create the partitions. For Arch base installation, there is only one partition needed. A swap partition is optional.
My example:
/dev/sda : 20GB
=> (/dev/sda1) /boot : 128MB
=> (/dev/sda2) swap : the remaining capacity
/dev/sdb : 320GB
=> (/dev/sdb1) / : 20GB (for OS & Server usage)
=> (/dev/sdb2) /home : ~140GB
=> (/dev/sdb3) /home2 : the remaining capacity
=> (/dev/sdb4) swap : 1GB
/dev/sdc : 160GB
=> (/dev/sdc1) / : 20GB (for OS & Server usage)
=> (/dev/sdc2) /home : ~140GB
=> (/dev/sdc3) swap : 1GBPartition 1 (/boot): 128MB, bootable
Partition 2 (RAID 0 swap): ~21.872GB
Partition 3 (RAID 1 /): 20GB
Partition 4 (RAID 1 /home): ~140GB
Partition 5 (/home2): the remaining capacity of /dev/sdb
# cfdisk /dev/sda
Create each partition in order:
- Select New.
- Hit Enter to make it a Primary partition.
- Type the appropriate size (in MB), or for Partition 3, just hit enter to select the remainder of the drive.
- Hit Enter to choose to place the partition at the Beginning.
- Select Type, hit enter to see the second page of the list, and then type fd for the Linux RAID Autodetect type.
- For Partition 1 on each drive, select Bootable.
- Hit down arrow (selecting the remaining free space) to go on to the next partition to be created.
- When you’re done, select Write, and confirm y-e-s that you want to write the partition information to disk.
- Then select Quit.
When you’re done, select Write, and confirm y-e-s that you want to write the partition information to disk. Then select Quit.
Repeat this for the other two drives:
# cfdisk /dev/sdb
# cfdisk /dev/sdcCreate the same exact partitions on each disk. If a group of partitions of different sizes are assembled to create a redundant RAID partition, it will work, but the redundant partition will be in multiples of the size of the smallest one, leaving the rest of the allocated drive space to waste. You can also use sfdisk to clone the partition table from your first drive to the other drives.
Use:
# sfdisk -d /dev/sda > table
to dump the partition from the first drive into table, and then
# sfdisk /dev/sdb < table
# sfdisk /dev/sdc < table
Load the RAID Modules
Before using mdadm, you need load the modules for the RAID levels you’ll be using. In this example, we’re using levels 1 and 5, so we’ll load those. You can ignore any modprobe errors like “cannot insert md-mod.ko: File exists”. Busybox’s modprobe can be a little slow sometimes.
# modprobe raid1
# modprobe raid5
Create the RAID Redundant Partitions
Now that you’ve created all the physical partitions, you’re ready to set up RAID. The tool you use to create RAID arrays is mdadm.
Flowing my example to create /dev/md0 (swap) , /dev/md1 (/) , /dev/md2 (home):
# mdadm –create /dev/md0 –level=0 –raid-devices=3 /dev/sda2 /dev/sdb4 /dev/sdc3
# mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sdb1 /dev/sdc1
# mdadm –create /dev/md2 –level=1 –raid-devices=2 /dev/sdb2 /dev/sdc2
On my case, I doesn’t has raid my boot’s partition. If you want to use Grub 0.97 (default in the Arch Linux 2010.05 release) on RAID 1, you need to specify an older version of metadata than the default. Add the option “–metadata=0.90″ to the above command. Otherwise Grub will respond with “Filesystem type unknown, partition type 0xfd” and refuse to install. This is supposedly not necessary with Grub 2.
For example:
# mdadm –create /dev/md1 –level=1 –raid-devices=3 –metadata=0.90 /dev/sda1 /dev/sdb1 /dev/sdc1
At this point, you should have working RAID partitions. When you create the RAID partitions, they need to sync themselves so the contents of all three physical partitions are the same on all three drives. The hard drives lights will come on as they try to sync up. You can monitor the progress by typing:
# cat /proc/mdstat
You can also get particular information about, say, the root partition by typing:
# mdadm –misc –detail /dev/md0
You don’t have to wait for synchronization to finish — you may proceed with the installation while syncronization is still occurring. You can even reboot at the end of the installation with synchronization still going.
Install and Configure Arch
This section doesn’t attempt to teach you all about the Arch Installer. It leaves out some details here and there for brevity, but still seeks to be basically follow-able. If you’re having trouble with the installer, you may wish to seek help elsewhere in the Wiki or forums.
Now you can continue using the installer to set-up the system and install the packages you need. Here’s the walkthrough:
- Type /arch/setup to launch the main installer.
- Select < OK > at the opening screen.
- Select 1 CD_ROM to install from CD-ROM (or 2 FTP if you have a local Arch mirror on FTP).
- If you have skipped the optional step (Create and Mount the Filesystems) above, and haven’t created a fileystem yet, select 1 Prepare Hard Drive > 3 Set Filesystem Mountpoints and create your filesystems and mountpoints here
- Now at the main menu, Select 2 Select Packages and select all the packages in the base category, as well as the mdadm and lvm2 packages from the system category. Note: mdadm & lvm2 are included in base category since arch-base-0.7.2.
- Select 3 Install Packages. This will take a little while.
- Note: Because the installer builds the initrd using /etc/mdadm.conf in the target system, you should update that file with your RAID configuration. The original file can simply be deleted because it contains comments on how to fill it correctly, and that is something mdadm can do automaticly for you. So let’s delete the original and have mdadm create you a new one with the currect setup:
- Press Alt-F2 to get a new terminal an log in, then do
- Select 4 Configure System:
Add the mdadm hook to the HOOKS list in /etc/mkinitcpio.conf (before ‘filesystems’, NOT after). See Configuring mkinitpcio using RAID for more details.Then exit the configuration menu.
- Select 6 Install Bootloader.
- Select 7 Exit Install to leave the installer program.
rm /mnt/etc/mdadm.conf
mdadm –examine –scan >> /mnt/etc/mdadm.conf
Edit Grub on the Primary Hard Drive
The arrays can be assembled on boot by the kernel using that hook and the contents of /etc/mdadm.conf, which is included in the initrd image when it’s build.
An example of a GRUB boot configuration for booting of a RAIDed root like this:
# (0) Arch Linux
title Arch Linux
root (hd0,0)
kernel /vmlinuz26 root=/dev/md0 ro
initrd /kernel26.img
Conclusion
Done.
Optimize & Other setting
Write-intent bitmap
For Raid1, we can enable bitmap function to speed-up rebuilding. A write-intent bitmap is used to record which areas of a RAID component have been modified since the RAID array was last in sync. Basically, the RAID driver periodically writes out a small table recording which portions of a RAID component have changed. Therefore, if you lose power before all drives are in sync, when the array starts up a full re-sync is not needed. Only the changed portions need to be re-synced.
Enable:
# mdadm –grow /dev/md1 –bitmap=internalDisable:
# mdadm –grow /dev/md1 –bitmap=none
Notification
If you want to receive e-mail alerts about your RAID system mdadmin must be configured with your e-mail address.
Make sure you can send mail from your machine. If all you need is basic SMTP support, you may wish to consider installing nail. This is a version of mail that can be compiled with SMTP support.
Make sure that the next line is in the /etc/mdadm.conf with the correct To e-mail address:
MAILADDR root@example.com
Source : http://wiki.archlinux.org/index.php/Installing_with_Software_RAID_or_LVM
Source : http://en.gentoo-wiki.com/wiki/RAID/Software