]> git.ipfire.org Git - thirdparty/mdadm.git/blob - tests/10ddf-create
Create.c: fix uclibc build
[thirdparty/mdadm.git] / tests / 10ddf-create
1 #
2 # Test basic DDF functionality.
3 #
4 # Create a container with 5 drives
5 # create a small raid0 across them all,
6 # then a small raid10 using 4 drives, then a 2disk raid1
7 # and a 3disk raid5 using the remaining space
8 #
9 # add some data, tear down the array, reassemble
10 # and make sure it is still there.
11 set -e
12 . tests/env-ddf-template
13 sda=$(get_rootdev) || exit 1
14
15 mdadm -CR /dev/md/ddf0 -e ddf -n 5 $dev8 $dev9 $dev10 $dev11 $dev12
16 mdadm -CR r5 -l5 -n5 /dev/md/ddf0 -z 5000
17 if mdadm -CR r5 -l1 -n2 /dev/md/ddf0 -z 5000
18 then echo >&2 create with same name should fail ; exit 1
19 fi
20 mdadm -CR r10 -l10 -n4 -pn2 /dev/md/ddf0 -z 5000
21 mdadm -CR r1 -l1 -n2 /dev/md/ddf0
22 mdadm -CR r0 -l0 -n3 /dev/md/ddf0
23 testdev /dev/md/r5 4 5000 512
24 testdev /dev/md/r10 2 5000 512
25 # r0/r10 will use 4608 due to chunk size, so that leaves 23552 for the rest
26 testdev /dev/md/r1 1 23552 64
27 testdev /dev/md/r0 3 23552 512
28 dd if=$sda of=/dev/md/r0 || true
29 dd if=$sda of=/dev/md/r10 || true
30 dd if=$sda of=/dev/md/r1 || true
31 dd if=$sda of=/dev/md/r5 || true
32
33 s0=`sha1sum /dev/md/r0`
34 s10=`sha1sum /dev/md/r10`
35 s1=`sha1sum /dev/md/r1`
36 s5=`sha1sum /dev/md/r5`
37
38
39 mdadm -Ss
40 mdadm -A /dev/md/ddf0 $dev8 $dev9 $dev10 $dev11 $dev12
41 mdadm -I /dev/md/ddf0
42
43 udevadm settle
44 s0a=`sha1sum /dev/md/r0`
45 s10a=`sha1sum /dev/md/r10`
46 s1a=`sha1sum /dev/md/r1`
47 s5a=`sha1sum /dev/md/r5`
48
49 if [ "$s0" != "$s0a" ]; then
50 echo r0 did not match ; exit 1;
51 fi
52 if [ "$s10" != "$s10a" ]; then
53 echo r10 did not match ; exit 1;
54 fi
55 if [ "$s1" != "$s1a" ]; then
56 echo r1 did not match ; exit 1;
57 fi
58 if [ "$s5" != "$s5a" ]; then
59 echo r5 did not match ; exit 1;
60 fi
61
62 # failure status just means it has completed already, so ignore it.
63 mdadm --wait /dev/md/r1 || true
64 mdadm --wait /dev/md/r10 || true
65 mdadm --wait /dev/md/r5 || true
66
67 mdadm -Dbs > /var/tmp/mdadm.conf
68
69 mdadm -Ss
70
71 # Now try to assemble using mdadm.conf
72 mdadm -Asc /var/tmp/mdadm.conf
73 check nosync # This failed once. The raid5 was resyncing.
74 udevadm settle
75 mdadm -Dbs | sort > /tmp/mdadm.conf
76 sort /var/tmp/mdadm.conf | diff /tmp/mdadm.conf -
77 mdadm -Ss
78
79 # and now assemble fully incrementally.
80 for i in $dev8 $dev9 $dev10 $dev11 $dev12
81 do
82 mdadm -I $i -c /var/tmp/mdadm.conf
83 done
84 check nosync
85 udevadm settle
86 mdadm -Dbs | sort > /tmp/mdadm.conf
87 sort /var/tmp/mdadm.conf | diff /tmp/mdadm.conf -
88 mdadm -Ss
89 rm /tmp/mdadm.conf /var/tmp/mdadm.conf