Распаковка img android linux

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?)

Читайте также:  Change package manager linux

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!

Источник

How to extract boot.img?

I am trying to see the content in a boot.img file from an Android image. I googled and found this article to extract system.img , but it doesn’t work for boot.img . When trying to do this for boot.img , it is showing the following:

Invalid sparse file format at header magi Failed to read sparse file 
  1. If so, Is there any other method to extract boot.img ?
  2. If not, what is the problem for not extracting boot.img ?

4 Answers 4

boot.img is a small(ish) file that contain two main parts.

Unpack boot.img :

It contains the following steps:

wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android-serialport-api/android_bootimg_tools.tar.gz 
tar xvzf android_bootimg_tools.tar.gz 

We can extract the ramdisk also, using the following command

gunzip -c boot.img-ramdisk.gz | cpio -i 

After changing the files, we can again pack those files as boot.img using mkbootimg

Читайте также:  Network topology mapper linux

Getting the same error for step 3 on Mint 17 here. Tried running them by sudo and after chmod 755 to no avail.

Fix for: «unpackbootimg command not found», you are running 32bit binary on a 64 bit machine without 32bit dependencies. Install them with «apt-get install gcc-multilib»

Install abootimg (available as a package, for example in Debian/Ubuntu and openSUSE).

To extract (boot|recovery).img :

$ abootimg -x (boot|recovery).img $ ls boot.img bootimg.cfg initrd.img zImage 

To repack (boot|recovery).img after modifying one of bootimg.cfg , zImage or initrd.img :

abootimg --create (boot|recovery).img -f bootimg.cfg -k zImage -r initrd.img 

This project is not maintained and did not work with my boot.img file, however the answer from @cfig worked.

boot.img is not a compressed filesystem image like system.img . It is read by the bootloader, and contains little more than a kernel image and a ramdisk image.

Some binary distribution ship the kernel and ramdisk images separately. In that case you don’t need to do anything with boot.img , just regenerate a new one with mkbootimg .

If you need to extract information from a boot.img , try split_bootimg (by William Enck, via the Android wiki).

You can use the following tool to extract and re-pack Android boot image

$ git clone https://github.com/cfig/Android_boot_image_editor.git 

copy your boot.img to the cloned git repository. Run:

First time run will need to download necessary libs from internet, be patient. You can get the contents at «build/unzip_boot/», like this:

build/unzip_boot/ ├── bootimg.json (boot image info) ├── kernel ├── second (2nd bootloader, if exists) ├── boot.img.avb.json (AVB only) └── root 

Источник

How would I extract a .img file

I am trying to extract a .img file (hard disk image with with Chromium OS on it). I have not been able to find any way to do this other than mounting it but that is not usable because it shows up as multiple drives so I cannot repack it.

Читайте также:  Настройка репозиториев kali linux

5 Answers 5

You do not extract an .img ; you mount it. Example:

mkdir /mnt/ChromeOS mount -o loop image.img /mnt/ChromeOS/ 

and this will list the contents:

Mind that .img can also be zipped. If that is the case (unlikely though) you also need to gunzip it.

This does not work if the img contains multiple partitions, at least it fails for me. Using kpartx works instead.

You can use kpartx — create device maps from partition tables

Install the package kpartx and run

kpartx [-a | -d | -l] [-v] wholedisk 

DESCRIPTION

This tool, derived from util-linux’ partx, reads partition tables on specified device and creates device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion.

EXAMPLE

To mount all the partitions in a raw disk image:

You can clone from the image file to a drive

You can clone from the .img [image] file to a drive, for example a USB pendrive, that is big enough. This is the basic intention of the file.

You can use mkusb for that purpose. It works with compressed image files too (when compressed with gzip and xz ), .img.gz and .img.xz files.

After the cloning you will see the partitions for example with

sudo lsblk -f sudo lsblk -m sudo parted -ls 

After cloning you can mount and unmount the partition(s) on the drive ‘as usual’.

Источник

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