1

There is a vendor image in my device I want to change (unpack/mount, doing changes, pack/umount). My purpose is to update boot.img with my new kernel (in a rooted device). Unfortunately, it does not work due to incompatible versions between a newly compiled kernel (my compilation) to the previous kernel modules stored in vendor.img. As I figure it, I need to update the old ko executables stored in vendor.img in my product.

The first step is to do dd from my device and adb pull it out to my build environment. While I tried to do a mount on vendor.img, I discovered it not working due share_blocks attribute blocking it to mount as RW (dmesg wrote: "...unsupported optional features (4000)"), To solve it, running the following command

e2fsck -y -E unshare_blocks vendor.img

will disable the share_blocks feature that prevented me to do mount as RW. Of course, doing mount RW works correctly.

In the last phase, I tried to replace files in the vendor filesystem and then I discovered another challenge into my way, Unfortunately, there was a problem with limited space in the file system,

For example: In case I want to replace the kernel module called abc.ko, deleting the file doesn't show any new free space in the file system. At this point, I can't update the old kernel modules with the new ones (compatible with the newly compiled kernel). Of course, running df -h . returned no free space and 100% used.

Does anyone have any idea what I need to do?

3

2 Answers 2

2

I know it is almost 2 years ago, but this is solved.

  1. Go to this repository: https://sourceforge.net/projects/multi-function-patch/files/RO2RW/. I used this version and the test one successfully: RO2RW-StableBeta.v3.7.2.1.zip.

  2. You flash it in Magisk with the phone running.

  3. Reboot and open up Termux

  4. Execute the following commands

    su
    RO2RW 
    

The script will walk you through the process. Many options like adding disable force encryption which is a boon to development since TWRP decryption is spotty at best now on a variety of devices. It allows you to resize or repartition in a variety of options.

At the end of the script, it offers a choice of a deblocked super for flashing in TWRP style recoveries or one suitable for fastboot work. It dumps the new super with a vbmeta and vbmeta_system image that corresponds to a folder in the internal storage. At this point, you can use a number of tools to dump the super and edit it, and then put it back together.


All my phones are RW rootfs now. The good old days of wiping out bloatware and having room for new system apps is back.

I am experimenting as we speak with repacking the decrypted RW super to include GSI VNDKLite system images. I love a lot of these ROMs but it is such a PITA to get good connectivity and MMS out of them due to the proprietary firmware for the devices and radios.

I am shooting to modify vendor_boot and repack the super with the GSI system, but retain the vendor-specific hardware items in the factory firmware in vendor, vendor_boot, boot.img/kernel/, vendor, and product partitions. I think it's a matter of putting them in the same folder and using common tools for repacking these and editing vendor_boot. According to what I have been reading, facilitating this is actually the purpose of the new setup with these bundled ramdisks in vendor_boot. If/when I sort it out, I will throw a tutorial up on XDA. I am about to fire this tool off towards that end: https://gitee.com/cfig/Android_boot_image_editor.


Other relevant links:

0

Assuming vendor is standalone partition (for super partition, refer to other question)

adb pull /dev/block/platform/bootdevice/by-name/vendor vendor.img
dd if=/dev/zero bs=1G seek=1 count=0 of=vendor.img
resize2fs vendor.img 1G
e2fsck -E unshare_blocks vendor.img
e2fsck -yf vendor.img
adb push vendor.img /dev/block/platform/bootdevice/by-name/vendor

that will resize to 1 GB total.

1
  • Thanks, but it's no help me because you cannot enlarge vendor partition.
    – sivandahan
    Sep 19, 2021 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .