Browse Source

mkdisk.sh: ensure at least 32MB for FAT image

K. Lange 2 years ago
parent
commit
d2b8145361
1 changed files with 9 additions and 2 deletions
  1. 9 2
      util/mkdisk.sh

+ 9 - 2
util/mkdisk.sh

@@ -7,17 +7,23 @@ IN=$2
 
 OUTDIR=`dirname $1`
 
+# Calculate required space
 SPACE_REQ=$(du -sb "$DIR/../fatbase" | cut -f 1)
-
 let "SIZE = ($SPACE_REQ / 1040000)"
-echo $SIZE
 
+# Minimum size
+if [ $SIZE -lt 32 ]; then
+    SIZE=32
+fi
+
+# Use more sectors-per-cluster for larger disk sizes
 if [ $SIZE -gt 128 ]; then
     SPC=4
 else
     SPC=1
 fi
 
+# Create empty FAT image
 rm -f $OUT
 mkdir -p cdrom
 fallocate -l ${SIZE}M $OUT || dd if=/dev/zero bs=1M count=${SIZE} of=$OUT
@@ -25,6 +31,7 @@ mkfs.fat -s $SPC -S 2048 $OUT
 
 #echo "Turning $IN into $OUT"
 
+# Add files
 for i in $(find $IN)
 do
     if [[ $i == $IN ]]; then