1 #!/bin/sh 2 3 # Support formatting of partitions. 4 5 PROGNAME=`basename "$0"` 6 THISDIR=`dirname "$0"` 7 8 COMMON="$THISDIR/makesd-common" 9 FSCK="/sbin/fsck" 10 MKFS="/sbin/mkfs" 11 MKSWAP="/sbin/mkswap" 12 13 . "$COMMON" 14 15 16 17 # format <device> <type> 18 19 format() 20 { 21 PARTNUM=$1 22 TYPE=$2 23 DEVICE="${DEV}${PARTNUM}" 24 25 if [ ! -e "$DEVICE" ] ; then 26 echo "$DEVICE does not exist and therefore cannot be formatted." 1>&2 27 return 1 28 fi 29 30 case "$DEVICE" in 31 ( fat ) 32 "${MKFS}.vfat" -F 32 -n "boot" "$DEVICE" && "${FSCK}.vfat" -a -y "$DEVICE" 33 ;; 34 ( ext* ) 35 "${MKFS}.$TYPE" "$DEVICE" && "${FSCK}.$TYPE" -y "$DEVICE" 36 ;; 37 ( swap ) 38 "$MKSWAP" "$DEVICE" 39 ;; 40 esac 41 } 42 43 44 45 # Obtain details of the selected device. 46 47 check_device 48 49 PARTNUM=1 50 51 while read_fields ; do 52 format "$PARTNUM" "$TYPE" 53 PARTNUM=$(($PARTNUM + 1)) 54 done