[tool] ANDROID_IMG_REPACK_TOOLS

Search This thread

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,583
Ctrl-Freak

Why are you making rebuilding correct created file system via make_ext4fs and updating permissions all files that normally created?
You can, for edit, to use only converters simg2img and ext2simg, and to change permissions only new added files...

$ simg2img system.img system.raw
$ mkdir system
$ sudo mount -t ext4 -o loop system.raw system
editing
$ ext2simg -v system.raw system.new.img
 
Last edited:

Ctrl-Freak

Senior Member
Oct 15, 2013
164
139
Ctrl-Freak

Why are you making rebuilding correct created file system via make_ext4fs and updating permissions all files that normally created?
You can, for edit, to use only converters simg2img and ext2simg, and to change permissions only new added files...

$ simg2img system.img system.raw
$ mkdir system
$ sudo mount -t ext4 -o loop system.raw system
editing
$ ext2simg -v system.raw system.new.img

Understood. (I had found the ext2simg syntax within your Moto G tool, and it worked without error...)

I have a very weak understanding of selinux permissions, and I was hoping that after I 'tweak' /system that I could apply the permissions automatically with the -S file_contexts switch. I should have spent all of this time learning selinux...

Thanks!!
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,583
Understood. (I had found the ext2simg syntax within your Moto G tool, and it worked without error...)

I have a very weak understanding of selinux permissions, and I was hoping that after I 'tweak' /system that I could apply the permissions automatically with the -S file_contexts switch. I should have spent all of this time learning selinux...

Thanks!!
eg I assign selinux permissions to the mounted image so:
I'm create small script:
Code:
#!/bin/bash


echo set file contexts

ch_con() {
		sudo chcon -v u:object_r:system_file:s0 $1
}
ch_con system/bin/.ext/.su
ch_con system/bin/ddexe
ch_con system/xbin/su
ch_con system/xbin/daemonsu
ch_con system/etc/install-recovery.sh
ch_con system/etc/init.d/99SuperSUDaemon
ch_con system/etc/.installed_su_daemon
ch_con system/app/Superuser.apk
ch_con system/lib/libdummy.so
ch_con system/etc/permissions/platform.xml
echo
 

Ctrl-Freak

Senior Member
Oct 15, 2013
164
139
eg I assign selinux permissions to the mounted image so:
I'm create small script:
Code:
#!/bin/bash


echo set file contexts

ch_con() {
		sudo chcon -v u:object_r:system_file:s0 $1
}
ch_con system/bin/.ext/.su
ch_con system/bin/ddexe
ch_con system/xbin/su
ch_con system/xbin/daemonsu
ch_con system/etc/install-recovery.sh
ch_con system/etc/init.d/99SuperSUDaemon
ch_con system/etc/.installed_su_daemon
ch_con system/app/Superuser.apk
ch_con system/lib/libdummy.so
ch_con system/etc/permissions/platform.xml
echo

Thanks a million!

---------- Post added at 03:39 PM ---------- Previous post was at 03:29 PM ----------

Another question.

I started with a stock motorola system.img file that is 935,103,928 bytes.

I fastboot flashed that to my device, rooted, then used dd to make an image of the /system ext4 partition:
Code:
dd if=/dev/block/platform/msm_sdcc.1/by-name/system of=/sdcard/Download/system_orig.img

To test, I used ext2simg without any more changes:
Code:
ext2simg -v system_orig.img system_new.img

Now system_new.img is 1,434,486,540 bytes, but all I added was su.

How does motorola shrink the sparse file? (Maybe simg2simg ??)


Thanks again.
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,583
Yes, simg2simg can reduce file size by splitting into several parts, but it is usually not necessary, fastboot can flash and in this state
 
  • Like
Reactions: Ctrl-Freak

bovirus

Senior Member
Oct 7, 2007
2,154
795
I didn't know.
As for rpevious version that I reported I saw the new tag on Android build and I think that was different from 5.1.0:r1.
 

purian23

Senior Member
Jan 11, 2009
980
1,363

Thank you!

Have you ever encountered this? Really odd, my system is fully up to date, all build tools etc installed.
It doesn't matter if I enter sudo or go full root, the same exists.

Code:
purian23@Samsung ~/android_img_repack_tools $ git checkout android-5.1.0_r3Already on 'android-5.1.0_r3'
Your branch is up-to-date with 'origin/android-5.1.0_r3'.
purian23@Samsung ~/android_img_repack_tools $ ./configure
bash: ./configure: Permission denied
purian23@Samsung ~/android_img_repack_tools $
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,583
Thank you!

Have you ever encountered this? Really odd, my system is fully up to date, all build tools etc installed.
It doesn't matter if I enter sudo or go full root, the same exists.

Code:
purian23@Samsung ~/android_img_repack_tools $ git checkout android-5.1.0_r3Already on 'android-5.1.0_r3'
Your branch is up-to-date with 'origin/android-5.1.0_r3'.
purian23@Samsung ~/android_img_repack_tools $ ./configure
bash: ./configure: Permission denied
purian23@Samsung ~/android_img_repack_tools $
You must give for "configure" executable permissions...
 
  • Like
Reactions: purian23

pigeon

Senior Member
May 10, 2003
89
2
Australia
pigeond.net
Nexus 7 2013

Hi all,

Has anyone here managed to customize/repack a working system.img for the Nexus 7 (2013)?

I can create my own system.img file with the usual simg2img, loop mount, mkuserimg.sh/make_ext4fs combo , but if I flash it to the device (fastboot flash system mysystem.img), it fails to boot. It simply stucks at the boot Google logo. If I flash the original unmodified system.img though, it is booting.

