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

Status
Not open for further replies.
Search This thread

lebigmac

Senior Member
Jan 31, 2017
630
296
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!
I haven't seen this error before. The good news is you almost reached the very end of the script.
To me it almost looks like your hard drive is full so the lpmake command is throwing an error.
Were all partitions successfully extracted from your super image? It's complaining that it can't find product_a partition.
This definitely needs further investigation...
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
630
296
have modified dumpFile() a little to make script faster and save space on userdata

makesysrw_alecxs_mod.jpg


lol that's quite the extensive modification compared to the original...
You even changed the version number to 1.02 ! How thoughtful.
Hey if it works for you I'm happy for you :)
Please keep in mind the new universal version is already in the works that's also going to be compatible with Windows and Mac users.
Alecxs I appreciate your effort but don't waste your time on modding the old version. Come join me and help me create the new version so all Android users (not only the Linux users) can enjoy a system that's read-write-able.

I do agree however that the process of dumping the original super to the computer is a little bit more time consuming than necessary. This is not due to a limitation of the script but rather an Android permission limitation...
You can't adb pull the original super file directly off the phone because if you try it on a stock phone you will get the 'adb cannot run as root on production builds' or 'permission denied' error and therefore the script must first copy the file to internal /sdcard before being able to pull it to the computer.
This is already fixed in the next upcoming version.
 
Last edited:

uvzen

Member
Feb 28, 2020
30
8
Huawei P8
Huawei P10
In the makesysrw.sh bash script at the very end inside the checkPhoneState() function you can try to skip the root check and force inititate the procedure anyway by replacing this block of text:
Code:
        if ( adb shell "which su"&>/dev/null );then
            printf "$app: Root detected. Initiating procedure...\n\n"
            mainProc
        else
            printf "$app: Error! Root NOT detected. Abort\n"
            exit
        fi
simply with this:
Code:
        mainProc

I will check it later and let you know because I can't now.
 

aIecxs

Senior Member
Feb 17, 2016
1,032
317
have seen you made a lot of advertising for this. i recommend to ask @munjeni for hosting precompiled binaries under releases tag, so we can always wget/bitsadmin binary depending on host arch, instead of bundling binaries without distributing source code...

also other binaries like simg2img should be installed via package manager if possible, for example on darwin/debian/fedora it is available
Code:
brew install -y simg2img
apt-get install -y android-tools-fsutils
yum --disablerepo=updates* install -y android-tools
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
630
296
@Alecxs. The reason why I made lots of comments about this method is to bring more attention to this technique. My intention was not to spam the forum.
And no I did not invent this method I only found it hidden deep inside the forum after a very long time of searching. It was very well hidden or I just don't know how to navigate the new forum software yet.
I had to go even as far as learning hex editing before finally out of the blue I discovered those threads that helped me to create this script.

