Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / t-pvcreate-operation.sh
blob72560c93bd73fb5fd11dd8e677dfd3a6ffadb7f4
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
11 . ./test-utils.sh
13 aux prepare_devs 4
15 for mdatype in 1 2
17 # pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330)
18 test ! -d $G_root_/mnt && mkdir $G_root_/mnt
19 if mke2fs $dev1; then
20 mount $dev1 $G_root_/mnt
21 not pvcreate -M$mdatype $dev1 2>err
22 grep "Can't open $dev1 exclusively. Mounted filesystem?" err
23 umount $dev1
26 # pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216)
27 pvcreate -M$mdatype $dev1
28 pvcreate -M$mdatype $dev1
29 pvremove -f $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
36 vgremove -f $vg1
37 pvremove -f $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
47 vgremove -f $vg1
48 pvremove -f $dev2
49 pvremove -f $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'
60 done
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
66 not pvcreate $dev1
67 vgremove -f $vg1
68 pvremove -f $dev2
69 pvremove -f $dev1
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
75 pvcreate -ff -y $dev1
76 vgreduce --removemissing $vg1
77 vgremove -ff $vg1
78 pvremove -f $dev2
79 pvremove -f $dev1
81 for i in 0 1 2 3
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;
86 pvremove -f $dev1
87 done
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
95 bogusuuid=fred
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
114 mkswap $dev1
115 blkid -c /dev/null $dev1 | grep "swap"
116 pvcreate -f $dev1
117 blkid -c /dev/null $dev1 | not grep "swap"