Skip to content

Instantly share code, notes, and snippets.

@Ludo6431
Created August 22, 2011 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ludo6431/1161395 to your computer and use it in GitHub Desktop.
Save Ludo6431/1161395 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd "`dirname $0`"
BASESRC="fsroot"
IMGFILE="fsimg.img"
IMGSIZE="256" # in MB
TMPDIR="`mktemp -d`"
# <-- verifying mandatory things
if [ ! -d ${BASESRC} ]
then
echo "Can't find the input directory : ${BASESRC}"
exit 1
fi
# -->
# <- create a new blank FAT partition
echo "Creating ${IMGSIZE}MB FAT16 image..."
dd if=/dev/zero of=${IMGFILE} bs=1048576 count=${IMGSIZE}
mkdosfs -F16 ${IMGFILE}
echo "OK"
# -->
# <-- mount it
echo -n "Mounting image..."
sudo mount -o loop -o uid=1000 ${IMGFILE} ${TMPDIR}
echo "OK"
# -->
# <-- copy files in it
echo -n "Copying files..."
cp -R ${BASESRC}/* ${TMPDIR}/
echo "OK"
# -->
# <-- unmount it
echo -n "Unmounting image..."
sudo umount ${TMPDIR}
rmdir ${TMPDIR}
echo "OK"
# -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment