• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[SCRIPT][LINUX] Mount System as read write (Android 10+)

Status
Not open for further replies.
Search This thread

lebigmac

Senior Member
Jan 31, 2017
873
507
This Linux-only version is pretty much deprecated at this point. Please use the BRAND NEW UNIVERSAL VERSION instead! Thank you.

Ladies and gentlemen. Let me present to you my very first release here at the XDA forums:
Welcome to:
makeSystemRW v1.04
automated bash script by lebigmac for Android 10 and above
Creation date: February 2021
Updated: March 2021


Requirements:
  • LINUX ONLY!
  • Android 10 or newer
  • This version only supports devices with super image.
    Check if you have super by running
    ls -Alg /dev/block/by-name
  • phone must be rooted + bootloader unlocked + 10 GB free space on phone
  • at least 20 GB free space on computer for dumping data
  • adb and fastboot commands should be in your $PATH environment variable
I'm not 100% sure if this is a necessary requirement but I also disabled dm-verity and verification on my device just in case by simply booting into TWRP and then executing these 2 commands:
Code:
adb disable-verity

adb shell avbctl disable-verification

Description: A script for all Android power users that wish to make their read-only Android 10+ system read-write-able again to remove bloatware and make more thorough customizations to their device.

In a nutshell this is what the script is doing:

  • dumps your existing super image to your pc
  • extracts the embedded read-only partitions (system, vendor, product, etc...)
  • makes these partitions read-write-able
  • joins everything back together to new flashable super.img
  • flashes it to device
User data is not affected.

Usage:
Simply call the script from the shell.
Optional arguments (replace x with your custom value) :

  • in=x : With this flag you can specify an existing super.img and skip the entire dumping of the super image process. Here you can use the super_original.img which you dumped earlier with makesysrw or the official super.img from your downloaded firmware. You probably have to unsparse the official super.img first using the included simg2img tool for superunpack to recognize it properly. If omitted, makesysrw will dump super image from phone to ./super_original.img
  • out=x : With this argument you can specify the output path. If omitted, default output value is ./super_fixed.img
  • size=x : With this parameter you can specify the extra free space (in megabytes) that will be added to each partition. If omitted, default extra size is 0 (shrink to minimum)
Examples:
Code:
# Run this command if you're first time user:
# Specify the extra free space in megabytes for each partition:
./makesysrw.sh size=100

# Plug an existing raw super image into the script like this:
./makesysrw.sh in=./super_original_raw.img size=100

# Specify both the input file as well as the output destination:
./makesysrw.sh in=./super_original_raw.img out=./super_fixed.img size=100

# For unsparsing the (sparse) super.img from your phone manufacturer's firmware you can do:
./tools/bin/simg2img ./super_sparse.img ./super_raw.img

NOTE: I did not come up with all this by myself. After searching for a solution for countless days without success, going even as far as learning hex editing - I coincidentally came across a couple of very interesting threads burried deep inside the new forum interface where this technique has been described and discussed by various enthousiasts (links can be found below in the credits section). So I take absolutely no credit for the underlying core mechanisms of the script. I'm only the amateur who put it all together into a compact script so that everybody can enjoy an Android system that's read-write-able again. Just like it used to be in Android 9 or earlier. Before this annoying 'shared_blocks feature' was implemented.

Credits: Big thanks to @munjeni for allowing me to use his amazing superunpack tool instead of the default lpunpack. Source code can be found here.
Also big thanks to @Brepro1 without your awesome tutorial guiding me I couldn't have created this script.
Thanks @AndyYan your
interesting thread also helped me a lot for automating the script especially the lpdump part.
More thanks @gabrielfrias for his
helpful comment
Thanks @YOisuPU and of course @topjohnwu for discovering the 'shared_blocks feature'
Thanks @bynarie for making available his
otatools package! A part of it is now bundled with the archive

Disclaimer: This is open source software and is provided as is without any kind of warranty or support whatsoever. By using and viewing this software you agree to the following terms:
Under no circumstances shall the author be held responsible for any damages or negative consequences that may arrise from the (inappropriate) use of this software.
All responsibility and liability lies with the end-user. You hereby agree not to abuse this software for illegal purposes. Use this software at your own risk!

