如何使用busybox模板为ARM体系结构创建LXC容器

时间:2017-02-16 13:09:44

标签: linux arm lxc busybox

我对lxc了解不多,最近几天才开始研究它。

我尝试通过命令在linux 14.04LTS上创建一个Linux容器:

lxc-create -t /usr/share/lxc/templates/lxc-busybox -n OpenWrt

它通过lxc-start命令在那里运行良好。

然后 tar OpenWrt.tar.gz 复制在运行LEDE的Compex 主板上OS( ARM体系结构)到目录 / srv / lxc / ,其中我解压它来获取 / srv / lxc / OpenWrt 目录。然后,当我尝试通过命令运行容器时: lxc-start -F -n OpenWrt,我收到以下错误:

  lxc-start 20160210174618.933 ERROR    lxc_conf - conf.c:instantiate_veth:2618 - failed to create veth pair (vethAPIAY5 and vethWJLSXO): Operation not supported
      lxc-start 20160210174618.936 ERROR    lxc_conf - conf.c:lxc_create_network:2962 - failed to create netdev
      lxc-start 20160210174618.936 ERROR    lxc_start - start.c:lxc_spawn:1088 - Failed to create the network.
      lxc-start 20160210174618.936 ERROR    lxc_start - start.c:__lxc_start:1346 - Failed to spawn container "OpenWrt".
      lxc-start 20160210174618.971 ERROR    lxc_start_ui - tools/lxc_start.c:main:366 - The container failed to start.
      lxc-start 20160210174618.971 ERROR    lxc_start_ui - tools/lxc_start.c:main:370 - Additional information can be obtained by setting the --logfile and --logpriority options.

然后我只是在/ srv / lxc / OpenWrt / config文件中保存的配置文件中注释了网络配置(前4行),如下所示:

#lxc.network.type = veth
#lxc.network.flags = up
#lxc.network.link = lxcbr0
#lxc.network.hwaddr = 00:16:3e:1d:e5:8c
lxc.rootfs = /srv/lxc/OpenWrt/rootfs
lxc.haltsignal = SIGUSR1
lxc.utsname = OpenWrt
lxc.tty = 1
lxc.pts = 1
lxc.cap.drop = sys_module mac_admin mac_override sys_time

# When using LXC with apparmor, uncomment the next line to run unconfined:
#lxc.aa_profile = unconfined
lxc.mount.entry = /lib lib none ro,bind 0 0
lxc.mount.entry = /usr/lib usr/lib none ro,bind 0 0
#lxc.mount.entry = /sys/kernel/security sys/kernel/security none ro,bind,optional 0 0
lxc.mount.auto = proc:mixed sys

并通过命令再次运行容器:

lxc-start -n OpenWrt -l trace -o logfile.log

这次出现格式错误,如下面的日志所示:

lxc-start 20160210181025.855 ERROR    lxc_start - start.c:start:1431 - Exec format error - Failed to exec "/sbin/init".
      lxc-start 20160210181025.855 ERROR    lxc_sync - sync.c:__sync_wait:57 - An error occurred in another process (expected sequence number 5)
      lxc-start 20160210181025.856 ERROR    lxc_start - start.c:__lxc_start:1346 - Failed to spawn container "OpenWrt".
      lxc-start 20160210181025.859 ERROR    lxc_cgfs - cgroups/cgfs.c:cgroup_rmdir:209 - Device or resource busy - cgroup_rmdir: failed to delete /sys/fs/cgroup/lxc/OpenWrt-2
      lxc-start 20160210181025.921 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - Command get_cgroup failed to receive response: Connection reset by peer.
      lxc-start 20160210181030.927 ERROR    lxc_start_ui - tools/lxc_start.c:main:366 - The container failed to start.
      lxc-start 20160210181030.930 ERROR    lxc_start_ui - tools/lxc_start.c:main:368 - To get more details, run the container in foreground mode.
      lxc-start 20160210181030.936 ERROR    lxc_start_ui - tools/lxc_start.c:main:370 - Additional information can be obtained by setting the --logfile and --logpriority options.

我的理解是我试图在ARM板上运行x86二进制文件,这就是我遇到此错误的原因。现在我 尝试在linux 14.04计算机上创建一个ARM兼容容器,以便它可以在运行LEDE OS的ARM Compex板上运行。我正在寻找在lxc-create命令中指定所需架构的选项,比如创建ARM ubuntu lxc conatiner,我找到了一个命令即:

lxc-create -n armubuntu -t ubuntu -- -a armhf -r precise

但是当我尝试通过以下命令创建一个busybox容器时:

lxc-create -n myOpenWrt -t busybox -- -a armhf

我收到了无效选项错误:

getopt: invalid option -- 'a'
lxc-busybox -h|--help -p|--path=<path> -s|--ssh={dropbear,openssh}

现在我在网上搜索任何类似的命令来为ARM体系结构或任何小尺寸的容器创建所需的busybox容器(实际上创建的ubuntu ARM容器大小为426 MB,无法在板上复制/测试)。

有人请建议。

由于

0 个答案:

没有答案