[tool] ANDROID_IMG_REPACK_TOOLS

Search This thread

TopTongueBarry

Senior Member
Nov 15, 2012
98
97
HELP - Trying root SM-T235 running 4.4.2

As posted in the SM-T235 thread:
Used Krusader and Odin_3_ROM_Editor to:
Add the SU binary to system.img in /system/bin
Add the Superuser.apk to system.img in /system/app
Add busybox to the system.img in /system/app

Followed the instructions in the Odin_3_ROM_Editor thread to repack supplying the proper partition size.

Flashed using Odin 3.09
Completes flashing in Odin successfully,
Reset

The SM-T235 boots up to the animated Samsung logo and that's as far as it gets. never really hangs, but the animation continues endlessly.

After reflashing with the factory NE8 image, the device fails to connect to the mobile network. WiFi connectivity seems to work fine.
EDIT: After second restart Mobile network working fine on factory non-root image again.

Any idea why the device sits at the Samsung animation logo after flashing the rooted factory image.

TTB
 
Last edited:

rogerscrack

Senior Member
May 8, 2011
121
12
39
Buenos Aires
OnePlus 6
Open Krusader but Use "Krusader with admin permission" (ctrl+shift+k) to move or add this files.
You also have to give permissions that apply, to know what these are, check the package UPDATE-SuperSU.zip Chainfire for your tablet model and try again.
 

fy1128

Member
Nov 11, 2012
16
1
Gaozhou
www.laifuying.com
Thanks for the awesome tools, it is very helpful. i love itso much. And i get some questions here, what does Dtim.recovery use for ? i got it in the offical firmware, but when i repacked it with your tool, i didn't found it any more. Does it mean something ? or just forget it.
 

M_J_Nazari

Inactive Recognized Developer
Jul 14, 2010
1,545
2,577
35
Bushehr
pda-planet.com
Hi @A.S._id

thank you for this great tool

i have problem with this tool while compiling make_ext4fs

Code:
Building make_ext4fs...
/tmp/cchvqLaL.o: In function `main':
make_ext4fs_main.c:(.text+0x530): undefined reference to `load_canned_fs_config'
make_ext4fs_main.c:(.text+0x563): undefined reference to `canned_fs_config'
/tmp/ccnvcPNT.o: In function `ext4_parse_sb_info':
ext4_utils.c:(.text+0xd9d): undefined reference to `ext4_parse_sb'
./libselinux.a(label_file.o): In function `compile_regex':
label_file.c:(.text+0x73d): undefined reference to `pcre_compile'
label_file.c:(.text+0x790): undefined reference to `pcre_study'
./libselinux.a(label_file.o): In function `closef':
label_file.c:(.text+0x1874): undefined reference to `pcre_free'
label_file.c:(.text+0x1891): undefined reference to `pcre_free_study'
./libselinux.a(label_file.o): In function `lookup_common':
label_file.c:(.text+0x1c66): undefined reference to `pcre_exec'
label_file.c:(.text+0x1cf7): undefined reference to `pcre_exec'
collect2: error: ld returned 1 exit status
make: *** [make_ext4fs] Error 1

Linux ubuntu 14.04.2 64bits
tested on 4.4.4 and 5.0 and 5.1 branches , all of them reports me the same error.

how can i fix this issue?

extra info:
the log when installing components.
Code:
Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
Note, selecting 'zlib1g-dev' instead of 'libz-dev'
Note, selecting 'libsdl1.2-dev' instead of 'libsdl-dev'
automake is already the newest version.
bison is already the newest version.
build-essential is already the newest version.
cvs is already the newest version.
flex is already the newest version.
g++-multilib is already the newest version.
gawk is already the newest version.
gcc-multilib is already the newest version.
gperf is already the newest version.
libesd0-dev is already the newest version.
libncurses5-dev is already the newest version.
libreadline6-dev is already the newest version.
libtool is already the newest version.
libx11-dev is already the newest version.
texinfo is already the newest version.
valgrind is already the newest version.
zip is already the newest version.
zlib1g-dev is already the newest version.
libwxgtk2.8-dev is already the newest version.
curl is already the newest version.
git-core is already the newest version.
gnupg is already the newest version.
libc6-dev is already the newest version.
libsdl1.2-dev is already the newest version.
x11proto-core-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

