Projekt

Allgemein

Profil

Howto mdadm » Historie » Revision 3

Revision 2 (Jeremias Keihsler, 20.05.2019 22:14) → Revision 3/4 (Jeremias Keihsler, 20.05.2019 22:20)

h1. Howto mdadm 

 have a look at: https://wiki.kobol.io/mdadm/ 

 or  

 <pre><code class="bash"> 
 ## var 
 md=/dev/md0 
 pd1=/dev/hdc1     ## phys-Disk (Partition) 
 pd2=/dev/hda3     ## phys-Disk 
 mnt=/mnt/tmp      ## mount-dir test 
 mdconf=/etc/mdadm/mdadm.conf 
 fstab=/etc/fstab 
 backupdir=/mnt/space ## f. backup $pd1 

 ## check variables 
 ls -l $md $pd1 $pd2 
 ## pd sollten annaehernd gleiche Groesse haben. 
 ## wichtig:    pd1 <= pd2 
 fdisk -l | egrep "$pd1|$pd2" 
 df -k $backupdir 

 ## backup 
 dd if=$pd1 | gzip -c > $backupdir/$pd1.dd.gz-`date +%y%m%d` 

 ## create RAID1 
 mdadm --create $md --level=1 --raid-devices=2 $pd1 missing 
 cat /proc/mdstat 
 ## add 2. pd 
 mdadm $md -a $pd2 

 ## create/restore fs (optional) 
 # gunzip -c $backupdir/$pd1.dd.gz-`date +%y%m%d` | dd of=$md 
 # mkfs.ext3 $md 

 ## check 
 cat /proc/mdstat 
 mdadm --detail --scan 
 mount -r $md $mnt 
 ls -l $mnt/ 
 umount $mnt 
 dd if=$pd1 bs=1k count=2 | hexdump -C 
 dd if=$pd2 bs=1k count=2 | hexdump -C 

 ## change konfig 
 ls -la $mdconf 
 cp -p $mdconf $mdconf.old 
 [ `grep DEVICE $mdconf | wc -l` -eq 0 ] && echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > $mdconf 
 #mdadm --detail --scan >> $mdconf 
 echo "ARRAY $md level=raid1 num-devices=2 devices=$pd1,$pd2" >> $mdconf 
 more $mdconf 

 ## test stop/start 
 mdadm -S $md 
 cat /proc/mdstat 
 mdadm -A -s -a    ## /etc/init.d/mdadm-raid start 
 cat /proc/mdstat 

 ## change konfig (final) 
 cp -p $fstab $fstab.old 
 cat $fstab.old | sed "s:$pd1:$md:" > $fstab 
 diff $fstab.old $fstab 
 </code></pre> 


 h2. change harddrive 

 https://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID