Steps to build Android kernel and system for LXC:
- Download Android SDK, NDK, system and kernel source code;
- Download modified lxc and libcap source code (ppoffiec/lxc-android, ppoffice/libcap-android)
- 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);
- Modify Android kernel config and make sure lxc-checkconfig does not report any missing features. Then build kernel;
- Modify Android
system/core/rootdir/init.rc
according toinit.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; - Rebuilt the Android system image so that the modified init.rc is in the image;
- 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.