Here's a snippet of something I've been working on along the same lines -
this is /bin/csh syntax, and works on raid0 but should work on regular
partitions as well:

echo "get raid size..."
@ r_tot = `disklabel -p g raid0 | awk '/total bytes/ { print int($3) }'`

@ r_root = 1;   @ r_tot -= $r_root
@ r_swap = 1;   @ r_tot -= $r_swap
@ r_tmp  = 1;   @ r_tot -= $r_tmp
@ r_usr  = 10;  @ r_tot -= $r_usr
@ r_home = 4;   @ r_tot -= $r_home
@ r_obj  = 4;   @ r_tot -= $r_obj
@ r_xobj = 4;   @ r_tot -= $r_xobj
@ r_pobj = 20;  @ r_tot -= $r_pobj
@ r_var  = $r_tot

if ($r_var < 0) then
    echo 'not enough space on raid0 for all partitions'
    exit 1
endif

echo "create raid label partitions..."
# NB: blank lines matter here
disklabel -E raid0 << _EOF_
a a

${r_root}G

a b

${r_swap}G

a d

${r_tmp}G

a e

${r_usr}G

a f

${r_home}G

a g

${r_obj}G

a h

${r_xobj}G

a i

${r_pobj}G

a j



w
q
_EOF_

Reply via email to