limine/qloader2-install

34 lines
887 B
Plaintext
Raw Normal View History

2020-01-21 09:13:50 +03:00
#!/bin/sh
set -ex
2020-01-21 09:13:50 +03:00
2020-04-07 08:24:19 +03:00
if [ -z "$2" ]; then
echo "Usage: $0 <path to qloader2 binary> <device> [stage2 start sector]"
2020-01-21 09:13:50 +03:00
exit 1
fi
# Variables.
2020-04-07 08:24:19 +03:00
DEVICE="$2"
2020-01-21 09:13:50 +03:00
MBR="$(mktemp)"
BINARY_SECT_SRC="$(mktemp)"
BINARY_SECT_BIN="$(mktemp)"
2020-04-07 08:24:19 +03:00
QLOADER2="$1"
2020-01-21 09:13:50 +03:00
if [ -z "$3" ]; then
STAGE2_SECT=1
else
STAGE2_SECT="$3"
fi
echo "dd $STAGE2_SECT" > "$BINARY_SECT_SRC"
nasm "$BINARY_SECT_SRC" -f bin -o "$BINARY_SECT_BIN"
2020-01-21 09:13:50 +03:00
# Copy the loader to the device.
dd if="$DEVICE" of="$MBR" bs=1 count=64 skip=446
dd if="$QLOADER2" of="$DEVICE" bs=512 count=1 conv=notrunc
dd if="$QLOADER2" of="$DEVICE" bs=512 count=63 skip=1 seek=$(( $STAGE2_SECT )) conv=notrunc
dd if="$BINARY_SECT_BIN" of="$DEVICE" bs=1 count=4 seek=$(( 0x1b0 )) conv=notrunc
dd if="$MBR" of="$DEVICE" bs=1 count=64 seek=446 conv=notrunc
2020-04-07 08:24:19 +03:00
rm "$MBR" "$BINARY_SECT_SRC" "$BINARY_SECT_BIN"