2 # verify that new kernel is informed about partitions on mdraid devices
4 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
22 require_scsi_debug_module_
25 # create memory-backed device
26 scsi_debug_setup_ dev_size_mb=10 > dev-name ||
27 skip_ 'failed to create scsi_debug device'
28 scsi_dev=$(cat dev-name)
30 # Arbitrary number, not likely to be used already
34 test -b $md_dev && skip_ "$md_dev already exists"
36 # Use gpt and create two partitions on the device.
37 parted -s "$scsi_dev" mklabel gpt \
38 mkpart p1 ext2 1M 4M \
39 mkpart p2 ext2 5M 8M > out 2>&1 || fail=1
40 compare /dev/null out || fail=1
44 mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev"
47 # create mdraid on top of both partitions
48 mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
50 # create gpt and two partitions on the raid device
51 parted -s $md_dev mklabel gpt \
52 mkpart r1 ext2 1M 2M \
53 mkpart r2 ext2 2M 3M > out 2>&1 || fail=1
54 compare /dev/null out || fail=1
56 # Verify that kernel has been informed about the second device.
57 grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; }
59 # Remove partitions from the raid device.
60 parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
61 compare /dev/null out || fail=1
63 # Verify that kernel has been informed about those removals.
64 grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; }