Opening and mounting an original image file

IAmATeaf

VIP Member
VIP Member
Joined
Sep 24, 2004
Messages
4,325
Reaction score
501
Location
Up ya arse!
I didn't really know what to put as the title but I and others have asked how do we open up an image file to see the contents, I remember seeing a thread on this where various people posted about doing this.

Over the last few weeks I have been on and off looking at this, I started out by looking at plugins that make image backups but some of the stuff just went over the top of me leaving me even more confused. So I went back to basics and did some googling and then asked the kind chaps over at the OpenPLi forums who are as helpful as ever.

What I've learned is that the main image file is in ubifs format, previously, years ago images used be in jffs2 format and I have to honest I did spend quite some time looking into how to manage jffs2 images before I realised that I had it wrong.

I installed Ubuntu as a VM on my server and started playing around. I installed mtd-utils which is a package that allows for the handling of Memory Technology Devices. Using the steps below I was then able to actually mount and see the contents of the actual image itself. All of this is done on Terminal session and I used a ViX image to play around with.

Code:
You don't have permission to view the code content. Log in or register now.

The sudo command switches user to the superuser which is required as some the command can't be run as a normal user.

In order to ensure that the image file is in ubifs format you can run the commands below to check the first 3 characters of the image file, this should return UBI

Code:
You don't have permission to view the code content. Log in or register now.

The dd command simply dumps data, if = the input file which is the image file, of = the output file, bs = block size which in this case is 1, count = the number of blocks to dump.
cat simply displays the contents of the named file to the screen.

In order to mount the image you run the following:

Code:
You don't have permission to view the code content. Log in or register now.

mkdir creates a new folder called ubi in /mnt, this only needs to be done the once

The next 4 modprobe commands dynamically loads in the requested library files

The modprobe nandsim command creates a virtual flash device

The dd command copies the image file to the newly created virtual flash device

The ubiattach command, I'll be honest I'm not too sure what it does right now, will have a read later but it seems to create some sort of stub character device that allows access to the block virtual flash device I think, or I could be talking complete shite :)

The mount command then mounts the character device that ubiattach created which points back to the block virtual flash device under the folder /mnt/ubi

And hey presto, if none of the commands have failed if you change to the folder /mnt/ubi you get to see the contents of the image.

Anybody want to have a play then post back your results, all the commands apart from the mkdir are dynamic so if you logoff or switch the machine off then you need to repeat them. I've put the commands into some script files to save me having to type the commands each time.

I'll carry on with this later as I'm checking now how to make changes to the mounted image and then save the changes back. I initially tried simply using the dd command to save the updated contents but that then ends up with a file that's not only a lot larger than the original as dd simply copies the entire virtual device but it's not in UBI format so then can't be mounted using the steps above. I then read that you have to use mkfs.ubifs which I tried but again the resulting file couldn't be mounted. I then had a quick read of the ubinize command but then decided to post on the OpenPLi forums who confirmed that I would need to use ubinize. I've had a play around with this and produced an updated image file but can't test it right this moment to see if it actually works when flashed back to the box but will post back when I've confirmed that it actually works.
 
Last edited:
i just did this with backtrack 5 and have openpli4 extracted
guide works great :)
 
Last edited:
Good stuff guys, with the silence after my original post I thought maybe nobody was interested. :D

I've had a play around with mkfs.ubifs and ubinize and have a modified image with just an extra symbolic link added to test with but I've not yet had the chance to test to see if it can be flashed and if the box then actually boots.

Sent from my GT-I9505 using Tapatalk
 
Back
Top