Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / t-lvcreate-usage.sh
blob14b6ecb4d04d484304ad97bf74f3fe8ff00a88af
1 #!/bin/sh
2 # Copyright (C) 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 # 'Exercise some lvcreate diagnostics'
14 . ./test-utils.sh
16 aux prepare_pvs 4
17 aux pvcreate --metadatacopies 0 $dev1
18 vgcreate -cn $vg $devs
20 # "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
21 lvcreate -n $lv -l 4 $vg
22 not lvcreate -n $lv -l 4 $vg
23 lvremove -ff $vg/$lv
24 # try to remove it again - should fail (but not segfault)
25 not lvremove -ff $vg/$lv
27 # "lvcreate rejects a negative stripe_size"
28 not lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
29 grep "^ Negative stripesize is invalid\$" err
31 # 'lvcreate rejects a too-large stripesize'
32 not lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
33 grep "^ Stripe size cannot be larger than" err
35 # 'lvcreate w/single stripe succeeds with diagnostics to stdout'
36 lvcreate -L 64m -n $lv -i1 --stripesize 4 $vg >out 2>err
37 grep "^ Redundant stripes argument: default is 1\$" out
38 grep "^ Ignoring stripesize argument with single stripe\$" out
39 lvdisplay $vg
40 lvremove -ff $vg
42 # 'lvcreate w/default (64KB) stripe size succeeds with diagnostics to stdout'
43 lvcreate -L 64m -n $lv -i2 $vg > out
44 grep "^ Using default stripesize" out
45 lvdisplay $vg
46 check_lv_field_ $vg/$lv stripesize "64.00k"
47 lvremove -ff $vg
49 # 'lvcreate rejects an invalid number of stripes'
50 not lvcreate -L 64m -n $lv -i129 $vg 2>err
51 grep "^ Number of stripes (129) must be between 1 and 128\$" err
53 # The case on lvdisplay output is to verify that the LV was not created.
54 # 'lvcreate rejects an invalid stripe size'
55 not lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
56 grep "^ Invalid stripe size" err
57 case $(lvdisplay $vg) in "") true ;; *) false ;; esac
59 # Setting max_lv works. (bz490298)
60 lvremove -ff $vg
61 vgchange -l 3 $vg
62 lvcreate -l1 -n $lv1 $vg
63 lvcreate -l1 -s -n $lv2 $vg/$lv1
64 lvcreate -l1 -n $lv3 $vg
65 not lvcreate -l1 -n $lv4 $vg
67 lvremove -ff $vg/$lv3
68 lvcreate -l1 -s -n $lv3 $vg/$lv1
69 not lvcreate -l1 -n $lv4 $vg
70 not lvcreate -l1 -m1 -n $lv4 $vg
72 lvremove -ff $vg/$lv3
73 lvcreate -l1 -m1 -n $lv3 $vg
74 lvs
75 vgs -o +max_lv
76 not lvcreate -l1 -n $lv4 $vg
77 not lvcreate -l1 -m1 -n $lv4 $vg
79 lvconvert -m0 $vg/$lv3
80 lvconvert -m2 -i 1 $vg/$lv3
81 lvconvert -m1 $vg/$lv3
83 not vgchange -l 2
84 vgchange -l 4
85 vgs $vg
87 lvremove -ff $vg
88 vgchange -l 0 $vg
90 # lvcreate rejects invalid chunksize, accepts between 4K and 512K
91 # validate origin_size
92 vgremove -ff $vg
93 vgcreate -cn $vg $devs
94 lvcreate -L 32m -n $lv1 $vg
95 not lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg/$lv1
96 not lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg/$lv1
97 lvcreate -L 8m -n $lv2 -s --chunksize 4k $vg/$lv1
98 check_lv_field_ $vg/$lv2 chunk_size 4.00k
99 check_lv_field_ $vg/$lv2 origin_size 32.00m
100 lvcreate -L 8m -n $lv3 -s --chunksize 512k $vg/$lv1
101 check_lv_field_ $vg/$lv3 chunk_size 512.00k
102 check_lv_field_ $vg/$lv3 origin_size 32.00m
103 lvremove -ff $vg
104 vgchange -l 0 $vg
106 # regionsize must be
107 # - nonzero (bz186013)
108 # - a power of 2 and a multiple of page size
109 # - <= size of LV
110 not lvcreate -L 32m -n $lv -R0 $vg 2>err
111 grep "Non-zero region size must be supplied." err
112 not lvcreate -L 32m -n $lv -R 11k $vg
113 not lvcreate -L 32m -n $lv -R 1k $vg
114 lvcreate -L 32m -n $lv --regionsize 128m -m 1 $vg
115 check_lv_field_ $vg/$lv regionsize "32.00m"
116 lvremove -ff $vg
117 lvcreate -L 32m -n $lv --regionsize 4m -m 1 $vg
118 check_lv_field_ $vg/$lv regionsize "4.00m"
119 lvremove -ff $vg
121 # snapshot with virtual origin works
122 lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
123 lvrename $vg/$lv1 $vg/$lv2
124 lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
125 lvchange -a n $vg/$lv1
126 lvremove $vg/$lv1
127 lvremove -ff $vg