Linux mount android img

How can I open binary Android ROM image files? (.img)

I’m a Windows/Mac/Ubuntu and Android user, so I know what I’m talking about, when I say: How do I open binary image files? (.img) They just won’t open, on any OS… I’m an Android dev… I’m currently working on a ROM, (I also program, using Windows) but I need to extract files, from .img files. I’ve converted them to .ext4.img but they just aren’t recognized by Linux (Definitly not by Android), by Mac OS or Windows. In other words, I can’t open, extract or mount them. Can anyone help me? I’m kinda confused…

the fact that the person with the most useful answer has to first guess what your question really is about, says it all. Please try to ask a more specific and detailed question than ‘How do I open binary image files’.

5 Answers 5

Short Answer is, there are 3 types:

  • Regular filesystem images, that can be mounted with -o loop option
  • YAFFS2 filesystem images, which currently cannot be mounted in Ubuntu and have to be unpacked
  • EXT4 filesystem images that have been further processed by the Android toolchain and need to be converted to regular images with simg2img from the Android toolchain.

So, you have a binary image extracted from an Android device, is that correct?

What does the file command say about the file? Something like this?

$ file system.img system.img: VMS Alpha executable 

That system image is extracted via nandroid from a Samsung Galaxy i7500. Most of those old Android devices used yaffs as a file system. Knowing what you are dealing with greatly helps. (i.e. Which device are we talking about? Where is that image from?)

Converting images into other file systems will only produce garbage at best if you do not have installed support for the file system in question. Unfortunately there is no package for Ubuntu. But that question has already been asked and answered: Create yaffs2 file system on Ubuntu Server 11.10

There is also the possibility that this image is encrypted. But why would someone give you an encrypted image?

Since this is mostly about Android and you call yourself an Android Developer, please read the Android documentation, again. It’s supposed to be all in there. If not ask your question at android.stackexchange.com, XDA-Developers, RootzWiki and the like. And please do not put a ROM on the net for hundreds of people to use unless you REALLY know what you are doing and you read the documentation. Doing it for fame is dangerous and bad for the users!

Источник

Как смонтировать IMG-файл Android под Linux?

