[T-Mobile Samsung Galaxy S7 Guides, News, & Discuss] kevin71246:
This is a complete working guide on how to extract the /system partition from a Samsung S7 FW/OTA package using Windows

(This is the same package one might flash to their phone with ODIN.) You can get this FW/OTA package from sites like Samsung-Firmware.org & SamMobile.com. It is very likely this works (or parts of it duct-taped together :)) on other Phone models,etc, but I vouch that this guide works on the Samsung S7. Please chime in if it works on other models & brands!

Intro:

I found a LOT of guides similar to this, but couldn't get any to work with the Samsung S7 packages! And there are MANY different versions of the tools I mention below, many not working! So be sure to use the tool versions I post below. Over much time, it was a tiny step with each new attempt until I finally got it...& wanted to share!

Purpose:

Why would anyone want to do this? If you're reading this thread and don't know the answer to that, then I'm confused :) But I'll answer anyway - What is the purpose of this thread?

You would want to do this because you're a ROM Developer and don't want to have to go through the time & trouble of installing an OTA, then do a dd/cat to get the system image, etc. (With this method you don't even need a phone, just a PC!)

You are using a custom ROM, but want a stock app; for example the custom ROM you're using has the Google Dialer/Phone app builtin, but you prefer the stock Samsung Phone. Doing the steps outlined here will yield a "system" folder in Windows that you can simply navigate to /system/app or /system/priv-app and copy over the apk to your phone and install it! (via ADB or phone File manager app, etc). Obviously not all apks will work. Or maybe you want the libraries from another phone OTA package in order for an apk to work, and so on...

You are just curious what's in the /system partition for an OTA package!

Tools:

7-Zip

LZ4

simg2img: "Clone or download"->Download ZIP

Ext2Explore (Same as Ext2Read)

Guide:

Download FW/OTA (TMB-G930TUVU4CRI2.zip) from SamMobile website (or whereever)

Use 7zip to extract TMB-G930TUVU4CRI2.zip to a folder

Use 7zip to extract AP_G930TUVU4CRI2*.tar.md5 to a folder (ignore "There is no correct record at end of archive" error)

Use lz4 to extract system.img.ext4.lz4 -> system.img.ext4

lz4 system.img.ext4.lz4​

Extract simg2img_win-master.zip -> \simg2img_win-master\

Copy system.img.ext4 to \simg2img_win-master\ folder

Rename system.img.ext4 -> system.img

Use simg2img_win-master to convert system.img -> system.ext4.img

Double-click convert.bat (or run in cmd prmpt) (This will take a few minutes)​

Create new folder to save contents in, eg: "C:\System"

Use ext2explore to mount system.ext4.img: Open ext2explore->File->Open Image->Select system.ext4.img

Click Save icon->Save to your new folder, eg: "C:\System"

Wait for it to extract. Once complete, enjoy!

Links & Useful Resources:

Tmobile Versions: https://support.t-mobile.com/docs/DOC-30276

Search Keywords:

(This section is here so this thread comes up in searches for the many errors I came across while trying to get this to work in both Windows & Linux. That's right! I tried in both OSs and actually got it to work first in Windows... & yet to get it to work in Linux!)

- losetup /dev/loop2 /media/sf_Share/system.img.ext4 ->warning file does not fit into 512-byte sector; the end of the file will be ignored

- mount /dev/loop2 /mnt/mysystem2 -> mount: /mnt/mysystem2: cant read superblock on /dev/loop2

- mount -t ext4 /media/system.img /mnt/mysystem6 -> wrong fs type, bad option, bad superblock on /dev/loop6, missing codepage or helper program, or other error

fsck /media/system.img -> ext2fs_open2: Bad magic number in super-block

fsck.ext2: Superblock invalid, trying backup blocks...

fsck.ext2: Bad magic number in super-block while trying to open ...

The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate suberblock: ...