Main /
RAID Setup
To set up RAID1 mirroring on an existing Linux system, I've done something like this in the past. It may need some modernisation - though maybe only because everyone uses grub and SATA drives now, and ext3 instead of ext2.
- Boot from a rescue CD or floppy that has mdadm and resize2fs.
umount /mnt/sysimage/ # Set up RAID devices and superblocks on hda mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hda9 missing mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/hda5 missing mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/hda6 missing mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/hda1 missing mdadm --create --verbose /dev/md4 --level=1 --raid-devices=2 /dev/hda7 missing # Fix summary information on disk. Don't abort on initial error. fsck -f /dev/md0 fsck -f /dev/md1 fsck -f /dev/md2 fsck -f /dev/md3 fsck -f /dev/md4 # Resize the partitions to account for RAID superblock size. resize2fs /dev/md0 resize2fs /dev/md1 resize2fs /dev/md2 resize2fs /dev/md3 resize2fs /dev/md4 mount /dev/md0 /mnt/sysimage/ vi /mnt/sysimage/etc/fstab
- Using fdisk, change the partition types on both drives to RAID autodetect.
- Edit the fstab to use the mdx nodes instead of hdax ones
reboot
- Once the system comes back up:
# Hot-add the hdc partitions to the mirror sets mdadm --manage -a /dev/md0 /dev/hdc9 mdadm --manage -a /dev/md1 /dev/hdc5 mdadm --manage -a /dev/md2 /dev/hdc6 mdadm --manage -a /dev/md3 /dev/hdc1 mdadm --manage -a /dev/md4 /dev/hdc7 # Create an mdadm.conf file (not really necessary, but prevents some # start-up drive scanning rubbish from appearing on the console) mdadm --detail --scan > /etc/mdadm.conf
- Edit the mdadm.conf to include a DEVICE line
- Change lilo to use a root of md0 instead of hda9
- Done!
