How to mount the android img file under linux? [closed]
Asked Answered
F

5

47

Recently, I'm interest in the android rom, I want to change and rebuild them.
So, I did some test on my XOOM, it's very easy to flash something into the machine.
I got some ROM from MOTOROLA (http://developer.motorola.com/products/software/), they are some img file, and I want to know what's inside, I hope to unpack them.

I tried the unyaffs, it said broken img file.
I try to mount them, it works great on the system.img, and I can get the file inside.

When I want to mount userdata.img by mount -o loop userdata.img /mnt/userdata (the same as system.img), it tells me mount: you must specify the filesystem type so I try the mount -t ext2 -o loop userdata.img /mnt/userdata, it said mount: wrong fs type, bad option, bad superblock on...

So, how to get the file from the inside of userdata.img?

Flann answered 29/12, 2011 at 4:6 Comment(4)
I have tried other file system, it return the same error.Flann
system.img: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-0000-675f-946fc0f9f25b (needs journal recovery) (extents) (large files)Flann
I use file to get the img info as above.Flann
Voting for reopen, since this is about a specific format and a specific project, and equivalent to any other howto question on the website. Open dupe at: #26138295Coffee
S
41

See the answer at: http://omappedia.org/wiki/Android_eMMC_Booting#Modifying_.IMG_Files

First you need to "uncompress" userdata.img with simg2img, then you can mount it via the loop device.

Selfacting answered 12/3, 2012 at 22:37 Comment(2)
I have found that page has everything needed: (including source ready to be built). Worked on Nexus 4 images. forum.xda-developers.com/showthread.php?t=1081239Shaggy
also mentioned on a github page github.com/EpicAOSP/make_ext4/blob/master/READMELusatia
A
30

I have found a simple solution: http://andwise.net/?p=403

Quote

(with slight adjustments for better readability)


This is for all who want to unpack and modify the original system.img that you can flash using recovery. system.img (which you get from the google factory images for example) represents a sparse ext4 loop mounted file system. It is mounted into /system of your device. Note that this tutorial is for ext4 file system. You may have system image which is yaffs2, for example.

The way it is mounted on Galaxy Nexus:

/dev/block/platform/omap/omap_hsmmc.0/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0

Prerequisites:

  • Linux box or virtual machine
  • simg2img and make_ext4fs binaries, which can be downloaded from the linux package android-tools-fsutils

Procedure:

Place your system.img and the 2 binaries in one directory, and make sure the binaries have exec permission.

Part 1 – mount the file-system

mkdir sys
./simg2img system.img sys.raw
sudo mount -t ext4 -o loop sys.raw sys/

Then you have your system partition mounted in ‘sys/’ and you can modify whatever you want in ‘sys/’. For example de-odex apks and framework jars.

Part 2 – create a new flashable system image

sudo ./make_ext4fs -s -l 512M -a system new.img sys/
sudo umount sys
rm -fr sys

Now you can simply type:

fastboot flash system new.img

Amari answered 21/4, 2012 at 12:28 Comment(3)
simg2img (and make_ext4fs) is also available in the android-tools-fsutils package on Debian and Ubuntu.Nerte
Hi, using this method I've encountered an error saying "Invalid sparse file format at header magi Failed to read sparse file"Advertise
After installing android-tools-fsutils, I didn't need to copy simg2img and make_ext4fs to the same directory as system.img. They're both in my PATH and work fine from there.Mither
T
2

In Android file system, "system.img" and "userdata.img" are VMS Alpha executable. "system.img" and "userdata.img" have the contents of /system and /data directory on root file system. They are mapped on NAND devices with yaffs2 file system. Now, yaffs2 image file can not be mounted on linux PC. If you can, maybe you got some rom that not packed in yaffs2 file system. You can check those rom file by execute the command:

file <system.img/userdata.img>

If it show "VMS Alpha executable" then you can use "unyaffs" to extract it.

Tredecillion answered 3/4, 2012 at 3:23 Comment(2)
Possibly true for Samsung devices, but not for Nexus devices.Nerte
Type 'adb shell mount' to check what filesystems the Android device thinks these .img files are: I wasted time trying to unyaff an ext4 image...Contradistinguish
P
0

Another option would be to use the File Explorer in DDMS (Eclipse SDK), you can see the whole file system there and download/upload files to the desired place. That way you don't have to mount and deal with images. Just remember to set your device as USB debuggable (from Developer Tools)

Prismatoid answered 15/1, 2013 at 11:34 Comment(0)
H
-2

I have found that Furius ISO mount works best for me. I am using a Debian based distro Knoppix. I use this to Open system.img files all the time.

Furius ISO mount: https://packages.debian.org/sid/otherosfs/furiusisomount

"When I want to mount userdata.img by mount -o loop userdata.img /mnt/userdata (the same as system.img), it tells me mount: you must specify the filesystem type so I try the mount -t ext2 -o loop userdata.img /mnt/userdata, it said mount: wrong fs type, bad option, bad superblock on...

So, how to get the file from the inside of userdata.img?" To load .img files you have to select loop and load the .img Select loop

Next you select mount Select mount

Furius ISO mount handles all the other options loading the .img file to your /home/dir.

Hurleigh answered 17/12, 2015 at 0:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.