В последнее время меня интересует андроид, я хочу изменить и перестроить их. Итак, я сделал несколько тестов на своем XOOM, очень легко что-то зажечь в машине.
Я получил ПЗУ от MOTOROLA (http://developer.motorola.com/products/software/), они — некоторый файл img, и я хочу знать, что внутри, я надеюсь распаковать их. Я попробовал unyaffs, сказал broken img file .
Я пытаюсь установить их, он отлично работает на system.img, и я могу получить файл внутри. Когда я хочу установить userdata.img на mount -o loop userdata.img /mnt/userdata (то же самое, что и system.img ), он сообщает мне mount: you must specify the filesystem type , поэтому я пытаюсь mount -t ext2 -o loop userdata.img /mnt/userdata , он сказал mount: wrong fs type, bad option, bad superblock on. Итак, как получить файл изнутри userdata.img ?

Читайте также:  Partition disks kali linux

system.img: данные файловой системы Linux rev 1.0 ext4, UUID = 57f8f4bc-abf4-0000-675f-946fc0f9f25b (требуется восстановление журнала) (экстенты) (большие файлы)

Голосование за повторное открытие, поскольку речь идет о конкретном формате и конкретном проекте, и эквивалентно любому другому вопросу с практическими рекомендациями на веб-сайте. Откройте дупе по адресу: stackoverflow.com/questions/26137795/…

5 ответов

Сначала вам нужно «распаковать» userdata.img с помощью simg2img , затем вы можете подключить его через устройство цикла.

Я обнаружил, что на этой странице есть все необходимое: (включая готовый исходный код). Работал на Nexus 4 изображения. forum.xda-developers.com/showthread.php?t=1081239

Это для всех, кто хочет распаковать и изменить исходную system.img, которую вы можете использовать при восстановлении.

system.img(например, что вы получаете из изображений google factory) представляет собой разреженную файловую систему с замкнутым контуром ext4.

Он монтируется в/систему вашего устройства. Обратите внимание, что это руководство предназначено для файловой системы ext4, у вас может быть образ системы, например, yaffs2.

способ монтируется на Galaxy Nexus:

«/dev/block/platform/omap/omap_hsmmc.0/by-name/system/system ext4 ro, relatime, барьер = 1, data = ordered 0 0» Необходимые условия:

Linux или виртуальная машина simg2img, make_ext4fs, которые можно скачать здесь http://andwise.net/?attachment_id=406

Процедура:

поместите файл system.img и 2 двоичных файла в один каталог и убедитесь, что двоичные файлы имеют разрешение на выполнение. Часть 1 — монтирование файловой системы

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

Затем у вас есть весь ваш системный раздел в sys, и вы можете изменить все, что хотите, в sys. Например, de-odex apks и фреймворки. Часть 2 — создайте новый flashable образ системы.

sudo./make_ext4fs -s -l 512M -a система new.img sys/ sudo umount sys rm -fr sys

Теперь вы можете просто ввести:

flashboot flash system new.img

Источник

How to mount the android img file under linux?

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 
  • Linux box or virtual machine
  • simg2img and make_ext4fs binaries, which can be downloaded from the linux package android-tools-fsutils
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 
fastboot flash system new.img 

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:

Читайте также:  Linux command from java

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

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.

Источник

Mount Android emulator images

I am trying to analyse Android malware on an emulator with Android 2.1. I want to analyze the files permissions and fingerprints after the execution of the suspicious app. I know, I can use the adb shell to get this information, but I think I can’t trust the information after the execution of e.g. a rootkit. I think the only way to prevent rootkits from hiding is by mounting the images directly or? I have the following files:

ramdisk.img snapshots.img userdata-qemu.img cache.img system.img userdata.img zImage 

How can they be mounted/extracted on Ubuntu (read access is enough)? With unyaffs I can extract the system.img and userdata.img file. simg2img returns «bad magic» for all files. Thanks Alex Edit: userdata-qemu.img works unyaffs2

3 Answers 3

You’ve already answered your own question but I’ll expand a bit. The Android sdk comes with system images, for example:

$ cd android-sdk-linux/system-images/android-15/armeabi-v7a/ $ ls *.img ramdisk.img system.img userdata.img $ cd ~/.android/avd/.avd/ $ ls *.img cache.img sdcard.img userdata.img userdata-qemu.img 

Though, not all images are of the same type:

$ file *.img cache.img: VMS Alpha executable sdcard.img: x86 boot sector, code offset 0x5a, OEM-ID "MSWIN4.1", sectors/cluster 4, Media descriptor 0xf8, sectors 2048000 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 3993, reserved3 0x800000, serial number 0x17de3f04, label: " SDCARD" userdata.img: VMS Alpha executable userdata-qemu.img: VMS Alpha executable 

Since sdcard.img contains no extra partitions, it can be mounted directly without an offset parameter (like -o loop,offset=32256 ):

$ fdisk -l sdcard.img You must set cylinders. You can do this from the extra functions menu. Disk sdcard.img: 0 MB, 0 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System $ sudo mount -o loop sdcard.img /mnt/ 

The other image files which are described as VMS Alpha executable are in fact yaffs2 files. As far as I’m aware they can’t be mounted directly but can be extracted using the two utilities unyaffs or unyaffs2.

$ mkdir extract $ cd extract $ unyaffs ../userdata.img 
$ unyaffs2 --yaffs-ecclayout ../userdata.img . 

Note, there’s another utility called simg2img which can be found in the android source tree under ./android_src/system/extras/ext4_utils/ which is used on compressed ext4 img files. However, if wrongly applied to yaffs2 images it complains with Bad magic .

Читайте также:  Adobe indesign аналоги linux

Источник

Is there a way to mount Android .img to access the AVD (Android Virtual Device) contents?

I feel a bit blind developing on an emulator for Android and not being able to see the file system on the AVD (.img). Is there a way to mount it in Windows or Linux, so that I could at least see the file listing and maybe contents? Bonus if it’s mounted with write permissions as well. Thank you.

6 Answers 6

You can just mount the device in Linux:

sudo mount -o loop ~/.android/avd//sdcard.img

Yes, it is writeable after mounting. (I always do it with the virtual device shut down though, I’m not sure how this would interact with a running emulator.)

w.r.t. running emulator, I can almost guarantee file system corruption if both the emulator and your host system write to the sdcard. In fact, if even one writes, the filesystem will probably look corrupted to the other.

This will give you a root shell (on the emulator)..

Alright, that’s a start (though such a pain in the a$$ on Windows. TAB doesn’t work and it is highly primitive). Is there any editor available on it? I tried vi, emacs, nano.

Looks like cat is my best friend with this primitive system. Also someone suggested installing busybox which has vi in it, which I may try.

$ hdiutil attach ~/.android/avd/Samsung_Nexus_S.avd/sdcard.img 

For Windows, I just ran across the ImDisk Virtual Disk Driver

Install this utility, and you can then mount sdcard.img. There’s a nice tutorial here

Yes, they can be mounted. Under Ubuntu you can mount sdcard.img via vfat and system.img and userdata-qemu.img via yaffs2. See also: «Whats Android file system ??».

Note that the file system yaffs2 is not included in the standard Ubuntu kernel. Thus, in case of Ubuntu, you have to build your own kernel with yaffs2 support before you are able to mount the system.img and the userdata-qemu.img. Alternatively, you can also take a look at the yaffs2utils which allow you to extract files from yaffs2 images or to create new image files. The advantage is that you do not have to build your own kernel for using these tools.

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. I tried mounting and it’s cumbersome, for example if the emulator is running you can’t do it. Plus you would need to mount each image if you want to see all contents.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Оцените статью
Adblock
detector