1 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
3 # This copyrighted material is made available to anyone wishing to use,
4 # modify, copy, or redistribute it subject to the terms and conditions
5 # of the GNU General Public License v.2.
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software Foundation,
9 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330)
18 test ! -d $G_root_/mnt
&& mkdir
$G_root_/mnt
20 mount
$dev1 $G_root_/mnt
21 not pvcreate
-M$mdatype $dev1 2>err
22 grep "Can't open $dev1 exclusively. Mounted filesystem?" err
26 # pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216)
27 pvcreate
-M$mdatype $dev1
28 pvcreate
-M$mdatype $dev1
31 # pvcreate (lvm$mdatype) fails when PV belongs to VG" \
32 pvcreate
-M$mdatype $dev1
33 vgcreate
-M$mdatype $vg1 $dev1
34 not pvcreate
-M$mdatype $dev1
39 # pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG
40 pvcreate
-M$mdatype $dev1
41 pvcreate
-M$mdatype $dev2
42 vgcreate
-M$mdatype $vg1 $dev1
44 # pvcreate a second time on $dev2 and $dev1
45 not pvcreate
-M$mdatype $dev2 $dev1
51 # NOTE: Force pvcreate after test completion to ensure clean device
52 #test_expect_success \
53 # "pvcreate (lvm$mdatype) fails on md component device" \
54 # 'mdadm -C -l raid0 -n 2 /dev/md0 $dev1 $dev2 &&
55 # pvcreate -M$mdatype $dev1;
56 # status=$?; echo status=$status; test $status != 0 &&
57 # mdadm --stop /dev/md0 &&
58 # pvcreate -ff -y -M$mdatype $dev1 $dev2 &&
59 # pvremove -f $dev1 $dev2'
62 # pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG
63 pvcreate
--metadatacopies 0 $dev1
64 pvcreate
--metadatacopies 1 $dev2
65 vgcreate
$vg1 $dev1 $dev2
71 # pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG
72 pvcreate
--metadatacopies 0 $dev1
73 pvcreate
--metadatacopies 1 $dev2
74 vgcreate
$vg1 $dev1 $dev2
76 vgreduce
--removemissing $vg1
83 # pvcreate (lvm2) succeeds writing LVM label at sector $i
84 pvcreate
--labelsector $i $dev1
85 dd if=$dev1 bs
=512 skip
=$i count
=1 2>/dev
/null |
strings |
grep -q LABELONE
;
89 # pvcreate (lvm2) fails writing LVM label at sector 4
90 not pvcreate
--labelsector 4 $dev1
92 backupfile
=mybackupfile-$
(this_test_
)
93 uuid1
=freddy-fred-fred-fred-fred-fred-freddy
94 uuid2
=freddy-fred-fred-fred-fred-fred-fredie
97 # pvcreate rejects uuid option with less than 32 characters
98 not pvcreate
--uuid $bogusuuid $dev1
100 # pvcreate rejects uuid already in use
101 pvcreate
--uuid $uuid1 $dev1
102 not pvcreate
--uuid $uuid1 $dev2
104 # pvcreate rejects non-existent file given with restorefile
105 not pvcreate
--uuid $uuid1 --restorefile $backupfile $dev1
107 # pvcreate rejects restorefile with uuid not found in file
108 pvcreate
--uuid $uuid1 $dev1
109 vgcfgbackup
-f $backupfile
110 not pvcreate
--uuid $uuid2 --restorefile $backupfile $dev2
112 # pvcreate wipes swap signature when forced
113 dd if=/dev
/zero of
=$dev1 bs
=1024 count
=64
115 blkid
-c /dev
/null
$dev1 |
grep "swap"
117 blkid
-c /dev
/null
$dev1 | not
grep "swap"