aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-02-03 12:11:37 +0100
committerlonkaars <loek@pipeframe.xyz>2024-02-03 12:11:37 +0100
commitb4054ac324b5d9ddb10236db0563d424fa9c4017 (patch)
treee5d32c52c909d7071707af3ede2041917c7afff3 /util
parent2b2cb626b527606436b6d7903407b7dbf66d9671 (diff)
fully automatic sd card partitioning and formatting
Diffstat (limited to 'util')
-rwxr-xr-xutil/part25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/part b/util/part
new file mode 100755
index 0000000..cf9abe5
--- /dev/null
+++ b/util/part
@@ -0,0 +1,25 @@
+#!/bin/sh
+SDCARD_DISK="$1"
+if ! [ -n "$SDCARD_DISK" ] ; then
+ cat << EOF >&2
+ERROR: could not automatically detect an SD card. Please insert an SD card of
+approx. 8GB, or manually set SDCARD_DISK in ./makefile
+EOF
+ exit 1
+fi
+if ! [ -w "$SDCARD_DISK" ] ; then
+ echo "ERROR: cannot not write to $SDCARD_DISK. Are you root?" >&2
+ exit 1
+fi
+if ! [ -b "$SDCARD_DISK" ] ; then
+ echo "ERROR: $SDCARD_DISK does not appear to be a block device" >&2
+ exit 1
+fi
+
+set -e
+
+sfdisk "$SDCARD_DISK" << 'EOF'
+label: dos
+,64M,0C,*
+,+ ,83,
+EOF