Projekt

Allgemein

Profil

Howto mdadm » Historie » Version 4

Jeremias Keihsler, 20.05.2019 22:46

1 1 Jeremias Keihsler
h1. Howto mdadm
2
3 3 Jeremias Keihsler
have a look at: https://wiki.kobol.io/mdadm/
4 4 Jeremias Keihsler
and also at: http://davidlu1001.github.io/2014/04/14/Linux-quick-guide-for-software-RAID/
5 3 Jeremias Keihsler
6
or 
7
8 2 Jeremias Keihsler
<pre><code class="bash">
9
## var
10
md=/dev/md0
11
pd1=/dev/hdc1   ## phys-Disk (Partition)
12
pd2=/dev/hda3   ## phys-Disk
13
mnt=/mnt/tmp    ## mount-dir test
14
mdconf=/etc/mdadm/mdadm.conf
15
fstab=/etc/fstab
16
backupdir=/mnt/space ## f. backup $pd1
17
18
## check variables
19
ls -l $md $pd1 $pd2
20
## pd sollten annaehernd gleiche Groesse haben.
21
## wichtig:  pd1 <= pd2
22
fdisk -l | egrep "$pd1|$pd2"
23
df -k $backupdir
24
25
## backup
26
dd if=$pd1 | gzip -c > $backupdir/$pd1.dd.gz-`date +%y%m%d`
27
28
## create RAID1
29
mdadm --create $md --level=1 --raid-devices=2 $pd1 missing
30
cat /proc/mdstat
31
## add 2. pd
32
mdadm $md -a $pd2
33
34
## create/restore fs (optional)
35
# gunzip -c $backupdir/$pd1.dd.gz-`date +%y%m%d` | dd of=$md
36
# mkfs.ext3 $md
37
38
## check
39
cat /proc/mdstat
40
mdadm --detail --scan
41
mount -r $md $mnt
42
ls -l $mnt/
43
umount $mnt
44
dd if=$pd1 bs=1k count=2 | hexdump -C
45
dd if=$pd2 bs=1k count=2 | hexdump -C
46
47
## change konfig
48
ls -la $mdconf
49
cp -p $mdconf $mdconf.old
50
[ `grep DEVICE $mdconf | wc -l` -eq 0 ] && echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > $mdconf
51
#mdadm --detail --scan >> $mdconf
52
echo "ARRAY $md level=raid1 num-devices=2 devices=$pd1,$pd2" >> $mdconf
53
more $mdconf
54
55
## test stop/start
56
mdadm -S $md
57
cat /proc/mdstat
58
mdadm -A -s -a  ## /etc/init.d/mdadm-raid start
59
cat /proc/mdstat
60
61
## change konfig (final)
62
cp -p $fstab $fstab.old
63
cat $fstab.old | sed "s:$pd1:$md:" > $fstab
64
diff $fstab.old $fstab
65
</code></pre>
66
67
68 1 Jeremias Keihsler
h2. change harddrive
69
70
https://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID