bash, perl, cfengine, etc.
#!/bin/sh
# dump the partition table for these disks to standard output
disks=(/dev/hda /dev/hdb /dev/hdc /dev/hdd)
for $disk in ${disks[@]}; do
sfdisk -d $disk
done
FAI has its own init scripts and subroutines which it uses to install and configure a base system. tasks are actions which can be taken, and rcS_fai is the system init script. Below is a breakdown of the normal actions and tasks which can be taken by FAI.
FAI_ACTION=install rcS_fai fai_init task_action task_install task_partition - partition harddisks task_mountdisks - mount harddisks - raidpartition task_extrbase - extract the base system task_mirror - mount debian mirror task_updatebase - update base system task_instsoft - install software packages task_configure task_finish - installation finished date task_chboot - task_savelog class FAI_ACTION=sysinfo task_sysinfo task_faiend die (spawn shell)
FH602 - Ferris Hall 602 lab machines, includes specific configurations, scripts, files FH602_TA - Ferris Hall 602 TA machine, includes specific scrips differing from 602 lab OTHER
RAID0 - Striping mode, suggested 2 disks minimum RAID1 - Disk mirroring support, suggested 2 disks minimum RAID4/5
The following is a summary of the process which is used to script software RAId installation with FAI. See also the RAID scripts which were derived from this information.
To install RAID on a host, first install the nescessary software.
aptitude install mdadm
Then decide which mode you are going to do RAID with. If you are going to be using RAID1, for example, make sure your kernel is compiled with RAID1 support.
modprobe md lvm-mod raid1
To create a RAID array on a disk which is not mounted on /, with two partitions on hda and hdb to be mirrors, chunk size 32, and 2 disks in the array, in RAID1 mode:
sfdisk -d /dev/hda > /tmp/hda.sfdisk sfdisk --force /dev/hdb < /tmp/hda.sfdisk mdadm --create --verbose /dev/md0 -l 1 -c 32 -n 2 /dev/hda1 /dev/hdb1 mke2fs -j -b 4096 -R stride=8 /dev/md0
This will partition disk hdb the same as hda and the create a 2 disk RAID1 array, using partitions /dev/hda1 and /dev/hdb1. Specify other partitions as needed.
To create a RAID array on /, there needs to be an intermediate step which you must take to boot off of the disk. To do this, you need and initrd. Install the needed packages to create an initrd, mount the initrd on loopback, and edit the linuxrc.
aptitde install initrd-tools mkdir /var/tmp/initrd mount -o loop /path/to/initrd.img /var/tmp/initrd
Edit the linuxrc to reflect your system devices and init process. RAID arrays should be assembled on init, even the root array, and then root should pivoted so that root is on the desired RAID array.
#!/bin/bash # : linuxrc,v 1.1 2004/07/16 21:07:36 credmon Exp $ if [ -e /proc/mounts ]; then : else /bin/mount -nt proc proc proc fi # fallback to creating array with less disks if some cannot be initialized ... mdadm --assemble --run --force /dev/md0 /dev/hda1 /dev/hdc1 ||\ mdadm --assemble --run --force /dev/md0 /dev/hda1 ||\ mdadm --assemble --run --force /dev/md0 /dev/hdc1 mdadm --assemble --run --force /dev/md1 /dev/hda6 /dev/hdc6 ||\ mdadm --assemble --run --force /dev/md1 /dev/hda6 ||\ mdadm --assemble --run --force /dev/md1 /dev/hdc6 mdadm --assemble --run --force /dev/md2 /dev/hda7 /dev/hdc7 ||\ mdadm --assemble --run --force /dev/md2 /dev/hda7 ||\ mdadm --assemble --run --force /dev/md2 /dev/hdc7 mdadm --assemble --run --force /dev/md3 /dev/hda8 /dev/hdc8 ||\ mdadm --assemble --run --force /dev/md3 /dev/hda8 ||\ mdadm --assemble --run --force /dev/md3 /dev/hdc8 mdadm --assemble --run --force /dev/md4 /dev/hda9 /dev/hdc9 ||\ mdadm --assemble --run --force /dev/md4 /dev/hda9 ||\ mdadm --assemble --run --force /dev/md4 /dev/hdc9 /bin/mount -n -o rw /dev/md0 /md0 cd /md0 /sbin/pivot_root . initrd cd / # need the chroot which is not on ramdisk exec sbin/chroot . sbin/init <dev/console >dev/console 2>&1Your can monitor the progress of your array from /proc/mdstat. Below is an example of an array that has just been created, and the disks are syncing.
Personalities : [raid1]
read_ahead 1024 sectors
md4 : active raid1 sdb9[1] sda9[0]
3317312 blocks [2/2] [UU]
[=>...................] resync = 7.5% (250604/3317312) finish=5.0min speed=10024K/sec
md3 : active raid1 sdb8[1] sda8[0]
28756224 blocks [2/2] [UU]
resync=DELAYED
md2 : active raid1 sdb7[1] sda7[0]
843264 blocks [2/2] [UU]
resync=DELAYED
md1 : active raid1 sdb6[1] sda6[0]
2048192 blocks [2/2] [UU]
resync=DELAYED
md0 : active raid1 sdb1[1] sda1[0]
160512 blocks [2/2] [UU]
unused devices: <none>
When the arrays are done syncing, you should unmount and stop the arrays. Also unmounting the initrd if you have not already done so. And then make the disks bootable.
umount /path/to/initrd losetup -d /dev/loop0 umount /dev/md0 mdadm --stop /dev/md0 mount /dev/hda1 /path/to grub-install --root-directory=/path/to /dev/hda umount /dev/hda1 mount /dev/hdb1 /path/to grub-install --root-directory=/path/to /dev/hdb umount /dev/hdb1
Serveral scripts were written so that one could setup a system to use software RAID from an FAI installation. You can download some examples here. They have been developed and used with a 2.4 based Linux Kernel, slight modification may be needed for 2.6.