Skip to content

Instantly share code, notes, and snippets.

@zglozman
Created April 16, 2017 01:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zglozman/b7c0ed0f183862c931e7c77595ba4c33 to your computer and use it in GitHub Desktop.
Save zglozman/b7c0ed0f183862c931e7c77595ba4c33 to your computer and use it in GitHub Desktop.
Script to mount jffs2 filesystem using mtd kernel modules
if [[ $# -lt 2 ]]
then
echo "Usage: $0 FSNAME.JFFS2 MOUNTPOINT [ERASEBLOCK_SIZE]"
exit 1
fi
if [ "$(whoami)" != "root" ]
then
echo "$0 must be run as root!"
exit 1
fi
if [[ ! -e $1 ]]
then
echo "$1 does not exist"
exit 1
fi
if [[ ! -d $2 ]]
then
echo "$2 is not a valid mount point"
exit 1
fi
if [[ "$3" == "" ]]
then
esize="128"
else
esize="$3"
fi
# cleanup if necessary
umount /dev/mtdblock0 &>/dev/null
modprobe -r mtdram &>/dev/null
modprobe -r mtdblock &>/dev/null
modprobe mtdram total_size=32768 erase_size=$esize || exit 1
modprobe mtdblock || exit 1
dd if="$1" of=/dev/mtdblock0 || exit 1
mount -t jffs2 /dev/mtdblock0 $2 || exit 1
echo "Successfully mounted $1 on $2"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment