Android Container 系列:大概步骤
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Android Container 系列:大概步骤,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3445字,纯文字阅读大概需要5分钟。
内容图文
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
内容总结
以上是互联网集市为您收集整理的Android Container 系列:大概步骤全部内容,希望文章能够帮你解决Android Container 系列:大概步骤所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。