1#!/bin/sh 2# This script should be run prior to running executing the filesystem tests. 3# valid devices need to be passed for Device Mapper to work correctly 4# 03/14/03 mridge@us.ibm.com added instance and time command line options 5# 05/16/03 changed script paths 6# 05/20/03 Added instructions on setup and warnings 7# 05/03/2004 hien1@us.ibm.com Added resize2fs and resize_reiserfs after extend and reduce LVs 8# 05/03/2004 Moved the mount after resizing 9# 05/03/2004 Modified /dev/ram to /dev/ram0 10 11cd `dirname $0` 12export LTPROOT=${PWD} 13echo $LTPROOT | grep testscripts > /dev/null 2>&1 14if [ $? -eq 0 ]; then 15 cd .. 16 export LTPROOT=${PWD} 17fi 18 19export TMPBASE="/tmp" 20 21 22usage() 23{ 24 cat <<-END >&2 25 usage: ${0##*/} [ -a part1 ] [ -b part2 ] [ -c part3 ] 26 [ -d part4 ] [ -n nfsmount ] 27 defaults: 28 part1=$part1 29 part2=$part2 30 part3=$part3 31 part4=$part4 32 nfsmount=$nfsmount 33 ltproot=$TPROOT 34 tmpdir=$TMPBASE 35 36 example: ${0##*/} -a hdc1 -b hdc2 -c hdc3 -d hdc4 -n mytesthost:/testmountdir 37 38 fdisk needs to be run and the 4 HD partitions marked as 0x8e -- Linux LVM 39 40 - If this is run on a 2.4 kernel system then LVM must be configured and the kernel rebuilt. In a 2.5 environment 41 you must configure Device Mapper and install LVM2 from www.systina.com for the testcase to run correctly. 42 43 - These operations are destructive so do NOT point the tests to partitions where the data shouldn't be overwritten. 44 Once these tests are started all data in the partitions you point to will be destroyed. 45 46 END 47exit 48} 49 50while getopts :a:b:c:d:e:n:v: arg 51do case $arg in 52 a) part1=$OPTARG;; 53 b) part2=$OPTARG;; 54 c) part3=$OPTARG;; 55 d) part4=$OPTARG;; 56 n) nfsmount=$OPTARG;; 57 v) verb=$OPTARG;; 58 59 \?) echo "************** Help Info: ********************" 60 usage;; 61 esac 62done 63 64if [ ! -n "$part1" ]; then 65 echo "Missing 1st partition. You must pass 4 partitions for testing" 66 usage; 67 exit 68fi 69 70if [ ! -n "$part2" ]; then 71 echo "Missing 2nd partition. You must pass 4 partitions for testing" 72 usage; 73 exit 74fi 75 76if [ ! -n "$part3" ]; then 77 echo "Missing 3rd partition. You must pass 4 partitions for testing" 78 usage; 79 exit 80fi 81 82if [ ! -n "$part4" ]; then 83 echo "Missing 4th partition. You must pass 4 partitions for testing" 84 usage; 85 exit 86fi 87 88if [ ! -n "$nfsmount" ]; then 89 echo "Missing NFS partition. You must pass an NFS mount point for testing" 90 usage; 91 exit 92fi 93 94export PATH="${PATH}:${LTPROOT}/testcases/bin" 95 96 97mkdir /test >/dev/null 2>&1 98mkdir /test/growfiles >/dev/null 2>&1 99mkdir /test/growfiles/ext2 >/dev/null 2>&1 100mkdir /test/growfiles/msdos >/dev/null 2>&1 101mkdir /test/growfiles/reiser >/dev/null 2>&1 102mkdir /test/growfiles/minix >/dev/null 2>&1 103mkdir /test/growfiles/nfs >/dev/null 2>&1 104mkdir /test/growfiles/jfs >/dev/null 2>&1 105mkdir /test/growfiles/ramdisk >/dev/null 2>&1 106 107vgscan 108vgchange -a y 109 110pvcreate -v /dev/$part1 /dev/$part2 /dev/$part3 /dev/$part4 111vgcreate -v ltp_test_vg1 /dev/$part1 /dev/$part2 112vgcreate -v ltp_test_vg2 /dev/$part3 /dev/$part4 113vgcfgbackup -v 114lvcreate -v -L 100 ltp_test_vg1 -n ltp_test_lv1 115lvcreate -v -L 100 ltp_test_vg1 -n ltp_test_lv2 -i 2 116lvcreate -v -L 100 ltp_test_vg2 -n ltp_test_lv3 117lvcreate -v -L 100 ltp_test_vg2 -n ltp_test_lv4 118 119mkfs -V -t ext2 /dev/ltp_test_vg1/ltp_test_lv1 120mkfs -V -t msdos /dev/ltp_test_vg1/ltp_test_lv2 121mkreiserfs /dev/ltp_test_vg2/ltp_test_lv3 <yesenter.txt 122mkfs -V -t minix /dev/ltp_test_vg2/ltp_test_lv4 123 124### there is no /dev/ram - has /dev/ram0 ... /dev/ram15 125mkfs -V -t ext3 /dev/ram0 126 127 128lvmdiskscan -v 129lvscan -v 130vgdisplay -v 131lvextend -v -l +5000 /dev/ltp_test_vg1/ltp_test_lv1 132lvreduce -v -f -l -20 /dev/ltp_test_vg1/ltp_test_lv1 133 134### Need to be resize to get LV to the correct size 135resize2fs -f /dev/ltp_test_vg1/ltp_test_lv1 136lvextend -v -l +5000 /dev/ltp_test_vg1/ltp_test_lv2 137lvreduce -v -f -l -20 /dev/ltp_test_vg1/ltp_test_lv2 138 139### Need to be resize to get LV to the correct size 140resize_reiserfs -f /dev/ltp_test_vg1/ltp_test_lv2 141lvextend -v -l +20 /dev/ltp_test_vg2/ltp_test_lv3 142lvreduce -v -f -l -20 /dev/ltp_test_vg2/ltp_test_lv3 143lvextend -v -l +20 /dev/ltp_test_vg2/ltp_test_lv4 144lvreduce -v -f -l -20 /dev/ltp_test_vg2/ltp_test_lv4 145 146vgreduce -v /dev/ltp_test_vg1 /dev/$part2 147vgextend -v /dev/ltp_test_vg1 /dev/$part2 148vgck -v 149 150### Move mount filesystems to the last since resize can't work on a mounted filesystem. 151mount -v -t nfs $nfsmount /test/growfiles/nfs 152mount -v /dev/ltp_test_vg1/ltp_test_lv1 /test/growfiles/ext2 153mount -v /dev/ltp_test_vg1/ltp_test_lv2 /test/growfiles/msdos 154mount -v /dev/ltp_test_vg2/ltp_test_lv3 /test/growfiles/reiser 155mount -v /dev/ltp_test_vg2/ltp_test_lv4 /test/growfiles/minix 156mount -v /dev/ram /test/growfiles/ramdisk 157 158echo "************ Running tests " 159sort -R ${LTPROOT}/runtest/lvm.part1 -o ${TMPBASE}/lvm.part1 160 161${LTPROOT}/bin/ltp-pan -e -S -a lvmpart1 -n lvmpart1 -l lvmlogfile -f ${TMPBASE}/lvm.part1 & 162 163wait $! 164 165 166 167umount -v -t nfs $nfsmount 168umount -v /dev/ltp_test_vg1/ltp_test_lv1 169umount -v /dev/ltp_test_vg1/ltp_test_lv2 170umount -v /dev/ltp_test_vg2/ltp_test_lv3 171umount -v /dev/ltp_test_vg2/ltp_test_lv4 172umount -v /dev/ram 173 174lvremove -f -v /dev/ltp_test_vg1/ltp_test_lv1 175lvremove -f -v /dev/ltp_test_vg1/ltp_test_lv2 176lvremove -f -v /dev/ltp_test_vg2/ltp_test_lv3 177lvremove -f -v /dev/ltp_test_vg2/ltp_test_lv4 178 179lvscan -v 180vgchange -a n 181vgremove -v /dev/ltp_test_vg1 182vgremove -v /dev/ltp_test_vg2 183 184mkfs -V -t ext3 /dev/$part4 185mkfs -V -t jfs /dev/$part1 <yesenter.txt 186 187mount -v -t ext3 /dev/$part4 /test/growfiles/ext3 188mount -v -t jfs /dev/hdc1 /test/growfiles/jfs 189 190echo "************ Running EXT3 & JFS tests... " 191sort -R ${LTPROOT}/runtest/lvm.part2 -o ${TMPBASE}/lvm.part2 192 193${LTPROOT}/bin/ltp-pan -e -S -a lvmpart2 -n lvmpart2 -l lvmlogfile -f ${TMPBASE}/lvm.part2 & 194 195wait $! 196 197umount -v /dev/$part1 198umount -v /dev/$part4 199 200 201