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 DEVICE=$1 22 TYPE=$2 23 24 if [ ! -e "$DEVICE" ] ; then 25 echo "$DEVICE does not exist and therefore cannot be formatted." 1>&2 26 return 1 27 fi 28 29 case "$DEVICE" in 30 ( fat ) 31 "${MKFS}.vfat" -F 32 -n "boot" "$DEVICE" && "${FSCK}.vfat" -a -y "$DEVICE" 32 ;; 33 ( ext* ) 34 "${MKFS}.$TYPE" "$DEVICE" && "${FSCK}.$TYPE" -y "$DEVICE" 35 ;; 36 ( swap ) 37 "$MKSWAP" "$DEVICE" 38 ;; 39 esac 40 } 41 42 43 44 # Obtain details of the selected device. 45 46 check_device 47 48 PARTNUM=1 49 50 while read_fields ; do 51 DEVICE="${DEV}${PARTNUM}" 52 format "$DEVICE" "$TYPE" 53 PARTNUM=$(($PARTNUM + 1)) 54 done