标签:Busybox Container 步骤 system local lxc LXC Android CONFIG
Compile Kernel (support cgroups & namespaces)
Download kernel source code from Android X86to compile,kernel's config file is copied from Android X86.On this basis,you need following compiler options to surpport LXC's environment. (1) About Namespace
CONFIG_NAMESPACES
CONFIG_UTS_NS
CONFIG_IPC_NS
CONFIG_PID_NS
CONFIG_NET_NS
(2)About Cgroups
CONFIG_CGROUPS
CONFIG_CGROUP_NS
ONFIG_CGROUP_DEVICE
CONFIG_CGROUP_SCHED
CONFIG_CGROUP_CPUACCT
CONFIG_CPUSETS
(3)About MISC
CONFIG_VETH
CONFIG_MACWLAN
CONFIG_VLAN_8021Q
CONFIG_SECURITY_FILE_CAPABILITIES
(4)Other
CONFIG_POSIX_MQUEUE
Transplant LXC tools to Android Host
LXC package has executable program and shell script. (1)Compile LXC
./configure --prefix=/system/local
make
make install
Note:/usr/local is default prefix of /configure ,and there is no /usr directory in android下,so you need to change it.
(2)Transplant Shell script
lxc's script is written in GNU Linux's bash.Many tools and commands is non-existent or non-executable.So you need modify as follow:
1. Statically link a bash procedure,and transpant to android
2. Copy ubuntu 10.04 file procedure to android
3. Copy zgrep script to android;zgrep calls ”gzip -cdfq”,and it can't use in Android,replace it to ”gzip -c -d -f”
4. lxc-create call command id -u from 190;this command can't execute in android,so you should comment revelant code out;lxc-destroy need do some modifications
(3)Modify source code
conf.c in LXC project calls tmpfile(),which didn't realize in Android's bionic libc.You need write tmpfile_replace(),whose function is same as tmpfile(),and conf.c can call tmpfile_replace()
(4)Compile LXC again
You need compile LXC again after modifying LXC source code; The main process includes following:
1. Modify LXC_PROJECT/src/lxc/Makefile.am,put new code files to Macro pkginclue_HEADERS and liblxc_so_SOURCES
2. Call autoconf to generate configure file(you need install autotools and libtools)
3. Call ./configure and make again
Run Busybox container
Busybox is a binary executable program,which integrates about 100 frequently-used Linux commands and tools.
Busybox is viewed as simplest Linux system,which contains all tools to create a complete Linux filesystem hierarchy standard,such as init,mount,mknod,and so on.So,if you can run a Busybox Container,you can also work on our Android LXC environment.
(1)Compile statically Busybox
You need compile statically a complete busybox to avoid dynamic Shared libraries' error when creating container's rootfs(lxc-create) 1. Download busybox source code from Busybox 2. make menuconfig, --> Build Options, --> Build Busybox as a static binary
3. make
4. Put compiled busybox to /system/local/bin directory beneath Host,and add PATH environment variable
adb push bin/busybox /system/local/bin/
export PATH=/system/local/bin:$PATH
(2) Create rootfs of Busybox
lxc-create -t busybox -n bb
(3) Modify config of Busybox
lxc.utsname = bb
lxc.tty = 1
lxc.pts = 1
lxc.rootfs = /system/local/var/lib/lxc/bb/rootfs
lxc.mount.entry = /lib /system/local/var/lib/lxc/bb/rootfs/lib none ro,bind 0 0
lxc.mount.entry = /lib /system/local/var/lib/lxc/bb/rootfs/usr/lib none ro,bind 0 0
(4) Mount cgroup file system
for t in `ls /system/cgroup`
do
mount -t cgroup -o $t cgroup /system/cgroup/$t
done
(5)Solve problem -- No such file or directory: /dev/shm (optional)
mkdir -p /dev/shm
mount -t tmpfs -o nodev,noexec tmpfs /dev/shm
Run Android JellyBean container
标签:Busybox,Container,步骤,system,local,lxc,LXC,Android,CONFIG 来源: https://blog.csdn.net/omnispace/article/details/116358416
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。