Projekt

Allgemein

Profil

Howto mdadm » Historie » Version 3

Jeremias Keihsler, 20.05.2019 22:20

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