generalized pixel format handling in 3d pipeline
[bootcensus] / instmbr
1 #!/bin/sh
2
3 dev=$1
4 if [ -z "$dev" ]; then
5         echo 'pass the device on which to install' >&2
6         exit 1
7 fi
8
9 # try to remake boot.img if it's missing
10 if [ ! -f boot.img ]; then
11         make || exit 1
12 fi
13
14 # safety check
15 if mount | grep ^$dev >/dev/null 2>&1; then
16         echo "device $dev seems to be in use." >&2
17         echo "Make sure it's the correct device, and unmount the following filesystems first:" >&2
18         echo "" >&2
19         mount | grep ^$dev >&2
20         exit 1
21 fi
22
23 # copy the existing MBR to preserve the partition table
24 echo "saving copy of existing MBR to preserve partition table ..."
25 dd if=$dev of=/tmp/instmbr.mbr bs=512 count=1 status=none
26 echo "writing boot image to $dev ..."
27 dd if=boot.img of=$dev bs=512 status=none conv=notrunc
28 echo "patching boot sector with saved partition table ..."
29 dd if=/tmp/instmbr.mbr of=$dev bs=1 seek=440 skip=440 count=70 status=none conv=notrunc
30
31 sync