3

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.

  • It seems no difference between ubifs images and images of other fs: unpack image or mount-loop exists image, make some changes and rebuild finally image. I found this link and hope this will be helpful for you - slatedroid.com/topic/3394-extract-and-rebuild-a-ubi-image. – Yurij Goncharuk Mar 5 '18 at 12:33
  • @YurijGoncharuk Thank you. I already had a look at this link and got stuck because mtdblockmodprobe and ubimodprobe wasn't found by modprobe. – d3L Mar 5 '18 at 12:54
  • Oh I see now that this is most likely a formatting error. – d3L Mar 5 '18 at 12:58
2

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=...

List of NAND chip IDs.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.