Skip to content

Instantly share code, notes, and snippets.

@raphaelmerx
Created March 28, 2017 08:19
Show Gist options
  • Save raphaelmerx/7231d0ab5bf052786450a119689f89f4 to your computer and use it in GitHub Desktop.
Save raphaelmerx/7231d0ab5bf052786450a119689f89f4 to your computer and use it in GitHub Desktop.

Extracting a full image from the master tablet

You will need:

  • Ubuntu (or other Linux distribution) computer
  • TWRP image for your tablet model. Search for it on https://twrp.me/Devices/
  • latest firmware for the Android tablet. For example download it from sammobile.
  • The heimdall command. Download it with sudo apt-get install heimdall-flash
  • Binaries for manipulating Android images: ext2simg and sgs4ext4fs.

Getting the master tablet image

Upgrade Android

  • On your computer, download the latest firmware for your tablet. You should end up with folder containing partition images.
  • Put the tablet in download mode: power if off, then press home + volume down + power.
  • Flash the firmware to the tablet: heimdall flash --BOOTLOADER sboot.bin --BOOT boot.img --RECOVERY recovery.img --SYSTEM system.img --CACHE cache.img --HIDDEN hidden.img --RADIO modem.bin
  • Once the tablet boots, do a factory data reset from the settings menu.

Configure

Install and configure apps, adjust the settings, etc.

Flash TWRP

  • Download the TWRP image for your tablet model.
  • Put the tablet in download mode.
  • Flash TWRP to the tablet: heimdall flash --RECOVERY TWRP_sm815.img
  • Power off the tablet.
  • Boot into recovery: hold home + volume up + power until you see the boot screen.

Transfer the partition images to an SD card

  • Insert an SD card into the tablet. The SD card should be bigger than the internal storage of the tablet.
  • In the TWRP menu, go to Mount and check "Micro SDCard"
  • In the TWRP menu, go to Advanced > Terminal.
  • From the TWRP terminal, copy the data partition to the SD card:
dd if=/dev/block/mmcblk0p22 | gzip > /external_sd/userdata.gz
  • Note: you can find which link in /dev/block corresponds to the data partition by running ls -lR /dev/block.

Get the partition images to your computer

  • Insert the SD card in your computer, and transfer userdata.gz
  • gunzip this file: gunzip userdata.gz. You should now have the userdata file, which is a Linux file system.
  • Transform the file to a sparse Android image. From the folder that contains the ext2simg and sgs4ext4fs files, run:
./ext2simg userdata userdata_28bit.img && rm userdata
./sgs4ext4fs --bloat userdata_28bit.img userdata.img && rm userdata_28bit.img
chmod 644 userdata.img

Package the partition images into and Odin file

  • Put the userdata.img file in the same folder as the other system files, then cd into that folder.
  • Use the tar command to combine the created userdata.img with the system files into one Odin flashable image:
chmod 644 *
tar -H ustar -c boot.img cache.img hidden.img modem.bin recovery.img sboot.bin system.img userdata.img > odin_repack.tar 

Done! You can now flash this file using Odin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment