REPIT
Lanchon REPIT
A Device-Only Data-Sparing Repartitioning Tool For Android
DEVICES – DOWNLOADS – GALAXY S2 – XDA THREAD
CHANGELOG – Powered by Flashize.
General Information (All Devices)
WHAT IS THE PROBLEM ?
many older devices, especially the ones originally released before emulated storage was available, were partitioned by the OEM in ways that hinder the installation and use of newer Android versions. for example, the Galaxy S2 GT-I9100 comes with a 0.5 GiB /system partition that is unable to fit CM 13.0 and Open GApps, even if you choose the pico version. though its flash is typically a generous 16 GiB, the stock /data partition is only 2 GiB which means that with today’s ART you run out of space to install applications in no time. it also comes with a 0.5 GiB /preload partition that goes unused on custom ROMs.
people have typically solved this by repartitioning. on Samsung devices this is a tricky process that involves the use of download mode, a Windows PC, Windows device drivers that support the device’s download mode, a ‘pirated’ proprietary PC software called Odin, the right PIT and other files, and correct configuration. (a free software alternative to Odin called Heimdall works on many devices and is cross platform and supports Linux PCs, but the rest of the hurdles remain.) the procedure has potential for hard-bricking if the wrong files are flashed. after repartitioning, all affected partitions must be reflashed or formatted anew, a procedure that many get wrong. and of course, all data in the affected partitions gets wiped (typically the complete device) making this an ultra-inconvenient affair.
WHAT IS REPIT ?
REPIT is a simple, safe, device-only, data-sparing, and easily portable repartitioning tool for Android devices:
- device-only: just flash a zip file in recovery to repartition the device.
- simple: rename the zip file before flashing to configure your choice of partition sizes, file systems, wipes, etc.
-
safe:
- a correctly ported REPIT can never hard-brick your device.
- before starting, REPIT checks for the existence of all the tools that will be needed for the task at hand, verifies that the current partition layout passes several sanity checks, checks and fixes all the involved file systems, and verifies that the new partition layout will meet its sanity checks too. REPIT performs a dry-run of the complete repartitioning process to detect possible problems early on.
- if REPIT fails, it will nonetheless try to restore your device to a working in-between state. you can solve the blocking issue and REPIT again towards your goal, or otherwise REPIT back to your original configuration. (keeping the in-between state is not recommended as it usually involves ‘wasted’ unpartitioned space.)
- my estimate is that between 500 to 1000 users already used REPIT for ‘major’ changes on the i9100 and no incidents of data loss were reported. (note: these are very stale numbers dating from March 2016, when REPIT was still in its infancy.)
- easily portable: a simple configuration file is all that is needed to port REPIT to a new device.
you can look at the log of a demo run to get a feel for what REPIT can do. in this run on a Galaxy S2 it grows the /system and /data ext4 partitions to 1 and 6 GiB respectively, it wipes and shrinks the unused /preload partition to a minimum size, and it adjusts the size of the internal /sdcard vfat partition to occupy whatever space is left. REPIT plans, orders and undertakes a safe series of partition resize and move operations to reach its goal, all the while keeping and eye on details such as alignments and retaining the data present in the /system, /data and /sdcard partitions.
LIMITATIONS
- REPIT requires TWRP 2 or TWRP 3. some recoveries unnecessarily hold device or partition locks during flashing, which prevents all repartitioning tools from working (parted, fdisk, gdisk, and of course REPIT). unfortunately the recoveries bundled with CM 11, 12.0, 12.1 and 13.0 display this issue and are incompatible. recent TWRP 2.8.7.* and 3.0.0.* recoveries comply with this requirement, but only when flashing zips from /tmp. (REPIT will automatically copy itself to /tmp if it detects locks, to help you relaunch from there.)
- REPIT does not support encrypted phones.
- REPIT will cause data loss if the repartitioning process is externally interrupted. plug into a power source!
HOW TO REPIT
- if you think your data is invaluable then treat it as such: make a backup!
- get TWRP running on your device.
- make sure your battery is mostly charged.
- get the zip for your device from the link below.
- rename it to express your desired configuration (see below).
- PLUG INTO A POWER SOURCE. this operation might take a long time and must not be interrupted.
- flash the zip locally on the phone. (if you want to sideload instead, please see the note below.)
finally, go get a coffee or two. do not, under any circumstance, interrupt this script !!!
in case the script fails to start:
- if the script cannot unmount all partitions, it will copy itself to the /tmp directory and ask you to flash it a second time from there.
- if it still fails to unmount all partitions, or if it fails to lock the eMMC (‘unable to reread the partition table’), then unplug the device from USB hosts such as PCs, reboot TWRP, and reflash the script immediately after boot up. (you may actually need to reflash twice, the second time from ‘/tmp’.) do not do anything after booting up and before flashing! in particular, do not connect the device to a PC or USB host as this might auto-mount the sdcard via MTP, and do not mount the sdcard as USB mass storage via TWRP’s UI. in some rare cases you might need to use TWRP’s UI to disable MTP before rebooting and to manually unmount all partitions before flashing the script from ‘/tmp’.
- if locking issues remain, your phone is probably encrypted; this script is not compatible with encrypted phones.
if you want to sideload:
- sideloading conceals the filename from the device, and thus filename-based configuration will not work.
-
to sideload you need to add a file called ‘flashize/repit-settings’ to the zip containing the full intended filename, or otherwise just the configuration part of it. for example, a file containing
-system=1G
is enough (the-
is required). note that your recovery might require you to resign the zip after that change. - otherwise you can add the file directly to the device before sideloading, for example via adb push. in that case it must be named ‘/tmp/repit-settings’.
HOW TO CONFIGURE
configure the script by renaming the zip file before flashing it.
valid zip names: <prefix>[-partition1=<conf>][-partition2=<conf>]...<suffix>
valid partition <conf>
values: [<size>(G|M)|same|min|max][+[keep|wipe][+[ext4|vfat|f2fs|swap|raw]]]
the defaults are device-dependent. please look inside your device’s configuration file for more information. for configuration samples please see the i9100 section below.
Partition Data
-
keep
: retain the data in the partition. if the partition needs to be moved or resized, this option usually makes the operation significantly slower, even if the partition is mostly empty. -
wipe
: wipe the partition. always wipe partitions that are empty or carry data that you do not care about: it will make REPIT faster and will result in less wear on the flash memory.
Partition Sizes
-
same
: do not alter the size of this partition. -
min
: make this unused partition a minimum yet formattable size (typically 8 MiB, but device-dependent). -
max
: make this partition as big as possible (at most one partition per ‘heap’ can have its size set to ‘max’). -
<size>(G|M)
: fractional number followed by a size unit expressing the desired partition size. the unit is eitherG
for GiB orM
for MiB. this value gets rounded to the nearest acceptable discreet value. the size granularity is device-dependent, but typically set to match the device-dependent partition alignment (which typically is 1 or 4 MiB).