File:  [ELWIX - Embedded LightWeight unIX -] / elwix / config / etc / default / fit2cf.sh
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Thu Mar 11 13:59:50 2021 UTC (3 years, 7 months ago) by misho
Branches: MAIN
CVS tags: elwix2_8, elwix2_7, HEAD, ELWIX2_7, ELWIX2_6
ver 2.6

    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.2 2021/03/11 13:59:50 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("%d", $4); }'`
   35: OLDSIZE=`disklabel $DEV | awk '($1 == "c:") { printf("%d", $2); }'`
   36: disklabel $DEV 2>&- | awk -vdevsize=$DEVSIZE -voldsize=$OLDSIZE '($1 == "c:") {
   37: 			for (i = 1; i <= NF; i++)
   38: 				printf("%s ", (i == 2) ? devsize : $i);
   39: 			printf("\n");
   40: 			next;
   41: 		      }
   42: 		      ($1 == "a:") {
   43: 			printf("e: %d %d unused 0 0 0\n", devsize - oldsize, oldsize);
   44: 		      }
   45: 		      { printf("%s\n", $0); }' >/tmp/disklabel.tmp
   46: 
   47: sysctl kern.geom.debugflags=16
   48: disklabel -R $DEV /tmp/disklabel.tmp
   49: newfs -b8192 -f1024 -m0 -Lfit2cf ${DEV}e
   50: sysctl kern.geom.debugflags=0
   51: 
   52: rm -f /tmp/disklabel.tmp
   53: echo
   54: echo " Now will restart system to activate new schema !!!"
   55: echo
   56: kill -2 1

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>