blob: e08f37c9e7e8c9678398aa4daf29e6b5056300a9 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/bin/sh
2
3if [ $# != 2 ]; then
4 echo not enough args
5 echo usage: $0 file device
6 exit 1
7fi
8
9if [ ! -f $1 ]; then
10 echo input file does not exist
11 exit 1
12fi
13
14if [ ! -b $2 ]; then
15 echo output device does not exist
16 exit 1
17fi
18
19UNAME=`uname`
20
21case `uname` in
22 Darwin)
23 set -v
24 sudo diskutil unmount $2 || exit 1
25 sudo dd if=$1 of=$2 bs=2048 seek=1 || exit 1
26 sudo diskutil eject $2 || exit 1
27 ;;
28 Linux)
29 set -v
30 sudo umount $2
31 sudo dd if=$1 of=$2 bs=2048 seek=1 || exit 1
32 sudo sync
33 ;;
34esac