1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta content="text/html; charset=ISO-8859-1"
5
http-equiv="content-type">
6
<title>Gentoo - SoftRaid</title>
9
<span class="postbody"><span style="font-weight: bold;">How to do a
10
gentoo install on a software RAID</span>
16
<span style="font-weight: bold;">1.About the Install</span>
19
Before you start reading this how-to you should read the x86 install
20
instructions several times to become familiar with the gentoo install
21
process. Also note that as you install following these instructions you
22
should have easy access to the normal instructions, you will need to
26
This how-to assumes that you are installing on two IDE drives, and
27
that both are masters on different IDE channels (thus they are /dev/hda
28
and /dev/hdc.) The CD-ROM you install off of could be /dev/hdb or
29
/dev/hdd (it doesn't matter).
32
I decided to partition my drives similarily to how the gentoo install
37
<table align="center" border="0" cellpadding="3" cellspacing="1"
41
<td><span class="genmed"><b>Code:</b></span></td>
44
<td class="code">device
45
mount size
47
/dev/hda1 /boot
50
/dev/hda2 swap
53
/dev/hda3 /
56
/dev/hda4 /home
57
(big) (this partiton is optional)</td>
61
<span class="postbody"><br>
63
/boot and / will be a RAID 1 (mirror), /home will be a RAID 0, the
64
swap parition will be on both hda and hdc, but will not be a RAID (more
65
will be explained later).
68
At this point let me just explain the common RAID levels and their pro
72
<span style="font-weight: bold;">RAID 0:</span> 2 or more hard drives
73
are combined into one big volume. The final volume size is the sum of
74
all the drives. When data is written to the RAID drive, the data is
75
written to all drives in the RAID 0. This means that drive reads and
76
writes are very fast, but if 1 drive dies you lose all your data.
79
<span style="font-weight: bold;">RAID 1:</span> 2 hard drives are
80
combined into one volume the size as the smallest of the physical
81
drives making it. The two hard drives in the RAID are always mirrors of
82
each other. Thus, if a drive dies you still have all your data and your
83
system operates as normal.
86
<span style="font-weight: bold;">RAID 5:</span> 3 or more hard drives
87
are combined into one larger volume. The volume size is (# of drives
88
-1) * drive size. You lose one drive of space because part of the space
89
on each drive is a backup of the other drives. Thus if one drive dies
90
you still have all your data, but if 2 die you lose everything. <br>
92
Some general RAID notes. Ideally, all drives in a RAID should be the
93
same size. Any difference in the drives makes it harder for the
94
computer to manage the RAID. Also, and IDE drive in a a RAID should be
95
on its own IDE channel. With IDE, a dead drive on a channel can bring
96
down the whole channel. In a RAID setup this means that if a drive
97
dies, two go down and your machine crashes.
101
<span style="font-weight: bold;">2. Booting</span>
104
Follow normal gentoo instructions in this section.
108
<span style="font-weight: bold;">3. Load kernel modules</span>
113
My machine uses a sis900 compatible network chip, so I use that
114
driver. You should, of course, use your own network driver name in its
119
<table align="center" border="0" cellpadding="3" cellspacing="1"
123
<td><span class="genmed"><b>Code:</b></span></td>
126
<td class="code">#modprobe sis900</td>
130
<span class="postbody"><br>
132
We also have to load the module that allows for RAID support, so:
136
<table align="center" border="0" cellpadding="3" cellspacing="1"
140
<td><span class="genmed"><b>Code:</b></span></td>
143
<td class="code">#modprobe md</td>
147
<span class="postbody"><br>
150
<span style="font-weight: bold;">4. Loading PCMCIA kernel modules</span>
153
Follow normal gentoo instructions in this section.
157
<span style="font-weight: bold;">5. Configure installation networking</span>
160
Follow normal gentoo instructions in this section.
164
<span style="font-weight: bold;">6. Set up partitions</span>
167
You need to use fdisk to setup your partitions. There is nothing
168
different here except to make sure you fdisk both disks and that you
169
set all partitions (except swap) to partition type fd (linux raid
170
auto-detect). If you fail to do either of these steps you RAID will not
171
work. Swap should be set to linux swap type.
174
This might be a good time to play with the "hdparm" tool. It allows
175
you to change hard drive access parameters, which might speed up disk
176
access. There is a pretty good forum thread about hdparm, I suggest
177
doing a search for it.
180
Before we put any filesystem on the disks we need to create and
181
start the RAID drives. So, we need to create /etc/raidtab. This file
182
defines how the virtual RAID drives map to physical partitions. If you
183
have hard drives of different size in a RAID 1 (not suggested), the
184
smaller of the two should be raid-disk 0 in this file. My raidtab file
185
ended up looking like this:
189
<table align="center" border="0" cellpadding="3" cellspacing="1"
193
<td><span class="genmed"><b>Code:</b></span></td>
196
<td class="code"># /boot (RAID 1)
198
raiddev
201
raid-level 1
203
nr-raid-disks 2
205
chunk-size 32
207
persistent-superblock 1
209
device
212
raid-disk 0
214
device
217
raid-disk 1
223
raiddev
226
raid-level 1
228
nr-raid-disks 2
230
chunk-size 32
232
persistent-superblock 1
234
device
237
raid-disk 0
239
device
242
raid-disk 1
248
raiddev
251
raid-level 0
253
nr-raid-disks 2
255
chunk-size 32
257
persistent-superblock 1
259
device
262
raid-disk 0
264
device
267
raid-disk 1</td>
271
<span class="postbody"><br>
273
While I didn't have enought hard drives to do this, adding
274
hot-spares is often a good idea. This means if a drive in your RAID 1
275
goes down, you already have a spare drive in the machine that can be
276
used as a replacement. A raidtab with the hot spare option looks like
281
<table align="center" border="0" cellpadding="3" cellspacing="1"
285
<td><span class="genmed"><b>Code:</b></span></td>
288
<td class="code"># / (RAID 1 with hot-spare)
290
raiddev
293
raid-level 1
295
nr-raid-disks 2
299
chunk-size 32
301
persistent-superblock 1
303
device
306
raid-disk 0
308
device
311
raid-disk 1
319
<span class="postbody"><br>
321
And a RAID 5 (with hot-spare) raidtab looks like this:
325
<table align="center" border="0" cellpadding="3" cellspacing="1"
329
<td><span class="genmed"><b>Code:</b></span></td>
332
<td class="code">raiddev /dev/md4
341
persistent-superblock 1
345
parity-algorithm right-symmetric
365
<span class="postbody"><br>
368
Now we need to create the RAID drives so:
372
<table align="center" border="0" cellpadding="3" cellspacing="1"
376
<td><span class="genmed"><b>Code:</b></span></td>
379
<td class="code">#mkraid /dev/md*</td>
383
<span class="postbody"><br>
386
for all raid drives, where * is replaced by the device specified in the
390
I decided to put an ext2 filesystem on the /boot RAID drive:
394
<table align="center" border="0" cellpadding="3" cellspacing="1"
398
<td><span class="genmed"><b>Code:</b></span></td>
401
<td class="code">#mke2fs /dev/md0</td>
405
<span class="postbody"><br>
408
Remember how I mentioned that I was going to setup the swap space
409
so that it would exist on more than one drive, but would not be in a
410
RAID? So when we make the swap space we make two of them. Make the
415
<table align="center" border="0" cellpadding="3" cellspacing="1"
419
<td><span class="genmed"><b>Code:</b></span></td>
422
<td class="code">#mkswap /dev/hda2
424
#mkswap /dev/hdc2</td>
428
<span class="postbody"><br>
431
And, since I want xfs on the / and /home RAIDs
435
<table align="center" border="0" cellpadding="3" cellspacing="1"
439
<td><span class="genmed"><b>Code:</b></span></td>
442
<td class="code">#mkfs.xfs -d agcount=3 -l size=32m /dev/md2
444
#mkfs.xfs -d agcount=3 -l size=32m /dev/md3</td>
448
<span class="postbody"><br>
451
The parameters added to the mkfs.xfs command come from the
452
suggestions made in orginal x86 install guide. Both my / and /home
453
partitions are about 9 GB, and XFS likes at least one allocation group
454
per 4 GB. Thus I used an agcount of 3.
457
If you want an ext3 filesystems use:
461
<table align="center" border="0" cellpadding="3" cellspacing="1"
465
<td><span class="genmed"><b>Code:</b></span></td>
468
<td class="code"># mke2fs -j /dev/md2
470
# mke2fs -j /dev/md3</td>
474
<span class="postbody"><br>
476
Or to create ReiserFS filesystems, use:
480
<table align="center" border="0" cellpadding="3" cellspacing="1"
484
<td><span class="genmed"><b>Code:</b></span></td>
487
<td class="code"># mkreiserfs /dev/md2
489
# mkreiserfs /dev/md3</td>
493
<span class="postbody"><br>
496
<span style="font-weight: bold;">7. Mount partitions</span>
503
<table align="center" border="0" cellpadding="3" cellspacing="1"
507
<td><span class="genmed"><b>Code:</b></span></td>
510
<td class="code">#swapon /dev/hda2
512
#swapon /dev/hdc2</td>
516
<span class="postbody"><br>
519
Mount the / and /boot RAIDs:
523
<table align="center" border="0" cellpadding="3" cellspacing="1"
527
<td><span class="genmed"><b>Code:</b></span></td>
530
<td class="code"># mkdir /mnt/gentoo
532
# mount /dev/md2 /mnt/gentoo
534
# mkdir /mnt/gentoo/boot
536
# mount /dev/md0 /mnt/gentoo/boot</td>
540
<span class="postbody"><br>
544
<span style="font-weight: bold;">8. Mounting the CD-ROM</span>
547
Follow normal gentoo instructions in this section.
551
<span style="font-weight: bold;">9. Unpack the stage you want to use</span>
554
Follow normal gentoo instructions in this section, except for one
555
addition. You need to copy your raidtab file over to your new gentoo
556
root. So after you copy resolv.conf do this:
560
<table align="center" border="0" cellpadding="3" cellspacing="1"
564
<td><span class="genmed"><b>Code:</b></span></td>
567
<td class="code"># cp /etc/raidtab /mnt/gentoo/etc/raidtab</td>
571
<span class="postbody"><br>
574
<span style="font-weight: bold;">10. Rsync</span>
577
Follow normal gentoo instructions in this section.
581
<span style="font-weight: bold;">11. Progressing from stage1 to stage2</span>
584
Follow normal gentoo instructions in this section.
588
<span style="font-weight: bold;">12. Progressing from stage2 to stage3</span>
591
Follow normal gentoo instructions in this section.
595
<span style="font-weight: bold;">13. Final steps: timezone</span>
598
Follow normal gentoo instructions in this section.
602
<span style="font-weight: bold;">14. Final steps: kernel and system
606
When in menuconfig be sure to compile in support for RAID devices
607
and all RAID levels you plan to use. And, be sure to compile them into
608
the kernel, don't compile them as modules. If you compile them as
609
modules you have to load the modules before mounting the RAID devices,
610
but if your / and /boot are the RAID you are in a catch-22. There are
611
work-arounds, but it is much easier to just compile all RAID support
615
Also, since I put xfs filesystems on my machine I emerged the
616
xfs-sources. Other than that, follow the instructions normally.
620
<span style="font-weight: bold;">15. Final steps: install additional
625
Since I put xfs filesystems on my machine I emerged xfsprogs. Other
626
than that, follow the instructions normally.
630
<span style="font-weight: bold;">16. Final steps: /etc/fstab</span>
633
Here again we need to let the computer know about our two swap
634
partitions. You specify two or more paritions has swap here, and if you
635
specify them with the same priority all of them will be use at the same
639
Also, be sure to specify the RAID drives and not the physical hard
640
drives in the the fstab file for any drive that is a RAID. My fstab
645
<table align="center" border="0" cellpadding="3" cellspacing="1"
649
<td><span class="genmed"><b>Code:</b></span></td>
652
<td class="code">/dev/md0 /boot
653
ext2 noauto,noatime 1 2
655
/dev/md2 /
656
xfs noatime
659
/dev/hda2 swap swap
660
defaults,pri=1 0 0
662
/dev/hdc2 swap swap
663
defaults,pri=1 0 0
665
/dev/md3 /home xfs
666
noatime 0 1
668
/dev/cdroms/cdrom0 /mnt/cdrom iso9660
669
noauto,ro 0 0
671
proc /proc
672
proc defaults
677
<span class="postbody"><br>
680
After that, follow instructions normally untill you get to grub.
687
<table align="center" border="0" cellpadding="3" cellspacing="1"
691
<td><span class="genmed"><b>Code:</b></span></td>
694
<td class="code">#grub</td>
698
<span class="postbody"><br>
701
The commands are the same as the standard install if you follow my
702
partion setup. If you have deviated, type
706
<table align="center" border="0" cellpadding="3" cellspacing="1"
710
<td><span class="genmed"><b>Code:</b></span></td>
713
<td class="code">grub> find /boot/grub/stage1</td>
717
<span class="postbody"><br>
720
to get the hard-drive to specify in place of (hd0,0). Since the
721
/boot partition is a RAID, grub cannot read it to get the bootloader.
722
It can only access physical drives. Thus, you still use (hd0,0) in this
726
The menu.lst does change from the normal install. The difference is
727
in the specified root drive, it is now a RAID drive and no longer a
728
physical drive. Mine looks like this:
732
<table align="center" border="0" cellpadding="3" cellspacing="1"
736
<td><span class="genmed"><b>Code:</b></span></td>
739
<td class="code">default 0
743
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
746
title=My example Gentoo Linux
750
kernel /boot/bzImage root=/dev/md2</td>
754
<span class="postbody"><br>
758
<span style="font-weight: bold;">17. Installation complete!</span>
761
Follow normal gentoo instructions in this section.
765
<span style="font-weight: bold;">18. Misc RAID stuff</span>
768
To see if you RAID is functioning properly after reboot do:
772
<table align="center" border="0" cellpadding="3" cellspacing="1"
776
<td><span class="genmed"><b>Code:</b></span></td>
779
<td class="code">#cat /proc/mdstat</td>
783
<span class="postbody"><br>
786
There should be one entry per RAID drive. The RAID 1 drives should
787
have a "[UU]" in the entry, letting you know that the two hard drives
788
are "up, up". If one goes down you will see "[U_]". If this ever
789
happens your system will still run fine, but you should replace that
790
hard drive as soon as possible.
799
<li>Power down the system
802
<li>Replace the failed disk
805
<li>Power up the system once again
810
<table align="center" border="0" cellpadding="3" cellspacing="1"
814
<td><span class="genmed"><b>Code:</b></span></td>
817
<td class="code">raidhotadd /dev/mdX /dev/hdX</td>
821
<span class="postbody"><br>
822
to re-insert the disk in the array
825
<li>Watch the automatic reconstruction run