Debian Codegraph @

tests/ts/blkid/md-raid0-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 raid0 (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 mdadm -q -S ${MD_DEVICE} &> /dev/null
49
50 ts_log "Create RAID device"
51 mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=0 \
52 --raid-devices=2 ${DEVICE1} ${DEVICE2} >> $TS_OUTPUT 2>> $TS_ERRLOG
53
54 # create dos partition table
55 $TS_CMD_FDISK --noauto-pt ${MD_DEVICE} &>/dev/null <<EOF
56 o
57 w
58 q
59 EOF
60
61 ts_log "Create partitions on RAID device"
62 $TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
63 n
64 p
65 1
66
67 +10M
68 n
69 p
70 2
71
72
73 p
74 w
75 q
76 EOF
77
78 udevadm settle
79
80 ts_log "Probe first RAID member"
81 $TS_CMD_BLKID --probe --output udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT
82
83 ts_log "Probe second RAID member"
84 $TS_CMD_BLKID --probe --output udev $DEVICE1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT
85
86 ts_log "Stop RAID device"
87 mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG
88
89 udevadm settle
90 ts_unlock "md"
91
92 ts_log "Deinitialize devices"
93
94 ts_fdisk_clean $MD_DEVICE
95
96 # remove generated UUIDs
97 sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT
98
99 ts_finalize