[Samsung Galaxy Tab A7 Lite] tom.android:
GSI Handbook. p3

RW a Read-Only GSI with Termux.

-Mod old system , make new one and dirty flash back.

- Example file : https://github.com/ahnet-69/treble_...tageOS-2.8-EOL-20230920-UNOFFICIAL_bgN.img.xz

Why Read Only?

Most devices have small system partition which might even be less than 3GB. To tackle this we enable shared blocks through which we can reduce the image's size to a huge extent.

1. Install termux (from f-droid) not from google play store.

2. Open Termux app and run.

#Open termux app, at the end of command > press Enter.

## Run the below command to setup storage. grant the storage popup if shown.

termux-setup-storage

pkg update

# if download packages smootly -no requires below command.
termux-change-repo

View attachment 6009597

-change repo by press Enter and select new repo near you. Select ok.

( must have no error occurred when update.)

I'm select "Tsinghua Univer".

View attachment 5965647

3. *Where are data stored of termux.?

"/data/data/com.termux/files"

4. install prerequisites.

Setup & Install packages for RW system partition.

Run the below set of command to install prerequisites.

pkg update
pkg install android-tools e2fsprogs
pkg install tsu
pkg install mount-utils
# or
pkg install termux-tools

4.1 Work around

Open termux shell.

# at home directory (-$)

pwd
#output: /data/data/com.termux/files/home

ls
#Output: storage

cd storage

ls
# output: dcim downloads external-1 movies music pictures shared

#Back to home (-$)
cd

# Current Dir
pwd

output: /data/data/com.termux/files/home

4.2 Download GSIs which is read only, usually in compress (.xz) format.

-go into downloads folder. Uncompress the gsi from .xz file and Rename gsi's file name to "system.img"

(-$)> cd storage/downloads

4.3 Get rid of (Remove) unshared blocks ( read-only component )

First we resize the image to fit our new unshared blocks.

-if the image is near to 4GB or higher then do 6GB etc.

-Dont worry we'll reduce its size back later

~/storage/downloads $ resize2fs system.img 4G

Successful resizing.

View attachment 6009663

4.4 Now we finally unshare the blocks!

e2fsck -E unshare_blocks system.img

If it asks you to run a cmd and errors without it. and file size doesnt change then run the cmd and run the above cmd again.

There! the same file you copied is now read/write!

View attachment 6009809

5. Edit System Files

# create directory for work with loop mount .

~/storge/downloads (-$)>mkdir system_mount

5.1 you can even mount the read/write image and make modifications to it

# Mount image file with mount_point

## need to escape the '-'

~/storge/downloads (-$)> sudo mount "-o" loop system.img system_mount

~/storge/downloads (-$)> ls system_mount

View attachment 6009835

5.2 Debloat (reclaim un-use spaces)

#Remove VoltageOS boot animation.

~/storge/downloads (-$)> sudo rm -R system_mount/system/media/bootanimation.zip

#Remove unused SDK

~/storge/downloads $ >
sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v28
sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v28.apex

sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v29
sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v29.apex

sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v30
sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v30.apex

sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v32
sudo rm -R system_mount/system/system_ext/apex/com.android.vndk.v32.apex

# Add new apps from resources folder

~/storge/downloads $ > mkdir resources

sudo cp -R resources/system/priv-app/FileManager system_mount/system/priv-app

sudo chmod -R 755 system_mount/system/priv-app/FileManager

5.3 finish modify

# unmount mount_point

~/storge/downloads $ > sudo umount system_mount

5.4 #final

#Resize to minimum image size after the modification.

~/storge/downloads $ > sudo e2fsck -f system.img

~/storge/downloads $ > sudo resize2fs -M system.img

5.5 #Get current size in MB ( output: 3146 M)

~/storge/downloads $ > du -m system.img

#output: 3146 system.img

5.6

#Resize +200MB (Add more Free spaces)

~/storge/downloads $ > sudo resize2fs system.img 3346M

View attachment 6009937

End of mod System.img

5.7

Transfer RW system.img from Termux to Computer

5.8

#Dirty Flash new RW system.img

#Reboot into fastbootD

adb reboot fastboot

fastboot flash system new-rw-system.img

reboot into system (no wipe)

End of RO to RW (Read-only GSIs)

Note:

May be you need Root File Manager. https://mixplorer.com/beta/

F-droid Termux app. https://f-droid.org/packages/com.termux/

Phantom-process-killer

DISABLE PHANTOM PROCESS KILLER In Android 12 & 13

Disable Phantom Process Killer in android 12 & 13. It’s a background process limiter that kills the app processes using excessive CPU or system resources.

kskroyal.com