32 lines
686 B
Bash
32 lines
686 B
Bash
#!/bin/sh
|
|
#
|
|
# do like as disklabel -B
|
|
# --written by Yasha
|
|
#
|
|
# usage: writeboot <boot_file> <boot_device(raw)>
|
|
#
|
|
# $NetBSD: writefdboot,v 1.3 1998/06/30 11:59:12 msaitoh Exp $
|
|
|
|
case "$#" in
|
|
2) ;;
|
|
*) echo "usage: `basename $0` fdboot /dev/rfd?a" >&2
|
|
exit 1;;
|
|
esac
|
|
|
|
boot="$1"
|
|
rootdev="$2"
|
|
temp=/tmp/writeboot$$
|
|
|
|
set - `ls -lLgd "$boot"`
|
|
case "$5" in [1-9]*) :;; *) exit 1;; esac
|
|
nblock=`expr \( $5 + 1023 \) / 1024 `
|
|
|
|
trap "rm -f $temp; exit 1" 1 2 3 15
|
|
rm -f $temp
|
|
( dd if="$boot" bs=64 count=1
|
|
dd if="$rootdev" bs=1024 count=1 | dd bs=4 skip=16 count=69
|
|
dd if="$boot" bs=340 skip=1 ) > $temp
|
|
|
|
cat $temp /dev/zero | dd conv=notrunc bs=1024 count=$nblock of="$rootdev"
|
|
rm -f $temp
|