I used the system.img from the 5.0.2 LRX22G factory image from https://developers.google.com/android/nexus/images, and I am using branch android-5.0.2_r1 in the android_img_repack_tools git repo.

Thanks!
 

Top Liked Posts

  • There are no posts matching your filters.
  • 118
    [tool] ANDROID_IMG_REPACK_TOOLS
    &
    Android_ROM_IMG_Repacker



    android_img_repack_tools is a kit utilites for unpack/repack android ext4 and boot images in LINUX & WINDOWS


    includes binaries:
    mkbootfs
    simg2simg
    make_ext4fs
    make_ext4fs_def
    mkbootimg
    ext2simg
    simg2img
    img2simg
    sgs4ext4fs - Chainfire's tool
    unpackbootimg - CyanogenMod tool
    mkbootimg_tools - xiaolu

    Android_ROM_IMG_Repacker




    sources used:
    https://android.googlesource.com
    https://github.com/CyanogenMod/android_system_core.git
    https://github.com/Chainfire/sgs4ext4fs





    how to make:

    Preparation OS:

    Code:
    sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind libreadline6-dev gcc-multilib g++-multilib libc6-dev x11proto-core-dev libx11-dev libz-dev gawk texinfo automake libtool cvs libsdl-dev

    Dowload repo:

    Code:
    git clone https://github.com/ASdev/android_img_repack_tools

    Choose branch, for example:

    Code:
    cd android_img_repack_tools
    git checkout android-4.4.4_r2.0.1

    Building tools:

    Code:
    chmod +x configure
    ./configure

    will download source from android git repositories

    Code:
    make

    will compille binaries: mkbootfs simg2simg make_ext4fs mkbootimg sgs4ext4fs unpackbootimg ext2simg img2simg simg2img

    Code:
    make clean

    will remove binaries

    Code:
    make clear

    wiil remove sources

    credits:
    android.googlesource
    Chainfire
    CyanogenMod


    go to the repository

    Already have a branch:
    android-2.3.7
    android-4.0.4
    android-4.1.1
    android-4.1.2
    android-4.2.2
    android-4.3
    android-4.4.2
    android-4.4.3
    android-4.4.4
    android-5.0.0
    android-5.0.2
    android-5.1.0
    android-5.1.1
    android-6.0.0
    android-6.0.1


    Usage:


    Code:
    ## Converting sparse flashing system.img from flashing android sparse img to ext4 img
    
    $ simg2img system.img system.raw.img
    ## or all parts of sparse img
    $ simg2img system.img* system.raw.img
    
    ## Mounting ext4 img for edit
    
    $ mkdir system_mnt
    $ mount -t ext4 -o loop system.raw.img system_mnt
    Code:
    ## Creating new android sparse img for flashing (android 2.3.6-4.2)
    
    $ mkuserimg.sh -s system_mnt system_new.img ext4 ./system [size partition MB for example 1024M]
    ## or
    $ make_ext4fs -s -l 1024M system_new.img system_mnt
    
    more
    
    $ mkuserimg.sh -s system system.img ext4 /system [size partition MB for example 1024M] file_contexts
    Code:
    ## Converting ext4 img to sparse img for flashing (android 4.3-etc)
    
    $ ext2simg -v system.raw.img system_new.img
    Code:
    ## Changing sparse img header size from 28bit to 32bit (for Samsung Exynos Octa)
    
    $ sgs4ext4fs --bloat system_new.img system_32bit.img

    Code:
    ## Remove Moto extra header... (for Motorola G-series, making after unsparse img)
    
    $ mv system.raw.img system.moto.img
    $ dd if=system.moto.img of=system.raw.img ibs=131072 skip=1





    ANDROID_IMG_REPACK_TOOLS_CYGWIN WINDOWS

    ANDROID_IMG_REPACK_TOOLS_CYGWIN is a kit utilites for unpack/repack android ext4 and boot images in WINDOWS


    mkbootfs.exe
    simg2simg.exe
    make_ext4fs.exe
    mkbootimg.exe
    ext2simg.exe
    img2simg.exe
    simg2img.exe
    sgs4ext4fs.exe - Chainfire's tool
    unpackbootimg.exe - CyanogenMod tool


    Already have a branch:
    android-4.1.2
    android-5.1.0
    android-5.1.1
    android-6.0.0
    android-6.0.1

    Already have a .exe:
    WINDOWS REPO






    XDA:DevDB Information
    android_img_repack_tools, Tool/Utility for the Android General

    Contributors
    A.S._id

    Version Information
    Status: Testing

    Created 2014-01-06
    Last Updated 2016-04-17
    36
    [tool] ANDROID_IMG_REPACK_TOOLS - CYGWIN EXE

    Android_img_repack_tools - cygwin exe
    33
    Android ext4fs ROM editor

    Android_ROM_IMG_Repacker

    It is automatise for android_img_repack_tools for Linux & Windows CYGWIN

    Instructions:


    credits:
    android.googlesource
    @Chainfire
    @Chenglu
    @xpirt

    Added v.2.1

    * Configure:
    Auto choice OS for compilation android_img_repack_tools

    * MOUNT ext4 img:
    Auto converting sparse to raw img
    Auto find magic sparse img and remove vendor extra header
    Auto choice OS for mount or extract raw img

    * MAKE_EXT4FS - new img ANDROID permission:
    Auto extract 'file_contexts' from recovery.img (if exist)

    * EXT2SIMG - raw to sparse
    Auto choice chunk header (28/32 bytes)

    Added v.2.2

    * Fixed some bugs
    26
    Odin3 ROM Editor

    Reserved
    9
    added branches:
    android-2.3.7_r1
    android-4.0.4_r2.1
    android-4.2.2_r1.2
    android-4.3_r3.1
    android-4.4.2_r1