Notes on RAID for Ubuntu
Shorthand notes on how to convert a new Ubuntu system to RAID 1
Install Ubuntu Server
System has 12GB of RAM
System has two 250GB drives (actually a 320 and a 250, I ignore the extra space for now)
During installation create 6 partitions on each drive, so that the system can be converted to RAID 1 (mirrored)
1 1GB /boot wont be raid, so we can boot! 2 10GB /raidroot where the system will be eventually 3 10GB / initial install location 4 EXT 5 24GB SWAP won't be raided, so we will have 48GB of swap 6 200GB /raidvar will be raided /var partition
Partitions are far bigger than they need to be but the data on this system will live on an NFS server and on another RAID array to be installed later. Making the boot partitions 1 GB means in a pinch an entire copy of Linux can be installed there.
Do the installation. After it's done install the package to manage raid
apt-get install mdadm
Unmount the extra filesystems and remove their entries from /etc/fstab.
Create RAID filesystems
See http://www.linuxfoundation.org/collaborate/workgroups/linux-raid
First convert the second and sixth partitions to RAID1
mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda2 /dev/sdb2 mdadm --monitor /dev/md0
mdadm --create --verbose /dev/md2 --level=mirror --raid-devices=2 /dev/sda6 /dev/sdb6 mdadm --monitor /dev/md2
Make filesystems on the new RAID devices mke2fs -j /dev/md0 mkreiserfs /dev/md2
Create mount points for testing. I use /raidroot and /raidvar. Add temporary entries to /etc/fstab, Use the "blkid" command to find a UUID for a filesystem.
Check /proc/mdstat to see if RAID reconstruction is complete. Then reboot to single user mode. The reboot is mostly just to confirm things are working with RAID and the kernel so far.
Copy. I prefer to do this from a rescue disk; adjust command accordingly
mkdir /tmp/root mount /dev/sd3 /tmp/root mkdir /tmp/raidroot mount /dev/md0 /tmp/raidroot cd /tmp/root tar cvf - . | (cd /tmp/raidroot; tar xpf -) cd /tmp/raidroot mkdir /tmp/raidvar mount /dev/md2 /tmp/raidvar cd /tmp/root/var tar cvf - . | (cd /tmp/raidvar; tar xpf -)
THere will be redundant copies of the /var partition left behind on the root partition but in practice it's not much space and comes in pretty handy if you have to boot into single user mode with the /var partition unmounted.
Edit the new /etc/fstab in /dev/md0. to make it use the newly copied files.
cd /tmp/raidroot vi fstab
Edit the grub stuff to add the capability to boot using the new root partition. you probably can't boot into it yet. Boot into the old /dev/sda3 root and do an update-initramfs. Then try to boot into /dev/md0