xref: /dflybsd-src/contrib/lvm2/dist/test/t-lvcreate-usage.sh (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino#!/bin/sh
286d7f5d3SJohn Marino# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
386d7f5d3SJohn Marino#
486d7f5d3SJohn Marino# This copyrighted material is made available to anyone wishing to use,
586d7f5d3SJohn Marino# modify, copy, or redistribute it subject to the terms and conditions
686d7f5d3SJohn Marino# of the GNU General Public License v.2.
786d7f5d3SJohn Marino#
886d7f5d3SJohn Marino# You should have received a copy of the GNU General Public License
986d7f5d3SJohn Marino# along with this program; if not, write to the Free Software Foundation,
1086d7f5d3SJohn Marino# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1186d7f5d3SJohn Marino
1286d7f5d3SJohn Marino# 'Exercise some lvcreate diagnostics'
1386d7f5d3SJohn Marino
1486d7f5d3SJohn Marino. ./test-utils.sh
1586d7f5d3SJohn Marino
1686d7f5d3SJohn Marinoaux prepare_pvs 4
1786d7f5d3SJohn Marinoaux pvcreate --metadatacopies 0 $dev1
1886d7f5d3SJohn Marinovgcreate -cn $vg $devs
1986d7f5d3SJohn Marino
2086d7f5d3SJohn Marino# "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
2186d7f5d3SJohn Marinolvcreate -n $lv -l 4 $vg
2286d7f5d3SJohn Marinonot lvcreate -n $lv -l 4 $vg
2386d7f5d3SJohn Marinolvremove -ff $vg/$lv
2486d7f5d3SJohn Marino# try to remove it again - should fail (but not segfault)
2586d7f5d3SJohn Marinonot lvremove -ff $vg/$lv
2686d7f5d3SJohn Marino
2786d7f5d3SJohn Marino# "lvcreate rejects a negative stripe_size"
2886d7f5d3SJohn Marinonot lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err;
2986d7f5d3SJohn Marinogrep "^  Negative stripesize is invalid\$" err
3086d7f5d3SJohn Marino
3186d7f5d3SJohn Marino# 'lvcreate rejects a too-large stripesize'
3286d7f5d3SJohn Marinonot lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err
3386d7f5d3SJohn Marinogrep "^  Stripe size cannot be larger than" err
3486d7f5d3SJohn Marino
3586d7f5d3SJohn Marino# 'lvcreate w/single stripe succeeds with diagnostics to stdout'
3686d7f5d3SJohn Marinolvcreate -L 64m -n $lv -i1 --stripesize 4 $vg >out 2>err
3786d7f5d3SJohn Marinogrep "^  Redundant stripes argument: default is 1\$" out
3886d7f5d3SJohn Marinogrep "^  Ignoring stripesize argument with single stripe\$" out
3986d7f5d3SJohn Marinolvdisplay $vg
4086d7f5d3SJohn Marinolvremove -ff $vg
4186d7f5d3SJohn Marino
4286d7f5d3SJohn Marino# 'lvcreate w/default (64KB) stripe size succeeds with diagnostics to stdout'
4386d7f5d3SJohn Marinolvcreate -L 64m -n $lv -i2 $vg > out
4486d7f5d3SJohn Marinogrep "^  Using default stripesize" out
4586d7f5d3SJohn Marinolvdisplay $vg
4686d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv stripesize "64.00k"
4786d7f5d3SJohn Marinolvremove -ff $vg
4886d7f5d3SJohn Marino
4986d7f5d3SJohn Marino# 'lvcreate rejects an invalid number of stripes'
5086d7f5d3SJohn Marinonot lvcreate -L 64m -n $lv -i129 $vg 2>err
5186d7f5d3SJohn Marinogrep "^  Number of stripes (129) must be between 1 and 128\$" err
5286d7f5d3SJohn Marino
5386d7f5d3SJohn Marino# The case on lvdisplay output is to verify that the LV was not created.
5486d7f5d3SJohn Marino# 'lvcreate rejects an invalid stripe size'
5586d7f5d3SJohn Marinonot lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err
5686d7f5d3SJohn Marinogrep "^  Invalid stripe size" err
5786d7f5d3SJohn Marinocase $(lvdisplay $vg) in "") true ;; *) false ;; esac
5886d7f5d3SJohn Marino
5986d7f5d3SJohn Marino# Setting max_lv works. (bz490298)
6086d7f5d3SJohn Marinolvremove -ff $vg
6186d7f5d3SJohn Marinovgchange -l 3 $vg
6286d7f5d3SJohn Marinolvcreate -l1 -n $lv1 $vg
6386d7f5d3SJohn Marinolvcreate -l1 -s -n $lv2 $vg/$lv1
6486d7f5d3SJohn Marinolvcreate -l1 -n $lv3 $vg
6586d7f5d3SJohn Marinonot lvcreate -l1 -n $lv4 $vg
6686d7f5d3SJohn Marino
6786d7f5d3SJohn Marinolvremove -ff $vg/$lv3
6886d7f5d3SJohn Marinolvcreate -l1 -s -n $lv3 $vg/$lv1
6986d7f5d3SJohn Marinonot lvcreate -l1 -n $lv4 $vg
7086d7f5d3SJohn Marinonot lvcreate -l1 -m1 -n $lv4 $vg
7186d7f5d3SJohn Marino
7286d7f5d3SJohn Marinolvremove -ff $vg/$lv3
7386d7f5d3SJohn Marinolvcreate -l1 -m1 -n $lv3 $vg
7486d7f5d3SJohn Marinolvs
7586d7f5d3SJohn Marinovgs -o +max_lv
7686d7f5d3SJohn Marinonot lvcreate -l1 -n $lv4 $vg
7786d7f5d3SJohn Marinonot lvcreate -l1 -m1 -n $lv4 $vg
7886d7f5d3SJohn Marino
7986d7f5d3SJohn Marinolvconvert -m0 $vg/$lv3
8086d7f5d3SJohn Marinolvconvert -m2 -i 1 $vg/$lv3
8186d7f5d3SJohn Marinolvconvert -m1 $vg/$lv3
8286d7f5d3SJohn Marino
8386d7f5d3SJohn Marinonot vgchange -l 2
8486d7f5d3SJohn Marinovgchange -l 4
8586d7f5d3SJohn Marinovgs $vg
8686d7f5d3SJohn Marino
8786d7f5d3SJohn Marinolvremove -ff $vg
8886d7f5d3SJohn Marinovgchange -l 0 $vg
8986d7f5d3SJohn Marino
9086d7f5d3SJohn Marino# lvcreate rejects invalid chunksize, accepts between 4K and 512K
9186d7f5d3SJohn Marino# validate origin_size
9286d7f5d3SJohn Marinovgremove -ff $vg
9386d7f5d3SJohn Marinovgcreate -cn $vg $devs
9486d7f5d3SJohn Marinolvcreate -L 32m -n $lv1 $vg
9586d7f5d3SJohn Marinonot lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg/$lv1
9686d7f5d3SJohn Marinonot lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg/$lv1
9786d7f5d3SJohn Marinolvcreate -L 8m -n $lv2 -s --chunksize 4k $vg/$lv1
9886d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv2 chunk_size 4.00k
9986d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv2 origin_size 32.00m
10086d7f5d3SJohn Marinolvcreate -L 8m -n $lv3 -s --chunksize 512k $vg/$lv1
10186d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv3 chunk_size 512.00k
10286d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv3 origin_size 32.00m
10386d7f5d3SJohn Marinolvremove -ff $vg
10486d7f5d3SJohn Marinovgchange -l 0 $vg
10586d7f5d3SJohn Marino
10686d7f5d3SJohn Marino# regionsize must be
10786d7f5d3SJohn Marino# - nonzero (bz186013)
10886d7f5d3SJohn Marino# - a power of 2 and a multiple of page size
10986d7f5d3SJohn Marino# - <= size of LV
11086d7f5d3SJohn Marinonot lvcreate -L 32m -n $lv -R0 $vg 2>err
11186d7f5d3SJohn Marinogrep "Non-zero region size must be supplied." err
11286d7f5d3SJohn Marinonot lvcreate -L 32m -n $lv -R 11k $vg
11386d7f5d3SJohn Marinonot lvcreate -L 32m -n $lv -R 1k $vg
11486d7f5d3SJohn Marinolvcreate -L 32m -n $lv --regionsize 128m  -m 1 $vg
11586d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv regionsize "32.00m"
11686d7f5d3SJohn Marinolvremove -ff $vg
11786d7f5d3SJohn Marinolvcreate -L 32m -n $lv --regionsize 4m -m 1 $vg
11886d7f5d3SJohn Marinocheck_lv_field_ $vg/$lv regionsize "4.00m"
11986d7f5d3SJohn Marinolvremove -ff $vg
12086d7f5d3SJohn Marino
12186d7f5d3SJohn Marino# snapshot with virtual origin works
12286d7f5d3SJohn Marinolvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
12386d7f5d3SJohn Marinolvrename $vg/$lv1 $vg/$lv2
12486d7f5d3SJohn Marinolvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg
12586d7f5d3SJohn Marinolvchange -a n $vg/$lv1
12686d7f5d3SJohn Marinolvremove $vg/$lv1
12786d7f5d3SJohn Marinolvremove -ff $vg
128