Please feel free to improve this script as you see fit (as long as you don't add anything malicious)
and make sure to post your feedback, suggestions and improvements in the official thread right here.


3.jpg


2.jpg


5.jpg


1.jpg


0.jpg

Mod Edit: Download link removed
Please click my like button below if you like it! Thanks​
 
Last edited by a moderator:

lebigmac

Senior Member
Jan 31, 2017
873
507
Are you serious it actually works on your device? lmao
Congratulations. You are the first person to try it :D

The script pretty much does the same thing as your awesome tutorial describes.
Without your tutorial this script would not exist so thank you very much for making it available!
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
873
507
Simply extract the downloaded archive and open a terminal shell in the extracted folder by right clicking inside it and select Open in Terminal

Then run this command if you're running it for the first time
Code:
./makesysrw.sh size=100

or this command if you already have your raw super.img file
Code:
./makesysrw.sh in=./existing_super_image.img size=100

If you can't launch the script file make sure it is executable on your computer.
 
Last edited:

Techguy777

Senior Member
Simply extract the downloaded archive and open a terminal shell in the extracted folder by right clicking inside it and select Open in Terminal

Then run this command if you're running it for the first time
Code:
./makesysrw.sh

or this command if you already have your super.img file
Code:
./makesysrw.sh existing_super_image.img

If you can't launch the script file make sure it is executable on your computer.


Thanks I'm supposed to run the shell from my pc terminal or on the android device?
 

Techguy777

Senior Member
Sorry I see its for linux users. Ok now im getting it I have ubuntu 14 on my hard drive but I need to reinstall the grub menu because I deleted it or something. I have a s10 lite and tab S6 I would love to make the writable on the system so does this make a backup or dump of your system and than you flash it? Do you guys think thatll work on one ui 2.5 and im on lineage 18.1 on my s10 lite
 

lebigmac

Senior Member
Jan 31, 2017
873
507
Well in a nutshell this is what the script is doing:
  • dumps your existing super image to your pc
  • extracts the embedded read-only partitions (system, vendor, product, etc...)
  • makes these partitions read-write-able
  • joins everything back together to new flashable super.img
  • flashes it to device
User data is not affected.

The script is telling you exactly what's happening under the hood. You can also check out the source code if you have any doubts.

Yes this version of the script is supposed to be run on a Linux computer.
Please report back if it works for you or not.

Lineage OS? Doesn't that have a read-write-able system by default? In that case the script will likely fail.
Please keep in mind this script has been developed on Android 10 (Xiaomi X3 NFC) with a system that's read-only.
 
Last edited:

Techguy777

Senior Member
Well in a nutshell the script dumps your existing super image to your pc.
And then modifies the files to make everything read write able and then flashes back to the device. User data is not affected.

The script is telling you exactly what's happening under the hood. You can also check out the source code if you have any doubts.

Yes the script is supposed to be run on the computer

Please report back if it works for you or not.
Lineage OS? Doesn't that already come with read-write-able system by default? In that case the script will likely fail.
Please keep in mind this script has been developped on Android 10 MIUI 12 (Xiaomi X3 NFC) with a system that's read-only and embedded in a super image.
Honestly Im not a 100 percent sure anymore. I know it's a super img and it's really different in twrp there's a ton of new partitions and you have to wipe it off completely to flash a new system. I really haven't dug to deep into everything because I know that S6 oneui isn't writable and actually upset me because it's not like having full root access anymore.
 

Lossyx

Senior Member
Jan 14, 2014
1,519
756
OnePlus 7T Pro
For Windows users with TWRP.
(This is more like a reference)

From adb shell inside twrp.

X = Partition. To find out what block partition is mounted at, mount it in twrp then run 'df -h'.

e2fsck -f /dev/block/dm-x
resize2fs /dev/block/dm-x 3G
e2fsck -E unshare_blocks /dev/block/dm-x

Now reboot to fastbootd and execute:
fastboot resize-logical-partition <partition_slot> $((3*1024*1024*1024))
 

giubenez

Member
Mar 30, 2011
41
4
Thank you for the script.

When I read that I could use it with the super.img I guessed the usage was like

./makesysrw.sh image.img super_edited.img

I have a linux partition, but on a remote server and I was hoping to use it on the file and get my edited file from the server without putting the phone in the server..

Let me knowif you add something like that(-i and -o flags will be useful)

Best
 
  • Like
Reactions: lebigmac

lebigmac

Senior Member
Jan 31, 2017
873
507
For Windows users with TWRP.
(This is more like a reference)

From adb shell inside twrp.

X = Partition. To find out what block partition is mounted at, mount it in twrp then run 'df -h'.

e2fsck -f /dev/block/dm-x
resize2fs /dev/block/dm-x 3G
e2fsck -E unshare_blocks /dev/block/dm-x

Now reboot to fastbootd and execute:
fastboot resize-logical-partition <partition_slot> $((3*1024*1024*1024))

As much as I wish for a solution to be available to our fellow Windows users,
unfortunately your suggestion doesn't work here on my device see screenshot below.

resize2fs_fail.jpg
 
Last edited:

Lossyx

Senior Member
Jan 14, 2014
1,519
756
OnePlus 7T Pro

lebigmac

Senior Member
Jan 31, 2017
873
507
If anybody is good with creating flashable zips contact me! Need help working on universal version right now which will also be compatible with Windows and Mac users!
I am only amateur so need a real pro to give me some assistance here. Thank you.
 
Last edited:
  • Like
Reactions: hacker812c

noyxo

New member
Mar 1, 2021
1
1
Redmi note 9 pro. EU 12.0.2 rom. Android 10. It works. I installed WMware Workstation on a virtual machine in Windows. Thanks.(Google translate, sorry)
 
  • Like
Reactions: lebigmac

gearmaker

Senior Member
Oct 7, 2012
63
33
Boise, Idaho
Tried it on my Oneplus 7T Pro with Android 10. It extracted the superimage but failed at writing it back. It returned this error:
Code:
error: file_write: write: No space left on device
lpmake E 03-02 21:41:55 76867 76867 images.cpp:468] [liblp]sparse_file_write failed with code: -1
lpmake E 03-02 21:41:55 76867 76867 images.cpp:326] [liblp]Could not open image for partition: product_a

