Building your custom version of Android is sometimes quite tricky, especially on new hardware. It is then often handy to be able to mount the Android system.img directly on your laptop, so that you can modify it without needing to rebuild it. This is especially useful if you don’t have working source, as often is the case.
In June, while busy breaking our then new NVIDIA Tegra X1 Shield Android TV through building a custom Android on it, using the NVIDIA provider source code, I encountered a bug that crashed the Surface Flinger.
I’ve seen that before; usually it is a result of missing proprietary EGL HAL drivers. This time it wasn’t that, well, almost. The EGL HAL drivers were readily there, no problem. However, one of the shared libraries the EGL drivers depend upon,
libnvcpl.so, was missing from the licensed binary file distribution. (I reported the problem to NVIDIA and hope that it is fixed by the time you read this.) After some thinking, I decided to fish the library out from the official NVIDIA NVIDIA SHIELD ANDROID TV Recovery OS Image.
On Mac OS X, using the Linux version of the image, it was easy enough to unpack the constituents,
system.img, etc. Furthermore, based on my earlier experience with other modern Androids, I correctly suspected that
system.img is actually a Linux ext4 system image. Now, the question was how to mount or otherwise inspect such an image on Mac OS X.
In the end of the day, the process was easy:
- Install the latest version of OS X Fuse, using the binary installer. This was the easiest option, as Fuse requires a kernel module, and Yosemite allows only officially signed kernel modules.
brew install ext4fuse.
One more non-obvious step was needed. The Android
system.img is actually not a direct ext4 file system image, but an Android specific wrapper around it. As I had built the open source Android for the console, I also had the required
simg2img around, (in
With these settings, I was finally able to mount the
$ sudo mkdir /mnt $ sudo chown `whoami` /mnt $ out/host/darwin-x86/bin/simg2img system.img system.ext4.imt $ ext4fuse system.ext4.img /mnt