molecules/scripts/oxnas/disk_create

48 lines
948 B
Bash
Executable File

#!/bin/sh
[ "x$1" == "x"] && {
echo "Usage: $0 hard-disk-device"
exit 1
}
# uncomment line below and set to the correct disk
disk=$1
workarea="."
stage1File=$workarea/stage1.wrapped
ubootFile=$workarea/u-boot.wrapped
ubootenvFile=$workarea/u-boot.env
perl <<EOF | dd of="$disk" bs=512
print "\x00" x 0x1a4;
print "\x00\x5f\x01\x00";
print "\x00\xdf\x00\x00";
print "\x00\x80\x00\x00";
print "\x00" x (0x1b0 -0x1a4 -12 );
print "\x22\x80\x00\x00";
print "\x22\x00\x00\x00";
print "\x00\x80\x00\x00";
EOF
if [ -f $stage1File ];then
echo "Writing stage 1"
dd if=$stage1File of="$disk" bs=512 seek=34
fi
if [ -f $ubootFile ];then
echo "Writing uboot"
dd if=$ubootFile of="$disk" bs=512 seek=154
fi
echo "Generating uboot env"
pushd $workarea/u-boot-env
./creatext2loadenv.sh
popd
if [ -f $ubootenvFile ];then
echo "Writing uboot env"
dd if=$ubootenvFile of="$disk" bs=512 seek=558
fi