summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 03:22:20 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 03:22:20 +0200
commit0ace22d6f88692883584119c64ff010f4cee6738 (patch)
tree6f575f9088dec8bab90943d6c23e174bca183f0a /tools
parentrestructure: rsnix kernel + shell crate + rsdos entry point (diff)
downloadrs-dos-0ace22d6f88692883584119c64ff010f4cee6738.tar.gz
rs-dos-0ace22d6f88692883584119c64ff010f4cee6738.zip
fix(rsdos): organizational changes
Diffstat (limited to '')
-rwxr-xr-xscripts/debug-kernel.py (renamed from tools/debug-kernel.py)0
-rwxr-xr-xscripts/qemu.sh (renamed from tools/qemu.sh)0
-rwxr-xr-xtools/boot-image.sh62
3 files changed, 0 insertions, 62 deletions
diff --git a/tools/debug-kernel.py b/scripts/debug-kernel.py
index c794ad6..c794ad6 100755
--- a/tools/debug-kernel.py
+++ b/scripts/debug-kernel.py
diff --git a/tools/qemu.sh b/scripts/qemu.sh
index b75bed4..b75bed4 100755
--- a/tools/qemu.sh
+++ b/scripts/qemu.sh
diff --git a/tools/boot-image.sh b/tools/boot-image.sh
deleted file mode 100755
index 2592afa..0000000
--- a/tools/boot-image.sh
+++ /dev/null
@@ -1,62 +0,0 @@
1#!/usr/bin/env bash
2# =============================================================================
3# tools/boot-image.sh — Create a bootable disk image from the ESP directory
4#
5# Produces a raw disk image (bootable via UEFI) for dd-ing to a USB stick
6# or attaching to QEMU as a hard disk.
7#
8# Usage:
9# ./tools/boot-image.sh [output.img]
10#
11# Default output: raisernics.img
12# =============================================================================
13set -euo pipefail
14
15SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
16cd "$SCRIPT_DIR"
17
18OUTPUT="${1:-raisernics.img}"
19ESP_DIR="${ESP_DIR:-esp}"
20MBR_SZ=1 # 1 MB reserved at start for GPT/pmbr
21SECTOR_SZ=512
22
23# Rebuild ESP if stale
24make all
25
26if [ ! -d "$ESP_DIR" ]; then
27 echo "ERROR: ESP directory '$ESP_DIR' not found. Run 'make all' first."
28 exit 1
29fi
30
31# Calculate required size: ESP contents + MBR gap + some slack
32ESP_SIZE_MB=$(du -sm "$ESP_DIR" 2>/dev/null | cut -f1 || echo 1)
33TOTAL_MB=$((ESP_SIZE_MB + MBR_SZ + 1)) # +1 MB slack
34
35echo "Creating ${TOTAL_MB} MB disk image: ${OUTPUT}"
36
37# Create empty image with MBR gap
38dd if=/dev/zero of="$OUTPUT" bs=1M count="$TOTAL_MB" status=none 2>/dev/null
39
40# Partition table: single GPT partition, type EFI System (C12A7328-F81F-11D2-BA4B-00A0C93EC93B)
41sgdisk --clear \
42 --new=1:${MBR_SZ}M:0 \
43 --typecode=1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B \
44 --change-name=1:"raisernics" \
45 "$OUTPUT" >/dev/null
46
47# Find partition offset
48PART_START=$(sgdisk --info=1 "$OUTPUT" 2>/dev/null | grep "Partition start sector" | awk '{print $NF}')
49if [ -z "$PART_START" ]; then
50 PART_START=$((MBR_SZ * 1024 * 1024 / SECTOR_SZ))
51fi
52
53# Format as FAT32
54mformat -i "$OUTPUT"@$((PART_START * SECTOR_SZ)) -h 32 -s 32 -t "$((TOTAL_MB * 2))" >/dev/null 2>&1 || true
55
56# Copy the ESP contents onto the partition
57mcopy -i "$OUTPUT"@$((PART_START * SECTOR_SZ)) -s "$ESP_DIR"/* ::/ 2>/dev/null
58
59echo " -> ${OUTPUT} ($(ls -lh "$OUTPUT" | awk '{print $5}'))"
60echo ""
61echo "To write to USB: sudo dd if=${OUTPUT} of=/dev/sdX bs=4M status=progress"
62echo "To test with QEMU: qemu-system-x86_64 -bios <OVMF> -drive file=${OUTPUT},format=raw"