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 $TESTDIR/mnt && mkdir $TESTDIR/mnt
20
mount $dev1 $TESTDIR/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 LABELONE >/dev/null
89
# pvcreate (lvm2) fails writing LVM label at sector 4
90
not pvcreate --labelsector 4 $dev1
92
backupfile=$PREFIX.mybackupfile
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 --norestorefile --uuid $bogusuuid $dev1
100
# pvcreate rejects uuid option without restorefile
101
not pvcreate --uuid $uuid1 $dev1
103
# pvcreate rejects uuid already in use
104
pvcreate --norestorefile --uuid $uuid1 $dev1
105
not pvcreate --norestorefile --uuid $uuid1 $dev2
107
# pvcreate rejects non-existent file given with restorefile
108
not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1
110
# pvcreate rejects restorefile with uuid not found in file
111
pvcreate --norestorefile --uuid $uuid1 $dev1
112
vgcfgbackup -f $backupfile
113
not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2
115
# pvcreate wipes swap signature when forced
116
dd if=/dev/zero of=$dev1 bs=1024 count=64
118
blkid -c /dev/null $dev1 | grep "swap"
120
# blkid cannot make up its mind whether not finding anything it knows is a failure or not
121
(blkid -c /dev/null $dev1 || true) | not grep "swap"