1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/makesd-format Sat May 25 01:19:39 2019 +0200
1.3 @@ -0,0 +1,54 @@
1.4 +#!/bin/sh
1.5 +
1.6 +# Support formatting of partitions.
1.7 +
1.8 +PROGNAME=`basename "$0"`
1.9 +THISDIR=`dirname "$0"`
1.10 +
1.11 +COMMON="$THISDIR/makesd-common"
1.12 +FSCK="/sbin/fsck"
1.13 +MKFS="/sbin/mkfs"
1.14 +MKSWAP="/sbin/mkswap"
1.15 +
1.16 +. "$COMMON"
1.17 +
1.18 +
1.19 +
1.20 +# format <device> <type>
1.21 +
1.22 +format()
1.23 +{
1.24 + PARTNUM=$1
1.25 + TYPE=$2
1.26 + DEVICE="${DEV}${PARTNUM}"
1.27 +
1.28 + if [ ! -e "$DEVICE" ] ; then
1.29 + echo "$DEVICE does not exist and therefore cannot be formatted." 1>&2
1.30 + return 1
1.31 + fi
1.32 +
1.33 + case "$DEVICE" in
1.34 + ( fat )
1.35 + "${MKFS}.vfat" -F 32 -n "boot" "$DEVICE" && "${FSCK}.vfat" -a -y "$DEVICE"
1.36 + ;;
1.37 + ( ext* )
1.38 + "${MKFS}.$TYPE" "$DEVICE" && "${FSCK}.$TYPE" -y "$DEVICE"
1.39 + ;;
1.40 + ( swap )
1.41 + "$MKSWAP" "$DEVICE"
1.42 + ;;
1.43 + esac
1.44 +}
1.45 +
1.46 +
1.47 +
1.48 +# Obtain details of the selected device.
1.49 +
1.50 +check_device
1.51 +
1.52 +PARTNUM=1
1.53 +
1.54 +while read_fields ; do
1.55 + format "$PARTNUM" "$TYPE"
1.56 + PARTNUM=$(($PARTNUM + 1))
1.57 +done