Skip to content

Instantly share code, notes, and snippets.

@ppoffice
ppoffice / 01_Android_LXC_Note.md
Last active September 11, 2023 00:55
LXC for Android 9.0.0 r18 Goldfish

Steps to build Android kernel and system for LXC:

  1. Download Android SDK, NDK, system and kernel source code;
  2. Download modified lxc and libcap source code (ppoffiec/lxc-android, ppoffice/libcap-android)
  3. Build Android system from source first so that we can link to its shared library when we build lxc (or maybe we don't have to);
  4. Modify Android kernel config and make sure lxc-checkconfig does not report any missing features. Then build kernel;
  5. Modify Android system/core/rootdir/init.rc according to init.rc.diff. Make sure you mount all the cgroup subsystems needed (cpu, cpuacct, cpuset, memory, pids, devices, freezer, blkio) under /sys/fs/cgruop, otherwise lxc won't find them;
  6. Rebuilt the Android system image so that the modified init.rc is in the image;
  7. Fire up the emulator with custom kernel (emulator -kernel kernel-file-path) and use adb shell and dmesg to check if everything is doing ok.