-
Notifications
You must be signed in to change notification settings - Fork 8
/
grubinst
26 lines (20 loc) · 796 Bytes
/
grubinst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/bash
printUsage() {
echo "Usage:"
echo -e "\t`basename $0` img-file grub-stage1 grub-stage2"
echo -e "\te.g. `basename $0` 80m.img /usr/local/src/grub-0.97/stage1/stage1 /usr/local/src/grub-0.97/stage2/stage2"
echo
}
if [ $# -ne 3 ]; then
printUsage
exit 1
fi
img_file = $1
stage1 = $2
stage2 = $3
dd if=boot/hdboot.bin of=$img_file seek=`echo "obase=10;ibase=16;\`egrep -e '^ROOT_BASE' boot/include/load.inc | sed -e 's/.*0x//g'\`*200" | bc` bs=1 count=446 conv=notrunc
dd if=boot/hdboot.bin of=$img_file seek=`echo "obase=10;ibase=16;\`egrep -e '^ROOT_BASE' boot/include/load.inc | sed -e 's/.*0x//g'\`*200+1FE" | bc` skip=510 bs=1 count=2 conv=notrunc
dd if=$stage1 of=$img_file bs=1 count=446 conv=notrunc
dd if=$stage2 of=$img_file bs=512 seek=1 conv=notrunc
echo
exit 0