Forcing the Android emulator to store changes to /system

android, emulation

Solution

At the moment (with Build Tools v26, if Google doesn't change things as often as they do) if you use the `-writable-system` directive while booting up the emulator from the command line, it will allow persistence to the `/system` partition through reboots. That is you will be able to write to the `/system` partition and if you reboot, the changes will still be maintained.

`emulator -avd <AVD_NAME> -writable-system`

This will also persist your changes to a `qcow2` image file usually in `.android/avd/<AVD_NAME>.avd/system.img.qcow2`

You can even copy this `system.img.qcow2` file, wipe the data off the AVD using the `-wipe-data` directive, place this file back into the directory, reboot and the system changes you made initially will still be persisted. (Caveat: at least for now, coz Google keeps changing things)

Problem

I know this is a recurrent question when working with the Android emulator, but is there a way to force the emulator to accept persistent changes to `/system`? The emulator is based on QEMU, so it should be possible, in theory, to force the `system` image to behave the same way `userdata` (for instance) does, but I'm not familiar with how QEMU handles things. Any pointers?

Original source