Last active
December 27, 2019 14:11
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copy data to the end of the partition, needed for BIOS Next186 by Kost. | |
# https://gist.github.com/kost | |
# Example: ./copy_bios_end.sh BIOS_Next186.bin /dev/sdd | |
if [ "$#" -ne 2 ] ; then | |
echo "Usage: $0 <BIOSfile> <device>" >&2 | |
echo "Example: $0 BIOS_Next186.bin /dev/sdd" >&2 | |
exit 1 | |
fi | |
BIOS_INPUT=$1 | |
GIVEN_DEVICE=$2 | |
JUST_DEVICE=$(basename $GIVEN_DEVICE) | |
SIZE_DEVICE=$(cat /proc/partitions| grep -e "\b$JUST_DEVICE\b" | awk '{print $3}') | |
# /sys/block/$JUST_DEVICE/queue/hw_sector_size | |
CLUSTER_SIZE=512 | |
NUM_SECTORS=16 | |
DATA_SIZE=$(expr $NUM_SECTORS \* $CLUSTER_SIZE) | |
START_OFFSET=$(expr $SIZE_DEVICE - $NUM_SECTORS) | |
echo "$GIVEN_DEVICE: $JUST_DEVICE of $SIZE_DEVICE sectors" | |
echo "$GIVEN_DEVICE: offset $START_OFFSET with $DATA_SIZE" | |
echo dd if=$BIOS_INPUT of=$GIVEN_DEVICE seek=$START_OFFSET bs=$CLUSTER_SIZE | |
dd if=$BIOS_INPUT of=$GIVEN_DEVICE seek=$START_OFFSET bs=$CLUSTER_SIZE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment