resize_test.sh revision 213167
1212934Sbrian#! /bin/sh 2212934Sbrian# 3212934Sbrian# $FreeBSD: head/tools/regression/geom_eli/resize.t 213167 2010-09-25 10:34:11Z pjd $ 4212934Sbrian 5212934Sbrianecho 1..27 6212934Sbrian 7212934SbrianBLK=512 8212934SbrianBLKS_PER_MB=2048 9212934Sbrian 10212934Sbrianmd=$(mdconfig -s40m) || exit 1 11212934Sbrianunit=${md#md} 12212934Sbriani=1 13212934Sbrian 14212934Sbriansetsize() { 15212934Sbrian partszMB=$1 unitszMB=$2 16212934Sbrian 17212934Sbrian { 18212934Sbrian echo a: $(($partszMB * $BLKS_PER_MB)) 0 4.2BSD 1024 8192 19212934Sbrian echo c: $(($unitszMB * $BLKS_PER_MB)) 0 unused 0 0 20212934Sbrian } | disklabel -R $md /dev/stdin 21212934Sbrian} 22212934Sbrian 23212934Sbrian# Initialise 24212934Sbrian 25212934Sbriankldload geom_eli >/dev/null 2>&1 26212934Sbrian 27212934Sbriansetsize 10 40 || echo -n "not " 28212934Sbrianecho ok $i - "Sized ${md}a to 10m" 29212934Sbriani=$((i + 1)) 30212934Sbrian 31212934Sbrianecho secret >tmp.key 32212934Sbriangeli init -Bnone -PKtmp.key ${md}a || echo -n "not " 33212934Sbrianecho ok $i - "Initialised geli on ${md}a" 34212934Sbriani=$((i + 1)) 35212934Sbriangeli attach -pk tmp.key ${md}a || echo -n "not " 36212934Sbrianecho ok $i - "Attached ${md}a as ${md}a.eli" 37212934Sbriani=$((i + 1)) 38212934Sbrian 39212934Sbriannewfs -U ${md}a.eli >/dev/null || echo -n "not " 40212934Sbrianecho ok $i - "Initialised the filesystem on ${md}a.eli" 41212934Sbriani=$((i + 1)) 42212934Sbrianout=$(fsck -tufs -y ${md}a.eli) 43212934Sbrianecho "$out" | fgrep -q MODIFIED && echo -n "not " 44212934Sbrianecho ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ 45212934Sbrian "lines of output" 46212934Sbriani=$((i + 1)) 47212934Sbrian 48212934Sbrian 49212934Sbrian# Doing a backup, resize & restore must be forced (with -f) as geli 50212934Sbrian# verifies that the provider size in the metadata matches the consumer. 51212934Sbrian 52212934Sbriangeli backup ${md}a tmp.meta || echo -n "not " 53212934Sbrianecho ok $i - "Backed up ${md}a metadata" 54212934Sbriani=$((i + 1)) 55212934Sbrian 56212934Sbriangeli detach ${md}a.eli || echo -n "not " 57212934Sbrianecho ok $i - "Detached ${md}a.eli" 58212934Sbriani=$((i + 1)) 59212934Sbrian 60212934Sbriansetsize 20 40 || echo -n "not " 61212934Sbrianecho ok $i - "Sized ${md}a to 20m" 62212934Sbriani=$((i + 1)) 63212934Sbriangeli attach -pktmp.key ${md}a && echo -n "not " 64212934Sbrianecho ok $i - "Attaching ${md}a fails after resizing the consumer" 65212934Sbriani=$((i + 1)) 66212934Sbrian 67212934Sbriangeli restore tmp.meta ${md}a && echo -n "not " 68212934Sbrianecho ok $i - "Restoring metadata on ${md}a.eli fails without -f" 69212934Sbriani=$((i + 1)) 70212934Sbriangeli restore -f tmp.meta ${md}a || echo -n "not " 71212934Sbrianecho ok $i - "Restoring metadata on ${md}a.eli can be forced" 72212934Sbriani=$((i + 1)) 73212934Sbrian 74212934Sbriangeli attach -pktmp.key ${md}a || echo -n "not " 75212934Sbrianecho ok $i - "Attaching ${md}a is now possible" 76212934Sbriani=$((i + 1)) 77212934Sbrian 78212934Sbriangrowfs -y ${md}a.eli >/dev/null || echo -n "not " 79212934Sbrianecho ok $i - "Extended the filesystem on ${md}a.eli" 80212934Sbriani=$((i + 1)) 81212934Sbrian 82212934Sbrianout=$(fsck -tufs -y ${md}a.eli) 83212934Sbrianecho "$out" | fgrep -q MODIFIED && echo -n "not " 84212934Sbrianecho ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ 85212934Sbrian "lines of output" 86212934Sbriani=$((i + 1)) 87212934Sbrian 88212934Sbrian 89212934Sbrian# Now do the resize properly 90212934Sbrian 91212934Sbriangeli detach ${md}a.eli || echo -n "not " 92212934Sbrianecho ok $i - "Detached ${md}a.eli" 93212934Sbriani=$((i + 1)) 94212934Sbrian 95212934Sbriansetsize 30 40 || echo -n "not " 96212934Sbrianecho ok $i - "Sized ${md}a to 30m" 97212934Sbriani=$((i + 1)) 98212934Sbrian 99212934Sbriangeli resize -s20m ${md}a || echo -n "not " 100212934Sbrianecho ok $i - "Resizing works ok" 101212934Sbriani=$((i + 1)) 102212934Sbriangeli resize -s20m ${md}a && echo -n "not " 103212934Sbrianecho ok $i - "Resizing doesn't work a 2nd time (no old metadata)" 104212934Sbriani=$((i + 1)) 105212934Sbrian 106212934Sbriangeli attach -pktmp.key ${md}a || echo -n "not " 107212934Sbrianecho ok $i - "Attaching ${md}a works ok" 108212934Sbriani=$((i + 1)) 109212934Sbrian 110212934Sbriangrowfs -y ${md}a.eli >/dev/null || echo -n "not " 111212934Sbrianecho ok $i - "Extended the filesystem on ${md}a.eli" 112212934Sbriani=$((i + 1)) 113212934Sbrian 114212934Sbrianout=$(fsck -tufs -y ${md}a.eli) 115212934Sbrianecho "$out" | fgrep -q MODIFIED && echo -n "not " 116212934Sbrianecho ok $i - "fsck says ${md}a.eli is clean," $(echo $(echo "$out" | wc -l)) \ 117212934Sbrian "lines of output" 118212934Sbriani=$((i + 1)) 119212934Sbrian 120212934Sbriangeli detach ${md}a.eli 121212934Sbrian 122212934Sbrian 123212934Sbrian# Verify that the man page example works, changing ada0 to $md, 124212934Sbrian# 1g to 20m, 2g to 30m and keyfile to tmp.key, and adding -B none 125212934Sbrian# to geli init. 126212934Sbrian 127213167Spjdgpart create -s GPT $md || echo -n "not " 128213167Spjdecho ok $i - "Installed an GPT on md0" 129212934Sbriani=$((i + 1)) 130212934Sbriangpart add -s 20m -t freebsd-ufs -i 1 $md || echo -n "not " 131212934Sbrianecho ok $i - "Added a 20m partition in slot 1" 132212934Sbriani=$((i + 1)) 133212934Sbriangeli init -B none -K tmp.key -P ${md}p1 || echo -n "not " 134212934Sbrianecho ok $i - "Initialised geli on ${md}p1" 135212934Sbriani=$((i + 1)) 136212934Sbriangpart resize -s 30m -i 1 $md || echo -n "not " 137212934Sbrianecho ok $i - "Resized partition ${md}p1 to 30m" 138212934Sbriani=$((i + 1)) 139212934Sbriangeli resize -s 20m ${md}p1 || echo -n "not " 140212934Sbrianecho ok $i - "Resized geli on ${md}p1 to 30m" 141212934Sbriani=$((i + 1)) 142212934Sbriangeli attach -k tmp.key -p ${md}p1 || echo -n "not " 143212934Sbrianecho ok $i - "Attached ${md}p1.eli" 144212934Sbriani=$((i + 1)) 145212934Sbrian 146212934Sbriangeli detach ${md}p1.eli 147212934Sbrianmdconfig -du$unit 148212934Sbrian 149212934Sbrianrm tmp.* 150