From 8e3d87cf45fa4f3660baffa09a08cabc4e9d92e1 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 30 Mar 2023 09:14:15 -0500 Subject: [PATCH] Add flash.sh script This script simplifies the process of erasing the target disk and flashing `sdcard.img` onto it. --- flash.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 flash.sh diff --git a/flash.sh b/flash.sh new file mode 100755 index 0000000..c5ffbb6 --- /dev/null +++ b/flash.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# vim: set sw=4 ts=4 sts=4 et : + +dev=$(readlink -f "$1") +wipefs -fa "${dev}" +pv images/sdcard.img \ + | dd of="${dev}" bs=1M conv=sparse oflag=sync +sync; sync; sync +sleep 1 +for p in /sys/class/block/${dev##*/}/*/partition; do + [ -f "${p}" ] || continue + case $(cat "${p}") in + 1|2) + ;; + *) + p=${p%/*} + wipefs -fa /dev/${p##*/} + ;; + esac +done