#!/bin/rc
# create, wipe bootable device
fn logprog{
echo $"*
$*
}
fn bootfat{
dev=$1
cd /sys/src/boot/pc && mk 9bootfat mbr pbs
disk/mbr -m mbr $dev/data
echo
echo 'This is dev/fdisk; use it to create a FAT32 partition.'
echo 'When finished, type ''w'' and then ''q''.'
echo
disk/fdisk -b $dev/data
disk/format -b pbs -d -r 2 $dev/dos
s=sdos
n=/n/dos
dossrv -f $dev/dos $s
mount -c /srv/$s $n
{
echo 'bootfile=/'$"cputype'/9pcf'
echo 'mouseport=ask'
echo 'monitor=ask'
echo 'vgasize=ask'
} >$n/plan9.ini
logprog cp /$cputype/9bootfat $n
logprog mkdir $n/$cputype
logprog cp /$cputype/9pcf $n/$cputype
unmount $n
rm -f /srv/$s
}
fn wipe{
dev=$1
echo 'awk ''/^part/{if($2!="data"){print "delpart "$2}}'' '$"dev'/ctl >'$"dev'/ctl'
awk '/^part/{if($2!="data"){print "delpart "$2}}' $dev/ctl >$dev/ctl
logprog dd -if /dev/zero -of $dev/data -bs 51dev -count 4
}
fn usage{
echo usage: $0 [ -b device ] [ -w device ] >[1=2]
exit usage
}
if(! ~ $1 -* || ~ $#2 0)
usage
switch($1){
case -b
wipe $2
bootfat $2
case -w
wipe $2
case *
usage
}
|