User:Svamberg/Software RAID
From FAIWiki
You might want to read Setup_harddisks_2 for an update on the status of a fai integrated solution.
Contents |
[edit]
Prerequisite
- mdadm package in NFSROOT
- your install and running kernel must supported software raid
[edit]
Install
You need two hooks if you want to support software raids based on mdadm. Your kernels need to support software raid.
- get the main hook mountdisks.SW_RAID and store it in the $FAI/hooks/ directory
- save the following lines as mountdisks.SW_RAID.source in the $FAI/hooks directory
#!/bin/sh . $LOGDIR/disk_var.sh
- add class SW_RAID to your $FAI/class/ configuration
[edit]
Configure
Configuration is stored as the $SW_RAID_CONFIG variable, a syntax of which is
md_raid_device[raid_options]=devices:mountpoint:filesystem[,mkfs_options]:mount_options:boot raid_options - raid_level[,mdadm_option[,next_mdadm_option[,...]]] devices - first_device,[next_device,[,...]]][;first_spare_device[,next_spare_device[,...]]]
For example:
SW_RAID_CONFIG=" md0[mirror]=/dev/sda1,/dev/sdb1:/boot:ext3:: md1[mirror]=/dev/sda2,/dev/sdb2:/:ext3:rw,errors=remount-ro:boot md2[mirror]=/dev/sda5,/dev/sdb5:none:swap:: md3[linear]=/dev/sda7,/dev/sdb7:/mnt/data:ext3,-T news:: "
[edit]
Example
As an example, let's assume we have two identical disks. We need all raids in mirror.
[edit]
Partitioning
Before using raid you need to partition the disks by editing the $FAI/disk_config file.
# <type> <mountpoint> <size in mb> [mount options] [;extra options] disk_config sda primary /boot 100 rw ; boot -j ext3 primary / 10000 rw,errors=remount-ro ; -j ext3 logical - 2000 logical - 2000 logical - 1024- logical - 1000 disk_config sdb primary - 100 primary - 10000 logical - 2000 logical - 2000 logical - 1024- logical - 1000
[edit]
Configure raids
Add the raid configuration into the .var file (in $FAI/class directory):
SW_RAID_CONFIG=" md0[mirror]=/dev/sda1,/dev/sdb1:/boot:ext3:: md1[mirror]=/dev/sda2,/dev/sdb2:/:ext3:rw,errors=remount-ro:boot md3[mirror]=/dev/sda5,/dev/sdb5:none:swap:: md4[mirror]=/dev/sda6,/dev/sdb6:none:swap:: md5[mirror]=/dev/sda7,/dev/sdb7:/var:ext3:: md6[mirror]=/dev/sda8,/dev/sdb8:/var/cache/openafs:ext3:: "
[edit]
Result
After installation /proc/mdstat says:
Personalities : [linear] [raid0] [raid1] [raid5]
md1 : active raid1 sde2[1] sdd2[0]
10241344 blocks [2/2] [UU]
md3 : active raid1 sde5[1] sdd5[0]
2048192 blocks [2/2] [UU]
md4 : active raid1 sde6[1] sdd6[0]
2048192 blocks [2/2] [UU]
md5 : active raid1 sde7[1] sdd7[0]
56211328 blocks [2/2] [UU]
md6 : active raid1 sde8[1] sdd8[0]
1028032 blocks [2/2] [UU]
md0 : active raid1 sde1[1] sdd1[0]
104320 blocks [2/2] [UU]
unused devices: <none>
