1: #!/bin/sh
2: #
3: # (C)`10 by Michael Pounov <misho@elwix.org>
4: # ELWIX grow disklabel sectors and fit-to-flash whole unused space
5: #
6: # $Id: fit2cf.sh,v 1.3 2021/03/11 13:59:51 misho Exp $
7: #
8:
9: echo -n "++++ Check existence of fit2cf device ... "
10: if [ -c /dev/ufs/fit2cf ]; then
11: echo "OK"
12: exit 0
13: else
14: echo "Not found!"
15: fi
16:
17: if [ -z $1 ]; then
18: echo "Not specified disk drive ..."
19: exit 1
20: else
21: DEV=$(echo $1 | awk '{
22: if (!($1 ~ /^\//))
23: printf("/dev/%s", $1);
24: else
25: printf("%s", $1);
26: }')
27: if ! [ -c $DEV ]; then
28: echo "Wrong device $DEV !!!"
29: exit 1
30: fi
31: fi
32:
33: echo "Fit slice ${DEV}e to whole size of $DEV ..."
34: DEVSIZE=`diskinfo $DEV | awk '{ printf("%s", $4); }'`
35: disklabel $DEV 2>&- | awk -vdevsize=$DEVSIZE '($1 == "c:") {
36: for (i = 1; i <= NF; i++)
37: printf("%s ", (i == 2) ? devsize : $i);
38: printf("\n");
39: next;
40: }
41: ($1 == "a:") {
42: for (i = 1; i <= NF; i++) {
43: if (i == 2)
44: offset = $i + $3
45: printf("%s ", $i);
46: }
47: printf("\n");
48: printf("e: %d %d unused 0 0 0\n", devsize - offset, offset);
49: next;
50: }
51: { printf("%s\n", $0); }' >/tmp/disklabel.tmp
52:
53: sysctl kern.geom.debugflags=16
54: disklabel -R $DEV /tmp/disklabel.tmp
55: newfs -b8192 -f1024 -m0 -Lfit2cf ${DEV}e
56: sysctl kern.geom.debugflags=0
57:
58: rm -f /tmp/disklabel.tmp
59: echo
60: echo " Now will restart system to activate new schema !!!"
61: echo
62: kill -2 1
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>