GCC Version
Code:
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

best regards.
 
Last edited:

M_J_Nazari

Inactive Recognized Developer
Jul 14, 2010
1,545
2,577
35
Bushehr
pda-planet.com
some warning on 4.4.4 branch
Code:
Building libselinux...
removed ‘avc.o’
removed ‘avc_internal.o’
removed ‘avc_sidtab.o’
removed ‘booleans.o’
removed ‘callbacks.o’
removed ‘canonicalize_context.o’
removed ‘checkAccess.o’
removed ‘check_context.o’
removed ‘compute_av.o’
removed ‘compute_create.o’
removed ‘context.o’
removed ‘deny_unknown.o’
removed ‘disable.o’
removed ‘enabled.o’
removed ‘fgetfilecon.o’
removed ‘freecon.o’
removed ‘fsetfilecon.o’
removed ‘get_initial_context.o’
removed ‘getenforce.o’
removed ‘getfilecon.o’
removed ‘getpeercon.o’
removed ‘init.o’
removed ‘label.o’
removed ‘label_android_property.o’
removed ‘label_file.o’
removed ‘lgetfilecon.o’
removed ‘load_policy.o’
removed ‘lsetfilecon.o’
removed ‘mapping.o’
removed ‘policyvers.o’
removed ‘procattr.o’
removed ‘sestatus.o’
removed ‘setenforce.o’
removed ‘setfilecon.o’
removed ‘stringrep.o’
*******************************************
Building zlib_host...
*******************************************
Building libmincrypt_host...
*******************************************
Building mkbootimg...
core/mkbootimg/mkbootimg.c: In function ‘main’:
core/mkbootimg/mkbootimg.c:236:9: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
     sha = SHA_final(&ctx);
         ^
