summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-01-30 13:12:13 +0000
committerphk <phk@FreeBSD.org>2005-01-30 13:12:13 +0000
commitf64119b04d6936175f18ce1825361e610d1394c8 (patch)
tree3e8efd7b3254383c31e78e3d5c575d1271712259 /tools
parentdbb0b5a00bb5d064b3dd792dda81f23148866116 (diff)
downloadFreeBSD-src-f64119b04d6936175f18ce1825361e610d1394c8.zip
FreeBSD-src-f64119b04d6936175f18ce1825361e610d1394c8.tar.gz
Use awk to correctly calculate partioning, round things off to cylinders
and reserve first track etc.
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/nanobsd/i386.diskimage21
1 files changed, 13 insertions, 8 deletions
diff --git a/tools/tools/nanobsd/i386.diskimage b/tools/tools/nanobsd/i386.diskimage
index 2047604..ca00291 100644
--- a/tools/tools/nanobsd/i386.diskimage
+++ b/tools/tools/nanobsd/i386.diskimage
@@ -56,14 +56,19 @@ CFGLABEL=`get_label ${CFGSLICE}`
dd if=/dev/zero of=${TMPFILE0} count=${SECTS}
MD=`mdconfig -a -t vnode -f ${TMPFILE0} -x ${SC} -y ${HD}`
rm -f ${TMPFILE0}
-(
-sl=`expr "(" ${SECTS} - ${SC} - ${DATASIZE} ")" / 2`
-cyl=`expr ${SECTS} / ${SC} / ${HD}`
-echo g c${cyl} h${HD} s${SC}
-echo p 1 165 ${SC} $sl
-echo p 2 165 `expr ${SC} + $sl` $sl
-echo p 3 165 `expr ${SC} + $sl + $sl` ${DATASIZE}
-) > ${TMPFILE1}
+echo ${SECTS} ${SC} ${HD} ${DATASIZE} | awk '
+ {
+ cs = $2 * $3
+ cyl = $1 / cs
+ print "g c" cyl " h" $3 " s" $2
+ dsl = int (($4 + cs - 1) / cs)
+ csl = int ((cyl - dsl) / 2)
+ dsl = cyl - csl * 2
+ print "p 1 165 " $2, csl * cs - $2
+ print "p 2 165 " $2 + csl * cs, csl * cs - $2
+ print "p 3 165 " 2 * csl * cs, dsl * cs
+ }
+' > ${TMPFILE1}
cat ${TMPFILE1}
fdisk -i -f ${TMPFILE1} ${MD}
fdisk ${MD}
OpenPOWER on IntegriCloud