by Chris Atwood
1.About the Install
Before you start reading this how-to you should read the x86 install instructions several times to become familiar with the gentoo install process. Also note that as you install following these instructions you should have easy access to the normal instructions, you will need to refer back to them.
This how-to assumes that you are installing on two IDE drives, and that both are masters on different IDE channels (thus they are /dev/hda and /dev/hdc.) The CD-ROM you install off of could be /dev/hdb or /dev/hdd (it doesn't matter).
I decided to partition my drives similarily to how the gentoo install docs suggest.
Code: Select all
device mount size
/dev/hda1 /boot 100MB
/dev/hda2 swap >=2*RAM
/dev/hda3 / (big)
/dev/hda4 /home (big) (this partiton is optional)At this point let me just explain the common RAID levels and their pro and cons.
RAID 0: 2 or more hard drives are combined into one big volume. The final volume size is the sum of all the drives. When data is written to the RAID drive, the data is written to all drives in the RAID 0. This means that drive reads and writes are very fast, but if 1 drive dies you lose all your data.
RAID 1: 2 hard drives are combined into one volume the size as the smallest of the physical drives making it. The two hard drives in the RAID are always mirrors of each other. Thus, if a drive dies you still have all your data and your system operates as normal.
RAID 5: 3 or more hard drives are combined into one larger volume. The volume size is (# of drives -1) * drive size. You lose one drive of space because part of the space on each drive is a backup of the other drives. Thus if one drive dies you still have all your data, but if 2 die you lose everything.
Some general RAID notes. Ideally, all drives in a RAID should be the same size. Any difference in the drives makes it harder for the computer to manage the RAID. Also, and IDE drive in a a RAID should be on its own IDE channel. With IDE, a dead drive on a channel can bring down the whole channel. In a RAID setup this means that if a drive dies, two go down and your machine crashes.
2. Booting
Follow normal gentoo instructions in this section.
3. Load kernel modules
My machine uses a sis900 compatible network chip, so I use that driver. You should, of course, use your own network driver name in its place.
Code: Select all
#modprobe sis900Code: Select all
#modprobe md4. Loading PCMCIA kernel modules
Follow normal gentoo instructions in this section.
5. Configure installation networking
Follow normal gentoo instructions in this section.
6. Set up partitions
You need to use fdisk to setup your partitions. There is nothing different here except to make sure you fdisk both disks and that you set all partitions (except swap) to partition type fd (linux raid auto-detect). If you fail to do either of these steps you RAID will not work. Swap should be set to linux swap type.
This might be a good time to play with the "hdparm" tool. It allows you to change hard drive access parameters, which might speed up disk access. There is a pretty good forum thread about hdparm, I suggest doing a search for it.
Before we put any filesystem on the disks we need to create and start the RAID drives. So, we need to create /etc/raidtab. This file defines how the virtual RAID drives map to physical partitions. If you have hard drives of different size in a RAID 1 (not suggested), the smaller of the two should be raid-disk 0 in this file. My raidtab file ended up looking like this:
Code: Select all
# /boot (RAID 1)
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
chunk-size 32
persistent-superblock 1
device /dev/hda1
raid-disk 0
device /dev/hdc1
raid-disk 1
# / (RAID 1)
raiddev /dev/md2
raid-level 1
nr-raid-disks 2
chunk-size 32
persistent-superblock 1
device /dev/hda3
raid-disk 0
device /dev/hdc3
raid-disk 1
# /home (RAID 0)
raiddev /dev/md3
raid-level 0
nr-raid-disks 2
chunk-size 32
persistent-superblock 1
device /dev/hda4
raid-disk 0
device /dev/hdc4
raid-disk 1Code: Select all
# / (RAID 1 with hot-spare)
raiddev /dev/md2
raid-level 1
nr-raid-disks 2
nr-spare-disks 1
chunk-size 32
persistent-superblock 1
device /dev/hda3
raid-disk 0
device /dev/hdc3
raid-disk 1
device /dev/hdd1
spare-disk 0Code: Select all
raiddev /dev/md4
raid-level 5
nr-raid-disks 3
nr-spare-disks 1
persistent-superblock 1
chunk-size 32
parity-algorithm right-symmetric
device /dev/hda4
raid-disk 0
device /dev/hdb4
raid-disk 1
device /dev/hdc4
raid-disk 2
device /dev/hdd4
spare-disk 0Now we need to create the RAID drives so:
Code: Select all
#mkraid /dev/md*for all raid drives, where * is replaced by the device specified in the raidtab file.
I decided to put an ext2 filesystem on the /boot RAID drive:
Code: Select all
#mke2fs /dev/md0Remember how I mentioned that I was going to setup the swap space so that it would exist on more than one drive, but would not be in a RAID? So when we make the swap space we make two of them. Make the swap:
Code: Select all
#mkswap /dev/hda2
#mkswap /dev/hdc2And, since I want xfs on the / and /home RAIDs
Code: Select all
#mkfs.xfs -d agcount=3 -l size=32m /dev/md2
#mkfs.xfs -d agcount=3 -l size=32m /dev/md3The parameters added to the mkfs.xfs command come from the suggestions made in orginal x86 install guide. Both my / and /home partitions are about 9 GB, and XFS likes at least one allocation group per 4 GB. Thus I used an agcount of 3.
If you want an ext3 filesystems use:
Code: Select all
# mke2fs -j /dev/md2
# mke2fs -j /dev/md3Code: Select all
# mkreiserfs /dev/md2
# mkreiserfs /dev/md37. Mount partitions
Turn the swap on:
Code: Select all
#swapon /dev/hda2
#swapon /dev/hdc2Mount the / and /boot RAIDs:
Code: Select all
# mkdir /mnt/gentoo
# mount /dev/md2 /mnt/gentoo
# mkdir /mnt/gentoo/boot
# mount /dev/md0 /mnt/gentoo/boot8. Mounting the CD-ROM
Follow normal gentoo instructions in this section.
9. Unpack the stage you want to use
Follow normal gentoo instructions in this section, except for one addition. You need to copy your raidtab file over to your new gentoo root. So after you copy resolv.conf do this:
Code: Select all
# cp /etc/raidtab /mnt/gentoo/etc/raidtab10. Rsync
Follow normal gentoo instructions in this section.
11. Progressing from stage1 to stage2
Follow normal gentoo instructions in this section.
12. Progressing from stage2 to stage3
Follow normal gentoo instructions in this section.
13. Final steps: timezone
Follow normal gentoo instructions in this section.
14. Final steps: kernel and system logger
When in menuconfig be sure to compile in support for RAID devices and all RAID levels you plan to use. And, be sure to compile them into the kernel, don't compile them as modules. If you compile them as modules you have to load the modules before mounting the RAID devices, but if your / and /boot are the RAID you are in a catch-22. There are work-arounds, but it is much easier to just compile all RAID support into the kernel.
Also, since I put xfs filesystems on my machine I emerged the xfs-sources. Other than that, follow the instructions normally.
15. Final steps: install additional packages
Since I put xfs filesystems on my machine I emerged xfsprogs. Other than that, follow the instructions normally.
16. Final steps: /etc/fstab
Here again we need to let the computer know about our two swap partitions. You specify two or more paritions has swap here, and if you specify them with the same priority all of them will be use at the same time.
Also, be sure to specify the RAID drives and not the physical hard drives in the the fstab file for any drive that is a RAID. My fstab looks like this:
Code: Select all
/dev/md0 /boot ext2 noauto,noatime 1 2
/dev/md2 / xfs noatime 0 1
/dev/hda2 swap swap defaults,pri=1 0 0
/dev/hdc2 swap swap defaults,pri=1 0 0
/dev/md3 /home xfs noatime 0 1
/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
proc /proc proc defaults 0 0After that, follow instructions normally untill you get to grub.
Once you type
Code: Select all
#grubThe commands are the same as the standard install if you follow my partion setup. If you have deviated, type
Code: Select all
grub> find /boot/grub/stage1to get the hard-drive to specify in place of (hd0,0). Since the /boot partition is a RAID, grub cannot read it to get the bootloader. It can only access physical drives. Thus, you still use (hd0,0) in this step.
The menu.lst does change from the normal install. The difference is in the specified root drive, it is now a RAID drive and no longer a physical drive. Mine looks like this:
Code: Select all
default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title=My example Gentoo Linux
root (hd0,0)
kernel /boot/bzImage root=/dev/md217. Installation complete!
Follow normal gentoo instructions in this section.
18. Misc RAID stuff
To see if you RAID is functioning properly after reboot do:
Code: Select all
#cat /proc/mdstatThere should be one entry per RAID drive. The RAID 1 drives should have a "[UU]" in the entry, letting you know that the two hard drives are "up, up". If one goes down you will see "[U_]". If this ever happens your system will still run fine, but you should replace that hard drive as soon as possible.
To rebuild a RAID 1:
- Power down the system
- Replace the failed disk
- Power up the system once again
- Use
to re-insert the disk in the array
Code: Select all
raidhotadd /dev/mdX /dev/hdX - Watch the automatic reconstruction run





