Software RAID
From Wiki
Contents |
RAIDing an already running system
This is a nice concise overview.
Create a RAID
Create two identically sized partitions and set the type to software raid (type fb):
Just in case, zero the superblock, then create the RAID:
# mdadm --misc --zero-superblock /dev/sdb1 /dev/sdc1 # mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1
If there is a device that needs to be added later, use "missing" in place of the device name:
# mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 missing /dev/sdc1
In the case that grub 0.9 (grub legacy) is to be used, it is necessary to specify a metadata version of 0.9. This does not introduce any limitations for the majority of setups:
# mdadm --create --verbose --metadata=0.90 /dev/md0 --level=raid1 --raid-devices=2 missing /dev/sdc1
Check that the array was created:
# mdadm --examine --scan ARRAY /dev/md0 level=raid1 num-devices=2 UUID=802307d7:2fb8c54d:c7f19992:fb8f0d8b
Paste the resulting "ARRAY" line into the "# definitions of existing MD arrays" section of /etc/mdadm/mdadm.conf and restart mdadm.
Destroy a RAID
unmount !!! and Stop the raid:
# umount /mnt/whatever # mdadm --manage --stop /dev/md0
Zero the superblock on the appropriate partitions:
# mdadm --misc --zero-superblock /dev/sdb1 /dev/sdc1
Then, delete the appropriate "ARRAY" line from /etc/mdadm/mdadm.conf and restart mdadm.
mdadm should no longer report the device:
# mdadm --examine --scan
It's gone titsup
# mdadm --detail /dev/md0
# mdadm /dev/md0 --add /dev/sdb1
Annoyance
The boot code only gets installed onto one of the disks in the array (hd0,0). This means it is necessary to manually install grub each time the kernel is updated (as far as I can tell, anyway):
# grub grub>
grub> root (hd0,0) root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub>
grub> setup (hd0) setup (hd0) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded. succeeded Running "install /grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/grub/stage2 /grub/menu.lst"... succeeded Done. grub>
grub> root (hd1,0) root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub>
grub> setup (hd1) setup (hd1) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd1)"... 17 sectors are embedded. succeeded Running "install /grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/grub/stage2 /grub/menu.lst"... succeeded Done. grub>
grub> quit quit
