Loop Mounting Android ROM image files

 
 
2011-11-11 14:55:06
 
BEFORE WE BEGIN : THE PROCESS DIFFERS FOR SAMSUNG GALAXY SII IMAGES - SEE THIS GUIDE
So.. you've managed to obtain an img/rfs/img.ext3 file and you're wanting to get at the files inside. Well, in order to do this, you're going to need a couple of things, as outlined below. 
- A Linux Installation (VM is fine) - See our guide on 'How to set up a Linux Virtual Machine' 
- Your phone
- ADB (From the Android SDK) - See our guide on setting up ADB

Method

1. First of all, you need to establish what type of file system you have, as this process will differ slightly depending on the file system. In order to do this, connect your phone to the computer with USB debugging enabled. Open a command prompt (if windows) or terminal (if Linux/Mac) and type the following, pressing enter after each line:
adb shell 
cat /proc/mounts
Then look for the line which should look a little like this:
/dev/block/stl9 /system rfs ro,relatime,barrier=1,data=ordered 0 0
This line tells us a lot, but specifically to what we're doing, it tells us that /system is an RFS partition, mounted on stl9. If you were to need to data dump that entire filesystem right now, this is how you'd do it:
adb shell
su
dd if=/dev/block/stl9 of=/sdcard/system.rfs bs=4096
After doing that, you'd have system.rfs on your SDcard, ready for the next step!
 
2. Using the example above, our filesystem type is RFS. Now you need to ensure you're in Linux, with the file available. You can either do this entirely by command line, or by doing a bit of dragging and dropping mixed with some command line, so I will make those points clear as we go along. 
Let's assume you have terminal open, and you're in the same directory as your RFS file. Type:
sudo mkdir temp
You guessed it; we just made a directory called temp. You can do this manually with right click, create new folder (of course). 
sudo mount -o loop system.rfs /temp
Wow. That's actually all there is to mounting it. Manually open the temp directory now, and you will see the contents of system.rfs. Now, you can either copy all that to a new folder and zip it up ready for an update.zip ROM, or you can modify it directly to flash it with ODIN or similar!
Let's say you do want to modify it... move on to step 3!
 

OPTIONAL ADDITIONAL INFORMATION

3. Let's say you want to copy a modified build.prop file in there. You can't edit the one in there directly, so copy and paste it somewhere else, then make your changes. When you're done, to copy it to the mounted system, use:
sudo cp build.prop /temp/
That will overwrite the file. Now let's say you want to delete an application from the rom
sudo rm /temp/app/Browser.apk
That will remove the application. Now.. let's say you want to remove an entire directory
sudo rmdir /temp/etc/init.d
That will remove the entire directory. 
 
Now... when you've finished making your changes, to unmount the image file, simply do:
sudo umount /temp
 
All done!
blog comments powered by Disqus







PaypalFacebookRSSTwitterGoogle +