General Requirements
The obvious essential requirement for running RAID 1 is to have at least two disks, preferably of equal size. If using IDE (also known as PATA) drives, then place the disks on seperate controllers, e.g. as hda and hdc.
The second requirement is to build the kernel with support for RAID 1. The same logic as with SCSI drives are applicable in that the code must be built-in and not compiled as modules.
Convert single disk to RAID 1 array
MAKE A BACKUP OF ALL VALUABLE FILES BEFORE STARTING THIS PROCEDURE!
gentoo ~ # init 1
Install the mdadm program to manage the disks:
gentoo ~ # emerge mdadm
gentoo ~ # rc-update add mdadm boot
gentoo ~ # fdisk -l /dev/hda
Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xfe3d7ec6 Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 271 2072385 82 Linux swap / Solaris /dev/hda3 272 9964 77859022+ 83 Linux
gentoo ~ # fdisk /dev/hdc
gentoo ~ # fdisk -l /dev/hdc
Disk /dev/hdc: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/hdc1 * 1 13 104391 fd Linux raid autodetect /dev/hdc2 14 271 2072385 fd Linux raid autodetect /dev/hdc3 272 9964 77859022+ fd Linux raid autodetect /dev/hdc4 9965 14593 37182442+ 83 Linux
gentoo ~ # mdadm --create --verbose /dev/md1 --level=1 --raid-disks=2 missing /dev/hdc1
gentoo ~ # mdadm --create --verbose /dev/md2 --level=1 --raid-disks=2 missing /dev/hdc2
gentoo ~ # mdadm --create --verbose /dev/md3 --level=1 --raid-disks=2 missing /dev/hdc3
gentoo ~ # cat /proc/mdstat
gentoo ~ # mdadm --detail --scan >> /etc/mdadm.conf
gentoo ~ # mke2fs /dev/md1
gentoo ~ # mkswap /dev/md2
gentoo ~ # mke2fs -j /dev/md3
gentoo ~ # mkdir /mnt/md1
gentoo ~ # mount /dev/md1 /mnt/md1
gentoo ~ # cp -avx /boot/. /mnt/md1
gentoo ~ # mkdir /mnt/md3
gentoo ~ # mount /dev/md3 /mnt/md3
gentoo ~ # cp -avx / /mnt/md3
gentoo ~ # nano -w /mnt/md1/grub/menu.lst
default 0 timeout 10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title=Gentoo Linux 2.6.30-r4 root (hd0,0) kernel /boot/kernel-genkernel-x86-2.6.30-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hda3 udev initrd /boot/initramfs-genkernel-x86-2.6.30-gentoo-r4 title=Gentoo Linux 2.6.30-r4 (RAID) root (hd0,0) kernel /boot/kernel-genkernel-x86-2.6.30-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/md3 udev initrd /boot/initramfs-genkernel-x86-2.6.30-gentoo-r4
gentoo ~ # nano -w /mnt/md3/etc/fstab
# <mountpoint> <type> <opts> <dump/pass> /dev/md1 /boot ext2 noatime 1 2 /dev/md2 none swap sw 0 0 /dev/md3 / ext3 noatime 0 1 # /dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0 # /dev/fd0 /mnt/floppy auto noauto 0 0 proc /proc proc defaults 0 0 shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
gentoo ~ # grub --no-floppy
grub> find /boot/grub/stage1
(hd0,0) (hd1,0)
grub> device (hd0) /dev/hdc
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
Two “files” were not copied and are essential for the boot process to succeed. Create them with:
gentoo ~ # mknod /mnt/md3/dev/console c 5 1
gentoo ~ # mknod /mnt/md3/dev/null c 1 3
gentoo ~ # reboot
gentoo ~ # mount
/dev/md3 on / type ext3 (rw,noatime) /dev/md1 on /boot type ext2 (rw,noatime)
gentoo ~ # swapon -s
Filename Type Size Used Priority /dev/md2 partition 2072312 0 -1
gentoo ~ # fdisk /dev/hda
gentoo ~ # fdisk -l /dev/hda
Disk /dev/hda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xfe3d7ec6 Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 fd Linux raid autodetect /dev/hda2 14 271 2072385 fd Linux raid autodetect /dev/hda3 272 9964 77859022+ fd Linux raid autodetect
gentoo ~ # mdadm /dev/md1 --add /dev/hda1
gentoo ~ # mdadm /dev/md2 --add /dev/hda2
gentoo ~ # mdadm /dev/md3 --add /dev/hda3
gentoo ~ # watch -n1 'cat /proc/mdstat'
gentoo ~ # grub --no-floppy
grub> find /boot/grub/stage1
(hd0,0) (hd1,0)
grub> device (hd0) /dev/hda
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
gentoo ~ # nano -w /boot/grub/menu.lst
default 0 timeout 10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title=Gentoo Linux 2.6.30-r4 root (hd0,0) kernel /boot/kernel-genkernel-x86-2.6.30-gentoo-r4 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/md3 udev initrd /boot/initramfs-genkernel-x86-2.6.30-gentoo-r4
