Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / t-vgsplit-usage.sh
blobade39d8337e86d2211eebbccf1716e2b705690f9
1 #!/bin/sh
2 # Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12 # Test vgsplit command options for validity
14 . ./test-utils.sh
16 aux prepare_devs 5
18 for mdatype in 1 2
21 pvcreate -M$mdatype $devs
23 # ensure name order does not matter
24 # NOTE: if we're using lvm1, we must use -M on vgsplit
25 vgcreate -M$mdatype $vg1 $devs
26 vgsplit -M$mdatype $vg1 $vg2 $dev1
27 vgremove $vg1
28 vgremove $vg2
29 vgcreate -M$mdatype $vg2 $devs
30 vgsplit -M$mdatype $vg2 $vg1 $dev1
31 vgremove $vg1
32 vgremove $vg2
34 # vgsplit accepts new vg as destination of split
35 # lvm1 -- bz244792
36 vgcreate -M$mdatype $vg1 $devs
37 vgsplit $vg1 $vg2 $dev1 1>err
38 grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err
39 vgremove $vg1
40 vgremove $vg2
42 # vgsplit accepts existing vg as destination of split
43 vgcreate -M$mdatype $vg1 $dev1 $dev2
44 vgcreate -M$mdatype $vg2 $dev3 $dev4
45 vgsplit $vg1 $vg2 $dev1 1>err
46 grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err
47 vgremove $vg1
48 vgremove $vg2
50 # vgsplit accepts --maxphysicalvolumes 128 on new VG
51 vgcreate -M$mdatype $vg1 $dev1 $dev2
52 vgsplit --maxphysicalvolumes 128 $vg1 $vg2 $dev1
53 check_vg_field_ $vg2 max_pv 128
54 vgremove $vg1
55 vgremove $vg2
57 # vgsplit accepts --maxlogicalvolumes 128 on new VG
58 vgcreate -M$mdatype $vg1 $dev1 $dev2
59 vgsplit --maxlogicalvolumes 128 $vg1 $vg2 $dev1
60 check_vg_field_ $vg2 max_lv 128
61 vgremove $vg1
62 vgremove $vg2
64 # vgsplit rejects split because max_pv of destination would be exceeded
65 vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $dev1 $dev2
66 vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $dev3 $dev4
67 not vgsplit $vg1 $vg2 $dev1 2>err;
68 grep "^ Maximum number of physical volumes (2) exceeded" err
69 vgremove $vg2
70 vgremove $vg1
72 # vgsplit rejects split because maxphysicalvolumes given with existing vg
73 vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $dev1 $dev2
74 vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $dev3 $dev4
75 not vgsplit --maxphysicalvolumes 2 $vg1 $vg2 $dev1 2>err;
76 grep "^ Volume group \"$vg2\" exists, but new VG option specified" err
77 vgremove $vg2
78 vgremove $vg1
80 # vgsplit rejects split because maxlogicalvolumes given with existing vg
81 vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $dev1 $dev2
82 vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $dev3 $dev4
83 not vgsplit --maxlogicalvolumes 2 $vg1 $vg2 $dev1 2>err
84 grep "^ Volume group \"$vg2\" exists, but new VG option specified" err
85 vgremove $vg2
86 vgremove $vg1
88 # vgsplit rejects split because alloc given with existing vg
89 vgcreate -M$mdatype --alloc cling $vg1 $dev1 $dev2
90 vgcreate -M$mdatype --alloc cling $vg2 $dev3 $dev4
91 not vgsplit --alloc cling $vg1 $vg2 $dev1 2>err;
92 grep "^ Volume group \"$vg2\" exists, but new VG option specified" err
93 vgremove $vg2
94 vgremove $vg1
96 # vgsplit rejects split because clustered given with existing vg
97 vgcreate -M$mdatype --clustered n $vg1 $dev1 $dev2
98 vgcreate -M$mdatype --clustered n $vg2 $dev3 $dev4
99 not vgsplit --clustered n $vg1 $vg2 $dev1 2>err
100 grep "^ Volume group \"$vg2\" exists, but new VG option specified" err
101 vgremove $vg2
102 vgremove $vg1
104 # vgsplit rejects vg with active lv
105 pvcreate -M$mdatype -ff $dev3 $dev4
106 vgcreate -M$mdatype $vg1 $dev1 $dev2
107 vgcreate -M$mdatype $vg2 $dev3 $dev4
108 lvcreate -l 4 -n $lv1 $vg1
109 not vgsplit $vg1 $vg2 $dev1 2>err;
110 grep "^ Logical volumes in \"$vg1\" must be inactive\$" err
111 vgremove -f $vg2
112 vgremove -f $vg1
114 # vgsplit rejects split because max_lv is exceeded
115 vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $dev1 $dev2
116 vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $dev3 $dev4
117 lvcreate -l 4 -n $lv1 $vg1
118 lvcreate -l 4 -n $lv2 $vg1
119 lvcreate -l 4 -n $lv3 $vg2
120 vgchange -an $vg1
121 vgchange -an $vg2
122 not vgsplit $vg1 $vg2 $dev1 2>err;
123 grep "^ Maximum number of logical volumes (2) exceeded" err
124 vgremove -f $vg2
125 vgremove -f $vg1
127 # vgsplit verify default - max_lv attribute from new VG is same as source VG" \
128 vgcreate -M$mdatype $vg1 $dev1 $dev2
129 lvcreate -l 4 -n $lv1 $vg1
130 vgchange -an $vg1
131 vgsplit $vg1 $vg2 $dev1
132 compare_vg_field_ $vg1 $vg2 max_lv
133 vgremove -f $vg2
134 vgremove -f $vg1
136 # vgsplit verify default - max_pv attribute from new VG is same as source VG" \
137 vgcreate -M$mdatype $vg1 $dev1 $dev2
138 lvcreate -l 4 -n $lv1 $vg1
139 vgchange -an $vg1
140 vgsplit $vg1 $vg2 $dev1
141 compare_vg_field_ $vg1 $vg2 max_pv
142 vgremove -f $vg2
143 vgremove -f $vg1
145 # vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \
146 vgcreate -M$mdatype $vg1 $dev1 $dev2
147 lvcreate -l 4 -n $lv1 $vg1
148 vgchange -an $vg1
149 vgsplit $vg1 $vg2 $dev1
150 compare_vg_field_ $vg1 $vg2 vg_fmt
151 vgremove -f $vg2
152 vgremove -f $vg1
154 # vgsplit rejects split because PV not in VG
155 vgcreate -M$mdatype $vg1 $dev1 $dev2
156 vgcreate -M$mdatype $vg2 $dev3 $dev4
157 lvcreate -l 4 -n $lv1 $vg1
158 lvcreate -l 4 -n $lv2 $vg1
159 vgchange -an $vg1
160 not vgsplit $vg1 $vg2 $dev3 2>err;
161 vgremove -f $vg2
162 vgremove -f $vg1
163 done
165 # ONLY LVM2 metadata
166 # setup PVs" '
167 pvcreate --metadatacopies 0 $dev5
169 # vgsplit rejects to give away pv with the last mda copy
170 vgcreate $vg1 $dev5 $dev2
171 lvcreate -l 10 -n $lv1 $vg1
172 lvchange -an $vg1/$lv1
173 vg_validate_pvlv_counts_ $vg1 2 1 0
174 not vgsplit $vg1 $vg2 $dev5;
175 vg_validate_pvlv_counts_ $vg1 2 1 0
176 vgremove -ff $vg1
178 # vgsplit rejects split because metadata types differ
179 pvcreate -ff -M1 $dev3 $dev4
180 pvcreate -ff $dev1 $dev2
181 vgcreate -M1 $vg1 $dev3 $dev4
182 vgcreate $vg2 $dev1 $dev2
183 not vgsplit $vg1 $vg2 $dev3 2>err;
184 grep "^ Metadata types differ" err
185 vgremove $vg2
186 vgremove $vg1