Debian Codegraph @

tests/ts/blkid/md-raid1-whole

raw
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2010 Karel Zak <[email protected]>
5 #
6 # This file is part of util-linux.
7 #
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18
19 TS_TOPDIR="${0%/*}/../.."
20 TS_DESC="MD raid1 (whole-disks)"
21
22 . "$TS_TOPDIR"/functions.sh
23 ts_init "$*"
24
25 ts_check_test_command "$TS_CMD_FDISK"
26 ts_check_test_command "$TS_CMD_BLKID"
27
28 ts_skip_nonroot
29 ts_check_losetup
30 ts_check_prog "mdadm"
31
32 # rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1
33 TS_KNOWN_FAIL="yes"
34
35 ts_log "Initialize devices"
36 IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}"
37
38 ts_device_init 50 ${IMGNAME}1.img
39 DEVICE1=$TS_LODEV
40
41 ts_device_init 50 ${IMGNAME}2.img
42 DEVICE2=$TS_LODEV
43
44 MD_DEVNAME=md8
45 MD_DEVICE=/dev/${MD_DEVNAME}
46
47 ts_lock "md"
48
49 mdadm -q -S ${MD_DEVICE} &> /dev/null
50 udevadm settle
51
52 ts_log "Create RAID device"
53 mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \
54 --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>> $TS_ERRLOG
55 udevadm settle
56
57 # create dos partition table
58 $TS_CMD_FDISK --noauto-pt ${MD_DEVICE} &>/dev/null <<EOF
59 o
60 w
61 q
62 EOF
63
64 ts_log "Create partitions on RAID device"
65 $TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
66 n
67 p
68 1
69
70 +10M
71 n
72 p
73 2
74
75 +10M
76 p
77 w
78 q
79 EOF
80
81 udevadm settle
82
83 ts_log "Probe first RAID member"
84 $TS_CMD_BLKID --probe --output udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT
85
86 ts_log "Probe second RAID member"
87 $TS_CMD_BLKID --probe --output udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT
88
89 ts_log "Stop RAID device"
90 mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG
91
92 udevadm settle
93 ts_unlock "md"
94
95 ts_log "Deinitialize devices"
96
97 ts_fdisk_clean
98 # seems that raid1 minimum I/O size has been changed in kernels >4.4.x and >4.8
99 sed -i 's@^\(I/O size (minimum/optimal): \)[1-9][0-9]*@\1<removed>@' $TS_OUTPUT
100 # remove generated UUIDs
101 sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT
102
103 ts_finalize