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