By MattOlz at 2005-12-09 17:55
Once I bought a second hard drive, I decided it was time to try out raid. I found searching around that most of the tutorials on setting up raid was either for old linux versions, for hardware raid, or for raid1 (mirroring). The closest how-to I could find was for a Slackware 8.1 system at http://www.userlocal.com/articles/raid0-slackware-linux.php - which is what this tutorial is mostly based on. I tried the methods described numerous times, and nothing prevailed. Finally, I winged it and tried the steps described in this tutorial.
1. I use 2 Maxtor 120 gig hds. Start off by partitioning your first drive drive using whatever is your preference:
A. You need 1 boot partition, type 83 (Linux) and mark it bootable. I made this 30mb.
B. Next partition you need is your swap, type 82 (Linux Swap), I made mine 350mb. Make this half the size you need. (I wanted a 700 mb swap.)
C. Set the rest of your drive as type FD (Linux Raid Autodetect).
2. On the second hd:
A. Set a partition equal to your boot partition and type it 83.
B. Set the second partition equal to the swap on the first.
C. Set the rest of your hard drive as FD.
So, I Have the following setup:
/dev/sda1 30mb 83
/dev/sda2 350mb 82
/dev/sda3 119.62gb fd
/dev/sdb1 30mb 83
/dev/sdb2 350mb 82
/dev/sdb3 119.62gb fd
Reboot to make sure everything is set right. Ignore any warnings that the sdb does not have a partition marked bootable.
Once you are back in the shell, make sure /dev/md0 exists: ls -l /dev/md0 . Output like the following is good:
brw-rw---- 1 root disk 9, 0 1998-04-02 01:37 /dev/md0
If not: mknod /dev/md0 b 9 0
Next you need to create a raidtab file, which basically tells the system all about your raid setup:
raiddev /dev/md0 #use the device /dev/md0
nr-raid-disks 2 #How many disks you want to use in the array.
nr-spare-disks 0 #Number of spare disks for reconstruction(not used in r0)
chunk-size 16 #How big you want each stripe (in kb)
persistent-superblock 1 #Puts array info on the superblock of each drive
raid-level 0 # Self-explanatory
device /dev/sda3 #First partition to use
raid-disk 0 #Remember arrays start at 0
device /dev/sdb3 #Second partition to use
Next build the array: mkraid /dev/md0 . If you get an error about it already existing, then tag a --force on it and read the spiel and warnings, then do as it says.
We have to then format this partition ourselves, since there are some special options needed: mke2fs -jb 4096 -R stride=4 /dev/md0 . /dev/md0 will be formatted ext3 with a 4kb block size . The stride is your chunk size divided by the block size.
Now you are ready to enter the setup. Once there, setup swap as usual, then add the partion /dev/md0 w/ no formatting as /, /dev/sda1 as /boot formatted to your preference, and /dev/sdb1 as whatever you want, formatted to your preference.
Install the software, and then install lilo to mbr (/boot).
When setup is done, DON'T REBOOT!
First we need to copy over the raidtab info to the drive: cp /etc/raidtab /mnt/etc/raidtab
Then check your /mnt/etc/fstab to make sure it has /dev/md0 and /dev/sda1 and /dev/sdb1 in it.
Lastly edit /mnt/etc/lilo.conf and set root = /dev/md0 . Run lilo -C /mnt/etc/lilo.conf to reinstall, and you are done. Reboot and your new system should now be working.