Created
April 16, 2017 01:30
-
-
Save zglozman/b7c0ed0f183862c931e7c77595ba4c33 to your computer and use it in GitHub Desktop.
Script to mount jffs2 filesystem using mtd kernel modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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