Welcome to http://www.marssoft.de/
 
Thursday, 16th July 2020 18:19:04 (GMT+1) 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
guides:debianraid [2006/03/27 01:05]
mario
guides:debianraid [2014/04/02 22:39] (current)
Line 108: Line 108:
 </​code>​ </​code>​
  
-====(A) Using raidtools2setting ​up the Raid====+====OldUsing raidtools to set up the Raid====
  
-For my first runI used the raidtools to set up the raid, other people prefer to use mdadm directly. If you prefer ​the newer and little shorter guide to mdadm, jump **[[#​(B)_Using_mdadm:​_setting_up_the_Raid|to ​the mdadm section ​(B) below]]**.+If you likeyou can use the outdated ​[[raidtools-setup]] and then continue below the next section.
  
-For the raidtools, you need to edit '/​etc/​raidtab'​ to reflect your wanted configuration:​ 
  
-<​code>​ +====New: Using mdadm: setting up the Raid====
-# md0: raid 1: /boot +
-raiddev /dev/md0 +
- raid-level 1 +
- nr-raid-disks 2 +
- nr-spare-disks 0 +
- persistent-superblock 1 +
- device /​dev/​sda1 +
- raid-disk 0 +
- device /​dev/​sdb1 +
- raid-disk 1 +
- +
-# md1: raid 1: / +
-raiddev /dev/md1 +
- raid-level 1 +
- nr-raid-disks 2 +
- nr-spare-disks 0 +
- persistent-superblock 1 +
- device /​dev/​sda2 +
- raid-disk 0 +
- device /​dev/​sdb2 +
- raid-disk 1 +
- +
-# md2: raid 1: /usr +
-raiddev /dev/md2 +
- raid-level 1 +
- nr-raid-disks 2 +
- nr-spare-disks 0 +
- persistent-superblock 1 +
- device /​dev/​sda5 +
- raid-disk 0 +
- device /​dev/​sdb5 +
- raid-disk 1 +
- +
-# md3: raid 1: /var +
-raiddev /dev/md3 +
- raid-level 1 +
- nr-raid-disks 2 +
- nr-spare-disks 0 +
- persistent-superblock 1 +
- device /​dev/​sda6 +
- raid-disk 0 +
- device /​dev/​sdb6 +
- raid-disk 1 +
- +
-# md4: raid 1: /home +
-raiddev /dev/md4 +
- raid-level 1 +
- nr-raid-disks 2 +
- nr-spare-disks 0 +
- persistent-superblock 1 +
- device /​dev/​sda7 +
- raid-disk 0 +
- device /​dev/​sdb7 +
- raid-disk 1 +
- +
-# md5: raid 0: /scratch +
-raiddev /dev/md5 +
- raid-level 0 +
- nr-raid-disks 2 +
- chunk-size 4 +
- persistent-superblock 1 +
- device /​dev/​sda8 +
- raid-disk 0 +
- device /​dev/​sdb8 +
- raid-disk 1 +
- +
-# md6: raid 0: /tmp +
-raiddev /dev/md6 +
- raid-level 0 +
- nr-raid-disks 2 +
- chunk-size 4 +
- persistent-superblock 1 +
- device /​dev/​sda9 +
- raid-disk 0 +
- device /​dev/​sdb9 +
- raid-disk 1 +
-</​code>​ +
- +
-This handy shell (bash) script will create the raid for you, including the needed devices and the filesystem. Set FS to the filesystem of your choice (FS=ext3, FS=reiserfs, FS=xfs), and watch out for needed options. +
- +
-<​code>​ +
-FS="​reiserfs -q" +
-for I in 0 1 2 3 4 5 6 +
-do +
- if [ ! -e /dev/md$I ]; then mknod /dev/md$I b 9 $I; fi +
- mkraid --really-force /dev/md$I +
-  +
- T=`cat /​proc/​mdstat | grep resync` +
- while [ "​$T"​ != ""​ ] +
- do +
- echo "​$T"​ +
- sleep 10 +
- T=`cat /​proc/​mdstat | grep resync` +
- done +
- mkfs.$FS /dev/md$I +
-done +
-</​code>​ +
- +
-====(B) ​Using mdadm: setting up the Raid====+
  
 Well, mdadm is newer and seems to be more powerful than the old raidtools, so you might prefer this section. To have a little more comfort and automation, I made the following small script to create and set up the whole raid. Set FS to the filesystem of your choice (FS=ext3, FS=reiserfs,​ FS=xfs), and watch out for needed options: Well, mdadm is newer and seems to be more powerful than the old raidtools, so you might prefer this section. To have a little more comfort and automation, I made the following small script to create and set up the whole raid. Set FS to the filesystem of your choice (FS=ext3, FS=reiserfs,​ FS=xfs), and watch out for needed options:
Line 270: Line 170:
    ​devices=/​dev/​sda9,/​dev/​sdb9    ​devices=/​dev/​sda9,/​dev/​sdb9
 </​code>​ </​code>​
 +
 +====If raid-disks fail====
 +
 +Sometimes after power-outage or forced reboot the raid disks may be out of sync. mdadm then rejects one of the disks as outdated, the result will look somehow like md1, md2 or md3 below:
 +
 +<​code>​
 +root(strassen) ~> cat /​proc/​mdstat
 +Personalities : [raid0] [raid1]
 +md3 : active raid1 sda8[0]
 +      60556864 blocks [2/1] [U_]
 +
 +md2 : active raid1 sda7[0]
 +      15631104 blocks [2/1] [U_]
 +
 +md1 : active raid1 sda6[0]
 +      29302464 blocks [2/1] [U_]
 +
 +md0 : active raid1 sda1[0] sdc1[1]
 +      505920 blocks [2/2] [UU]
 +</​code>​
 +
 +The solution is to re-sync the disks. This is done by first removing the faulty disk, and then re-adding it. The error message below can be ignored, it just states that mdadm already removed partition sdc6:
 +
 +<​code>​
 +root(strassen) ~> mdadm /dev/md1 --fail /dev/sdc6 --remove /dev/sdc6
 +mdadm: set device faulty failed for /​dev/​sdc6: ​ No such device
 +root(strassen) ~> mdadm /dev/md1 --add /dev/sdc6
 +mdadm: re-added /dev/sdc6
 +</​code>​
 +
 +====Having fun: some Raid-Tests====
 +
 +So you want to see if everything is working as expected? You can make mdadm think the raid is faulty, and see how it reacts to that. Obviously it makes sense to set your email address in mdadm.conf:
 +
 +<​code>​
 +root(strassen) ~> cat /​etc/​mdadm/​mdadm.conf|grep MAILADDR
 +MAILADDR user@domain.org
 +</​code>​
 +
 +Now you can set one of the partitions or disks as faulty:
 +
 +<​code>​
 +root(strassen) ~> mdadm /dev/md1 --manage --set-faulty /dev/sdc6
 +# now you should get an email saying "A Fail event had been detected on md device /​dev/​md1."​
 +root(strassen) ~> cat /​proc/​mdstat|grep -A1 md1
 +md1 : active raid1 sdc6[2](F) sda6[0]
 +      29302464 blocks [2/1] [U_]
 +</​code>​
 +
 +Finally remove the faulty disk and re-add it again (as in the section about raid-recovery above):
 +
 +<​code>​
 +root(strassen) ~> mdadm /dev/md1 --manage --remove /dev/sdc6
 +mdadm: hot removed /dev/sdc6
 +root(strassen) ~> mdadm /dev/md1 --add /dev/sdc6
 +mdadm: re-added /dev/sdc6
 +</​code>​
 +
 +To re-add a stopped array (maybe after re-partitioning),​ use mdadm --assemble:
 +
 +<​code>​
 +root(strassen) ~> mdadm --assemble /dev/md9 /​dev/​sd[ab]14
 +mdadm: /dev/md9 has been started with 2 drives.
 +</​code>​
 +
  
 ====Going further: installing a new Linux==== ====Going further: installing a new Linux====
Line 537: Line 502:
 mount -o bind /sys $NEWLIN/sys mount -o bind /sys $NEWLIN/sys
 </​code>​ </​code>​
 +
guides/debianraid.1143414333.txt.gz · Last modified: 2014/04/02 22:39 (external edit)