makesysrw: Error! failed to create super_fixed.img file./makesysrw.sh super_image.img  14.21s user 37.28s system 51% cpu 1:40.46 total
Any ideas? Thank you for your great work!
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 50
    This Linux-only version is pretty much deprecated at this point. Please use the BRAND NEW UNIVERSAL VERSION instead! Thank you.

    Ladies and gentlemen. Let me present to you my very first release here at the XDA forums:
    Welcome to:
    makeSystemRW v1.04
    automated bash script by lebigmac for Android 10 and above
    Creation date: February 2021
    Updated: March 2021


    Requirements:
    • LINUX ONLY!
    • Android 10 or newer
    • This version only supports devices with super image.
      Check if you have super by running
      ls -Alg /dev/block/by-name
    • phone must be rooted + bootloader unlocked + 10 GB free space on phone
    • at least 20 GB free space on computer for dumping data
    • adb and fastboot commands should be in your $PATH environment variable
    I'm not 100% sure if this is a necessary requirement but I also disabled dm-verity and verification on my device just in case by simply booting into TWRP and then executing these 2 commands:
    Code:
    adb disable-verity
    
    adb shell avbctl disable-verification

    Description: A script for all Android power users that wish to make their read-only Android 10+ system read-write-able again to remove bloatware and make more thorough customizations to their device.

    In a nutshell this is what the script is doing:

    • dumps your existing super image to your pc
    • extracts the embedded read-only partitions (system, vendor, product, etc...)
    • makes these partitions read-write-able
    • joins everything back together to new flashable super.img
    • flashes it to device
    User data is not affected.

    Usage:
    Simply call the script from the shell.
    Optional arguments (replace x with your custom value) :

    • in=x : With this flag you can specify an existing super.img and skip the entire dumping of the super image process. Here you can use the super_original.img which you dumped earlier with makesysrw or the official super.img from your downloaded firmware. You probably have to unsparse the official super.img first using the included simg2img tool for superunpack to recognize it properly. If omitted, makesysrw will dump super image from phone to ./super_original.img
    • out=x : With this argument you can specify the output path. If omitted, default output value is ./super_fixed.img
    • size=x : With this parameter you can specify the extra free space (in megabytes) that will be added to each partition. If omitted, default extra size is 0 (shrink to minimum)
    Examples:
    Code:
    # Run this command if you're first time user:
    # Specify the extra free space in megabytes for each partition:
    ./makesysrw.sh size=100
    
    # Plug an existing raw super image into the script like this:
    ./makesysrw.sh in=./super_original_raw.img size=100
    
    # Specify both the input file as well as the output destination:
    ./makesysrw.sh in=./super_original_raw.img out=./super_fixed.img size=100
    
    # For unsparsing the (sparse) super.img from your phone manufacturer's firmware you can do:
    ./tools/bin/simg2img ./super_sparse.img ./super_raw.img

    NOTE: I did not come up with all this by myself. After searching for a solution for countless days without success, going even as far as learning hex editing - I coincidentally came across a couple of very interesting threads burried deep inside the new forum interface where this technique has been described and discussed by various enthousiasts (links can be found below in the credits section). So I take absolutely no credit for the underlying core mechanisms of the script. I'm only the amateur who put it all together into a compact script so that everybody can enjoy an Android system that's read-write-able again. Just like it used to be in Android 9 or earlier. Before this annoying 'shared_blocks feature' was implemented.

    Credits: Big thanks to @munjeni for allowing me to use his amazing superunpack tool instead of the default lpunpack. Source code can be found here.
    Also big thanks to @Brepro1 without your awesome tutorial guiding me I couldn't have created this script.
    Thanks @AndyYan your
    interesting thread also helped me a lot for automating the script especially the lpdump part.
    More thanks @gabrielfrias for his
    helpful comment
    Thanks @YOisuPU and of course @topjohnwu for discovering the 'shared_blocks feature'
    Thanks @bynarie for making available his
    otatools package! A part of it is now bundled with the archive

    Disclaimer: This is open source software and is provided as is without any kind of warranty or support whatsoever. By using and viewing this software you agree to the following terms:
    Under no circumstances shall the author be held responsible for any damages or negative consequences that may arrise from the (inappropriate) use of this software.
    All responsibility and liability lies with the end-user. You hereby agree not to abuse this software for illegal purposes. Use this software at your own risk!

    Please feel free to improve this script as you see fit (as long as you don't add anything malicious)
    and make sure to post your feedback, suggestions and improvements in the official thread right here.


    3.jpg


    2.jpg


    5.jpg


    1.jpg


    0.jpg

    Mod Edit: Download link removed
    Please click my like button below if you like it! Thanks​
    4
    It would be very helpful if you guys could please give me some feedback if the script works for you.
    Which device are you using?
    Your Android version?
    Did you disable dm-verity and verification before running the script?
    Your suggestions to enhance the script. Remember this is only version 1.0
    Thanks!

    @thor_1979
    4
    Ok folks I fixed the problem. I'm wrapping it all up and making a flashable zip and then uploading today. I promised the new universal version would be available this week. Well today is still this week ;)
    I'm so done with this project lol. It was a great bash programming exercise for me but I'm happy if I can start working on something new. I spent too much time on this project already.

    EDIT: Just found a genius called @Kolibass who figured out a way to flash an 8 GB large file in just under 30 seconds. Now compare this to the 2-5 minutes using traditional fastboot! Holy cow that's fast. Multithreading anyone?
    3
    Are you serious it actually works on your device? lmao
    Congratulations. You are the first person to try it :D

    The script pretty much does the same thing as your awesome tutorial describes.
    Without your tutorial this script would not exist so thank you very much for making it available!
    3
    Simply extract the downloaded archive and open a terminal shell in the extracted folder by right clicking inside it and select Open in Terminal

    Then run this command if you're running it for the first time
    Code:
    ./makesysrw.sh size=100

    or this command if you already have your raw super.img file
    Code:
    ./makesysrw.sh in=./existing_super_image.img size=100

    If you can't launch the script file make sure it is executable on your computer.