I just wanted to automate the entire process and make this method available to a wider audience so everyone can enjoy a system that's read-write-able. That's all. If such a script were available back in February it would've saved me lots of trouble and time.
If anything all credits should go to @Brepro1 , @AndyYan and @gabrielfrias also @munjeni for his nice superunpack tool.
My script is basically a carbon copy of the excellent Brepro1 / AndyYan tutorial (links in post #1)

Yes I agree releasing those precompiled binaries in the /tools folder without including the source code is not optimal. I might include a /source folder in the next version. Thanks for the idea.
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
630
296
screenshot_2-png.5238717

I will check it later and let you know because I can't now.

If you look closely at this screenshot you will see what the problem is.
You don't have the adb program in your $PATH environment variable.
So in order to fix this you must add your adb and fastboot to your $PATH environment variable.
That should fix your issue. Good luck!
 
Last edited:

aIecxs

Senior Member
Feb 17, 2016
1,032
317
no need to bundle source code, just links is already sufficient. unfortunately didn't find any useful download source or packages providing Dynamic Partition Tools, leaving you no choice to bundle binaries :(

edit: found lpunpack at least for linux
https://github.com/AndroidDumps
 
Last edited:

zgfg

Senior Member
Oct 10, 2016
4,988
2,274
By putting to GitHub, the source code, changes, (tagged) releases, everything will be easily available and managable, with the possibility for other developers to contribute (branches, pull, merge)
 
  • Like
Reactions: lebigmac

aIecxs

Senior Member
Feb 17, 2016
1,032
317
Still waiting for somebody with lots of experience in compiling AOSP for Android to contact me to collaborate on the upcoming version. Thanks!

what's the purpose of this? do you want to compile binaries for aarch64 and provide flashable zip?
 

lebigmac

Senior Member
Jan 31, 2017
630
296
what's the purpose of this? do you want to compile binaries for aarch64 and provide flashable zip?
You must admit that does sound good doesn't it? Anything to simplify the process and make our lives easier.
Unfortunately due to my limited compiling knowledge and limited resources I've hit a roadblock so I'm waiting for somebody with more compiling experience to contact me. Any volunteers?

The script in its current state and form works great for Linux users but I'm just sad for all the Windows and Mac users who are missing out on a system that's read-write-able and all the endless device customization possibilities that brings with it.
 
Last edited:

lebigmac

Senior Member
Jan 31, 2017
630
296
Thanks @Alecxs.
In your modification of the dumpFile function of the script why do you replace the dd command with this?
Code:
'cat $superPath 2> /dev/null' > $newPath

Does that pretty much do the same thing as dd ? Is it faster than dd ? Thanks for clarifying.
I always thought dd was the way to dump a file from the phone. It would've never occurred to me to use the cat function for this purpose. I thought that was more for reading text files and stuff.
 
Last edited:

ronlkh1965

Member
Feb 22, 2021
21
10
Hi any idea what is my problem?

partition_3_name = system
attributes = 0x1
first_extent_index = 0x2
num_extents = 0x1
group_index = 0x1
partition_group = qti_dynamic_partitions
extent num_sectors = 0x6c5718 (0xd8ae3000 bytes total)
extent target_type = 0x0
extent target_data = 0x4bf800 (dumping offset = 0x97f00000)
extent target_source = 0x0
Filetype EXT4. EXT4 size = 0xd8ae3000
Dumping system.ext4 ...
....................................................
........................................Error writing 512 bytes!
makesysrw: Please make sure the file exists and try again.
 

lebigmac

Senior Member
Jan 31, 2017
630
296
Hi any idea what is my problem?

partition_3_name = system
attributes = 0x1
first_extent_index = 0x2
num_extents = 0x1
group_index = 0x1
partition_group = qti_dynamic_partitions
extent num_sectors = 0x6c5718 (0xd8ae3000 bytes total)
extent target_type = 0x0
extent target_data = 0x4bf800 (dumping offset = 0x97f00000)
extent target_source = 0x0
Filetype EXT4. EXT4 size = 0xd8ae3000
Dumping system.ext4 ...
....................................................
........................................Error writing 512 bytes!
makesysrw: Please make sure the file exists and try again.

Now that's a new one. Never seen this error before. Your error is happening while the superunpack tool is running. What's happening before partition_3_name = system?
Does the superunpack tool successfully extract the other 2 partitions from your super_original.img file ? vendor.ext4 and product.ext4 ? So it failed at system.ext4 right?

If the super_original.img file was successfully dumped to your computer you could try to run this command manually and post the results here. Thanks
Code:
./tools/superunpack super_original.img
 
Last edited:
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    MOD ACTION:

    Thread closed at OP's request.
    1
    Do you think with Cygwin from Windows this will work?
    My congratulations for your work
  • 30
    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
    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
    Wait a second I upload new version right now. Give me a minute.
    Don't waste your time with that old version. The new version is a whole different beast! I think it deserve a new thread ;)
    2
    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
    2
    MOD ACTION:

    Thread closed at OP's request.
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone