Build a Linux Software RAID from Scratch - Page 2
Creating The Array and Filesystem
The next steps are starting up the array and creating filesystems. First create an
/etc/raidtab file. This is your master RAID configuration file. Let's say our new
data partitions are /dev/hdb1 and /dev/hdc1:
# /etc/raidtab raiddev /dev/md0 raid-level 0 nr-raid-disks 2 persistent-superblock 1 chunk-size 32 device /dev/hdb1 raid-disk 0 device /dev/hdc1 raid-disk 1
Now initialize the array:
# mkraid /dev/md0
Monitor progress:
# watch /proc/mdstat
Stop the watch command with CTRL+C. When the array is built you may create whatever filesystem you like on the data partitions: Ext2/3, JFS, ReiserFS, XFS, VFAT- anything that Linux supports. Use the utilities specific to the filesystems to create them. For example, this creates Ext3:
# mke2fs -j /dev/md0
This creates a Reiser filesystem:
# mkreiserfs /dev/md0
Be sure to follow the documentation for your chosen filesystem. Then create and initialize the swap partitions:
# mkswap /dev/hdb2
# mkswap /dev/hdc2
# swapon /dev/hdb2
# swapon /dev/hdc2
Start It Up
Now it's time to fire up your shiny new RAID 0 array:
# raidstart /dev/md0
Create mountpoints and mount the array:
# mkdir /mnt/raid0
# mount /dev/md0 /mnt/raid0
Now you can read and write to /mnt/raid0 just like any other directory.
Starting RAID at Boot
You probably want your nice new RAID 0 array to be automatically mounted at boot, so you
must add a line to your /etc/fstab file:
/dev/md0 /mnt/raid0 reiserfs defaults 0 1
Of course you may specify whatever mount options you like. Finally, there is one more kewl performance-enhancing trick you can do with the swap partitions. This is not a RAID function, but a kernel function- set up swapping in parallel in /etc/fstab:
/dev/hdb2 none swap sw,pri=0 0 0 /dev/hdc2 none swap sw,pri=0 0 0
This is a good time to reboot and verify that everything works. cat /proc/mdstat tells the status of the array.
RAID 1 and RAID 5
Now that you know the basics of setting up RAID, it's simple to create other RAID levels
in /etc/raidtab. RAID 1 is just the same as our RAID 0 example, except for this
line:
raid-level 1
Adding a three-disk RAID 5 array requires but three changes to /etc/raidtab:
raid-level 5 nr-raid-disks 3 parity-algorithm left-symmetric
Continued on page 3: Standby Spare Disk
|
|||
|
|||
|
Key IT Solutions
Copyright © 2012 QuinStreet Inc. All Rights Reserved.



