I have an ubi image file (.ubi) and I want to change a single file from that image (/etc/network/interfaces
to be precise).
How can I change a single file from that ubi image?
I'm using OS X but I have a Ubuntu VM as well.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI have an ubi image file (.ubi) and I want to change a single file from that image (/etc/network/interfaces
to be precise).
How can I change a single file from that ubi image?
I'm using OS X but I have a Ubuntu VM as well.
Ok after a lot of reading, I finally figured it out how to do it on Ubuntu:
1.) Simulate a NAND MT-device with nandsim
modprobe nandsim first_id_byte=... second_id_byte=.. third_id_byte=.. fourth_id_byte=...
2.) Find out the MT-device id
cat /proc/mtd | grep -i "NAND Simulator"
3.) Load UBI kernel module
modprobe ubi
4.) Erase MT-device (you may skip this step)
flash_erase /dev/mtdX 0 0
5.) Flash the UBI image with ubiformat
ubiformat /dev/mtdX -y -f /path/to/ubi -O XXXX -s XXXX
6.) Attach MT-device to UBI with ubiattach
and note the UBI device number
ubiattach -p /dev/mtdX
7.) Mount it with mount
mount -t ubifs ubiX /path/to/mount-point/
8.) Make the changes.
9.) Create UBIFS with mkfs.ubifs
mkfs.ubifs -o ubifs.img -m XXXX -e XXXX -c XXXX -v -r /path/to/mount-point/
10.) Create UBI image with ubinize
ubinize -o final.ubi -p XXXX -m XXXX -s XXXX -v ubinize.cfg
XXXX
= Parameter that is specific to the NAND flash chip used.
ubinize.cfg
looks something like this:
[rootfs]
mode=ubi
image=ubifs.img
vol_name=rootfs
vol_flags=autoresize
vol_type=dynamic
vol_id=0
mtdblockmodprobe
andubimodprobe
wasn't found by modprobe.