5

Help, I don't know what I did but after installing a custom ROM, I noticed that my system partition cannot be mounted as read/write.

I tried


"mount -o rw,remount /system" command on a terminal emulator, ADB shell, and TWRP terminal

The command shows no feedback showing failure (maybe I succeeded?)


Mount it using the built-in TWRP mount function.

The system check box can be checked out (it doesn't retain its check mark on reboot)


Some apps that actually works according to sources and reviews.

Some say (Failure to mount..) Some say (System mounted as rw) some doesn't have feedback.


I don't know what to do.

I noticed this when I installed a custom ROM. I tried using another custom ROM but same thing. Also reformatting doesn't help. I don't know if this occur on the stock ROM.


For reference

Device: Xiaomi Mi A2

Android version: Android 10

Custom ROM: AICP nightly build 15.0

1

2 Answers 2

9

Android 10 prevents apps or pretty much anything from mounting system as R/W. Yes, even if you are rooted.

Top John Wu, the creator of Magisk has covered this in a series of tweets. I will link them below for your reference. Your only way of tampering your system now would be using a systemless Magisk module. You can make your own or use some other module and inject files inside its folder before rebooting to apply that module.

  1. Just confirmed that the inability to remount system (the directory "/" in system-as-root) to rw is something new in Android Q, NOT an issue with the new system-as-root approach Magisk is using in the canary builds. Will have to investigate further to find out how to deal with it. Source: https://twitter.com/topjohnwu/status/1169720663201988611
  2. I found out that Android 10's system images are formatted with EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS. It will deduplicate blocks in the filesystem to reduce the image size. On my Pixel XL, the partition is physically not large enough to successfully run 'e2fsck -E unshare_blocks'. Source: https://twitter.com/topjohnwu/status/1170404631865778177?lang=en
  3. As clearly stated in the name of the feature, that EXT4 shared blocks feature is RO (read-only). The inability to disable this feature due to lack of free space in the partition (at least on my Pixel XL) makes it literally impossible to ever mount the system partition as rw. Source: https://twitter.com/topjohnwu/status/1170404633371525120
  4. I guess Google's justification to format partitions with this feature enabled is the introduction of overlayfs to "simulate" a writable partition. RIP to any mods or root apps that modify system. On Android 10 it seems system is either formatted as RO or using logical partitions. Source: https://twitter.com/topjohnwu/status/1170404634604658688
  5. BTW, just found this tidbit in Android's source code. They call these kind of filesystems "ext4 dedup". Other read-only filesystems they are aware of is squashfs (widely used in extremely constrained devices) and Huawei's EROFS. Source: https://twitter.com/topjohnwu/status/1170443615077666816

So, in short, you cannot R/W the system partition anymore with Android 10. The argument is just rejected.

2
  • 2
    EXT4_FEATURE_RO_COMPAT_SHARED_BLOCKS would be a problem on devices originally shipped with Android 10 (due to Dynamic Partitions and hence small system.img). On devices upgrading to Android 10, custom ROM developers can (re-)build system.img without SHARED_BLOCKS. Or the user may try e2fsck -E unshare_blocks in TWRP. If the shortage of space is a problem, dump system.img to /data partition or external SD card or PC, remove block sharing (by resizing filesystem) and flash back to system partition. ATM I can't think of a reason for this to not work. Bigger problem is dm-verity. Feb 4, 2020 at 13:11
  • 1
    @IrfanLatif my Nokia 8.1 updated from Android 9 to 10 and it had this problem and that's when I discovered TJW's tweets. I tried with a custom ROM and dm-verity was out too. My experience with dm-verity is more about device denying to boot or marking it as corrupt/won't boot types. It shouldn't be the one causing R/W from not happening. But I believe you know more on that topic. I don't know how and in what ways custom ROM devs can sort this out, but the few GSIs I used had this issue and I can't expect many of modifications from a GSI. Let's see what the ROM developers achieve in the future.
    – singhnsk
    Feb 4, 2020 at 19:19
1

I was having similar problems with Android 10 (Havoc OS / TWRP / Magisk 20.4) on an ASUS Max Pro M1. I wanted to remount /system so that I could edit /system/etc/hosts. I couldn't get adb to remount, though, and running "adb root" wouldn't work either.

Eventually I was successful, though, doing what I needed to do on the phone in a terminal, rather than using adb / debug mode. Here's what I did, including installing a file editor, since busybox can't install on Android 10 either:

  1. Install Termux from the google play store.
  2. Run Termux.
  3. Type "pkg install vim".
  4. Type "su", and grant permissions when the Magisk app prompts you.
  5. Type "mount -o rw,remount /" #mount -o /system doesn't work, so you have to mount the whole filesystem in read/write mode.
  6. If you want to use vim as root, you'll need to do this, too: "alias vi=/data/user/0/com.termux/files/usr/bin/vim" #let the shell know where to find the binaries for vim, since it's installed with termux. You may need to modify the path slightly depending on your phone; check first to confirm that's where it is.
  7. Do your dirty work.
  8. When finished, type "mount -o ro,remount /" to remount the filesystem as read only.

That should do it! I hope this works for you as well...

1
  • 1
    Hi, I'm also trying to edit the hosts file! However, when I try to run mount -o rw,remount / in Termux, I get the error '/dev/block/dm-0' is read-only. Do you have any idea what the issue is here?
    – Liam Baker
    Mar 23, 2022 at 13:58

You must log in to answer this question.

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