*******************************************
Building mkbootfs...
*******************************************
Building libsparse_host...
*******************************************
core/libsparse/output_file.c: In function ‘write_sparse_skip_chunk’:
core/libsparse/output_file.c:354:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘int64_t’ [-Wformat=]
   error("don't care size %llu is not a multiple of the block size %u",
   ^
*******************************************
Building simg2img...
core/libsparse/output_file.c: In function ‘write_sparse_skip_chunk’:
core/libsparse/output_file.c:354:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘int64_t’ [-Wformat=]
   error("don't care size %llu is not a multiple of the block size %u",
   ^
*******************************************
Building simg2simg...
core/libsparse/output_file.c: In function ‘write_sparse_skip_chunk’:
core/libsparse/output_file.c:354:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘int64_t’ [-Wformat=]
   error("don't care size %llu is not a multiple of the block size %u",
   ^
*******************************************
Building img2simg...
core/libsparse/output_file.c: In function ‘write_sparse_skip_chunk’:
core/libsparse/output_file.c:354:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘int64_t’ [-Wformat=]
   error("don't care size %llu is not a multiple of the block size %u",
   ^
*******************************************
Building make_ext4fs...
*******************************************
Building ext2simg...
*******************************************
Building unpackbootimg...
removed ‘libmincrypt_host.a’
removed ‘libselinux.a’
removed ‘libsparse_host.a’
removed ‘libz.a’
*******************************************
Building sgs4ext4fs...
*******************************************
 
Last edited:

M_J_Nazari

Inactive Recognized Developer
Jul 14, 2010
1,545
2,577
35
Bushehr
pda-planet.com
thank you @A.S._id
another question, it seems created images have not correct permissions on files, how can i fix this issue please?


finally i made the system.img from my phone and it boots correctly , but there is no permissions for some files like su.
I tried another way to make system.img from linux but no success too , as i checked the problem it caused by file permission problem, it seems many files have not correct permissions, phone stays on samsung logo ( 2nd logo ), tried to catch the logcat, but i cant access too, this is the message, any idea please?
Code:
M:\>adb logcat
- exec '/system/bin/sh' failed: Permission denied (13) -
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,575
thank you @A.S._id
another question, it seems created images have not correct permissions on files, how can i fix this issue please?
for fix this problem you must look update script from supersu installer UPDATE-SuperSU-v2.46.zip\META-INF\com\google\android\update-binary
or to ask chainfire...
 

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,575
@M_J_Nazari

So! I installed Ubuntu 14.04.2 LTS x62 into virtual machine VirtualBox, has done all the steps from the first message and received no errors ...
Probably you've done something wrong ...
 
Last edited:

M_J_Nazari

Inactive Recognized Developer
Jul 14, 2010
1,545
2,577
35
Bushehr
pda-planet.com
Hi
for fix this problem you must look update script from supersu installer UPDATE-SuperSU-v2.46.zip\META-INF\com\google\android\update-binary
or to ask chainfire...

when i made system.img from my phone, SU was installed correctly, i just have problem when i restored the image from odin.


@M_J_Nazari

So! I installed Ubuntu 14.04.2 LTS x62 into virtual machine VirtualBox, has done all the steps from the first message and received no errors ...
Probably you've done something wrong ...

the issue has fixed since i updated java version to 7.0 , now i have no any errors, just some warning from gcc. i just ignore them.

allready i have problem on setting correct permissions, anyone has any idea please?

thank you
 
Last edited:

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,575
@M_J_Nazari

some ?

you can already install supersu via cwm recovery or cf-auto-root for your device, after this, you can make archive tar with root files for extracting into mounted system img...
 

M_J_Nazari

Inactive Recognized Developer
Jul 14, 2010
1,545
2,577
35
Bushehr
pda-planet.com
@M_J_Nazari

some ?

you can already install supersu via cwm recovery or cf-auto-root for your device, after this, you can make archive tar with root files for extracting into mounted system img...

already i did it,
i didi all modification on rom, then created an image from my phone.
Code:
su
make_ext4fs -s -l 1500M -a system /sdcard/system.img /system
1500MB is for S4mini 9192

i installed system.img alone from odin, shall i install all images at the same time? (e.g. kernel, recovery, modem ...) could it be an issue?
 
  • Like
Reactions: .MoHaMaD

A.S._id

Inactive Recognized Developer
Sep 21, 2010
1,211
2,575
@M_J_Nazari

I'll thinking, you has problem not with permission of the files, but SELinux contexts of this files, if you want to use your custom files and a stock kernel, you mast to add contexts permissions for this custom files. For this you must before making system.img enter command into terminal
$ restorecon -v
 
  • Like
Reactions: M_J_Nazari

Ctrl-Freak

Senior Member
Oct 15, 2013
164
139
Howdy. I was hoping to get a little help using make_ext4fs to make a fastboot flashable image of a lollipop ext4 image of /system.

I've compiled make_ext4fs from several different android branches, and always get one of two different errors:

This first error looks like make_ext4fs is not using regex to locate the following from file_contexts:
Code:
/system(/.*)?           u:object_r:system_file:s0
Code:
sudo repack3/android_img_repack_tools/make_ext4fs -s -S file_contexts -l 1610612736 -a system  system_new.img sys1/
Creating filesystem with parameters:
    Size: 1610612736
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 6144
    Label:
    Blocks: 393216
    Block groups: 12
    Reserved block group size: 95
error: build_directory_structure: cannot lookup security context for /system/app


and the other error is below. (I tried simply sorting the file_contexts file.)
Code:
sudo repack2/android_img_repack_tools/make_ext4fs -s -S file_contexts -l 1610612736 -a system  system_new.img sys1/
Creating filesystem with parameters:
    Size: 1610612736
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 6144
    Label:
    Blocks: 393216
    Block groups: 12
    Reserved block group size: 95
error: xattr_assert_sane: BUG: extended attributes are not sorted

phone: 2013 motox
make_ext4fs works fine if I leave out the -S parameter.
I've googled, but cannot find any answers.
I've attached the file_contexts file.

Thanks!
 

Attachments

  • file_contexts.zip
    6.7 KB · Views: 48
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 115
    [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
    34
    [tool] ANDROID_IMG_REPACK_TOOLS - CYGWIN EXE

    Android_img_repack_tools - cygwin exe
    32
    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
    25
    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
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone