====== Working with software RAID ====== see also: * [[http://gentoo-wiki.com/HOWTO_Gentoo_Install_on_Software_RAID|Gentoo Howto on RAID]] * [[http://www.debian-administration.org/articles/424|growing ext3 partition on RAID1 without rebooting]] * [[:linux:lvm|LVM]] ===== Debian Woody + kernel 2.4 ===== Good article (based on the one that has already been available on old [[http://tnt.aufbix.org/old/linux/raid/|TNT site]]) on this topic is on URL: [[http://www.rot13.org/~dpavlin/md-raid1.html]] ===== Debian Sarge ===== TODO ===== RAID5 ===== **Creating a new one** mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1 **Adding spare to RAID5** mdadm --add /dev/md0 /dev/sdh1 **Fixing /etc/mdadm/mdadm.conf** echo "DEVICE partitions" > /etc/mdadm/mdadm.conf mdadm --detail --scan >> /etc/mdadm/mdadm.conf ===== SW RAID recover ===== **Copying the partition table from working HDD to new one** sfdisk -d /dev/sda > /tmp/partions sfdisk --force /dev/sdb < /tmp/partions **Adding partitions back to raid** mdadm --add /dev/md0 /dev/sdb1 mdadm --add /dev/md1 /dev/sdb2 mdadm --add /dev/md2 /dev/sdb3 mdadm --add /dev/md3 /dev/sdb4 **How to know which disk to remove?** The safest way (IMHO) to know which disk to remove is to write down the serial number of the disk, e.g. using smartctl, and then check the back side of each disk for the matching serial number. smartctl -i /dev/hda | grep Serial smartctl -i /dev/hde | grep Serial smartctl -i /dev/hdg | grep Serial ===== Forcing md array parity check ===== Force your md array to recheck parity from time to time, to assure data consistency. The following command will read every block on every disk in the md0 array: echo check > /sys/block/md0/md/sync_action ===== active (auto-read-only) ===== md0 : active (auto-read-only) raid1 sda1[0] sdb1[1] 1951744 blocks [2/2] [UU] to fix: # mdadm --readwrite /dev/md0 ===== Force the Linux kernel to re-read a partitiontable ===== blockdev --rereadpt /dev/device **Do NOT do this on a device where filesystems are mounted from.** ===== Boot system with GRUB from RAID1 ===== see also: [[http://www.texsoft.it/index.php?c=hardware&m=hw.storage.grubraid1&l=it|Very detailed instalation of fedora4]], [[http://ruslug.rutgers.edu/~mcgrof/grub-images/|GRUB Splash Image Howto]] [root@fedora4 ~]# grub GNU GRUB version 0.95 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.] grub> root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done. grub> root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done. grub> quit