Android Container 系列:大概步骤

Android Container 系列:大概步骤,第1张

概述CompileKernel(supportcgroups&namespaces)Download kernel sourcecodefrom AndroidX86tocompile,kernel's config fileiscopiedfrom AndroidX86.Onthisbasis,youneedfollowingcompileroptionstosurpportLXC'senvironment. (1)AboutN 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  makemake 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 = bblxc.tty = 1lxc.pts = 1lxc.rootfs = /system/local/var/lib/lxc/bb/rootfs  lxc.mount.entry = /lib /system/local/var/lib/lxc/bb/rootfs/lib none ro,bind 0 0lxc.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/$tdone

(5)Solve problem -- No such file or directory: /dev/shm (optional)

mkdir -p /dev/shmmount -t tmpfs -o nodev,noexec tmpfs /dev/shm
Run AndroID JellyBean container 总结

以上是内存溢出为你收集整理的Android Container 系列:大概步骤全部内容,希望文章能够帮你解决Android Container 系列:大概步骤所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1011990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存