Skip to content

Instantly share code, notes, and snippets.

@alangregory
Forked from naodesu/gist:10620506
Last active September 13, 2023 02:57
Show Gist options
  • Save alangregory/0191334ed6eaf92e3656 to your computer and use it in GitHub Desktop.
Save alangregory/0191334ed6eaf92e3656 to your computer and use it in GitHub Desktop.
How to mount ubifs image in Linux.
# $UBIFS is ubifs image file
# make sure $IMAGE is a ubifs image file
blkid $(IMAGE)
$(IMAGE): ... TYPE="ubifs"
# size of created mtd is 256.0 MiB
modprobe nandsim first_id_byte=0x2c second_id_byte=0xda third_id_byte=0x90 fourth_id_byte=0x95
flash_erase /dev/mtd0 0 0
ubiformat /dev/mtd0
modprobe ubi
ubiattach -m 0
# set $(SIZE) to value more than size of the ubifs filesystem
ubimkvol /dev/ubi0 -N volname -s $(SIZE)
ubiupdatevol /dev/ubi0_0 $(UBIFS)
mount /dev/ubi0_0 /mnt
JFFS2
dd if="$1" of=/dev/mtdblock0 || exit 1
mount -t jffs2 /dev/mtdblock0 $2 || exit 1
convert endian
jffs2dump -r -e /tmp/converted.img -b /tmp/original.img
# (taken from: http://lists.infradead.org/pipermail/linux-mtd/2013-October/049229.html )
@alangregory
Copy link
Author

What are arguments $1 and $2 in this gist?
$1 is the image file, $2 is the local folder to mount it

What is the unit of $SIZE ?
-s volume size volume size in bytes, kilobytes (KiB) or megabytes (MiB)

What does the JFF2 part have to do with the block above ?
2 different sections, one for image in ubifs format and another for jffs2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment