如何让ipv4 / inet在intel主机上运行的arm lxc容器中运行?
如果尝试在我的intel 64bit系统上创建armhf和arm64 / aarch64 lxc容器。
我在启动容器之前复制了相关的qemu文件。 /usr/bin/qemu-arm-static
for arm和/usr/bin/qemu-aarch64-static
for arm64。
当我创建其他基于intel的ubuntu容器时,我的eth0有一个ipv4地址。 (使用桥接网络)
我像这样创建arm64容器:
lxc launch ubuntu:15.04/arm64 arm64 cp /usr/bin/qemu-aarch64-static /usr/lib/lxd/containers/arm64/rootfs/usr/bin lxc start arm64
我没有做任何其他修改。
在arm64容器中,ifconfig显示:
eth0 Link encap:Ethernet HWaddr 00:16:3e:e4:d2:de inet6 addr: fe80::216:3eff:fee4:d2de/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2564 (2.5 KB) TX bytes:578 (578.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
尝试显而易见的事情:
/etc/init.d/networking start
yeilds
[....] Starting networking (via systemctl): networking.serviceFailed to get D-Bus connection: No such file or directory failed!
ifup eth0
收益率
/sbin/ifup: failed to open lockfile /run/network/.ifstate.lock: No such file or directory
ip addr
yeilds
Cannot open netlink socket: Address family not supported by protocol
运行各种不同的网络工具时Address family not supported by protocol
似乎是一个常见的错误消息 – 可能是因为没有识别出没有ipv4地址。
类似dhcp客户端
root@ubuntu:/var/log# dhclient -v Internet Systems Consortium DHCP Client 4.3.1 Copyright 2004-2014 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Error getting interfaces; Address family not supported by protocol Can't get list of interfaces.
/etc/network/interfaces
是
# The loopback network interface auto lo iface lo inet loopback # Source interfaces # Please check /etc/network/interfaces.d before changing this file # as interfaces may have been defined in /etc/network/interfaces.d # NOTE: the primary ethernet device is defined in # /etc/network/interfaces.d/eth0 # See LP: #1262951 source /etc/network/interfaces.d/*.cfg
和eth0.cfg是
# The primary network interface auto eth0 iface eth0 inet dhcp
(偶然改为静态ip没有任何区别)
比较我的intel容器和我的arm容器/ run目录是非常稀疏的,只包含lock
和systemd
(在intel上它包含一个网络子文件夹和许多其他东西)
我猜这个节目(但我真的不知道我在做什么)系统的’启动系统’有问题,无法启动一堆服务。 journalctl
返回No journal files were found.
和/ var / log相当稀疏,只包含: pt btmp dist-upgrade dpkg.log fsck landscape lastlog unattended-upgrades wtmp
任何帮助,将不胜感激 :)
更新:
当我尝试手动运行systemd-journald
,我得到:
qemu: Unsupported syscall: 278 qemu: Unsupported syscall: 74 qemu: Unsupported syscall: 74
更新:
使用更新的qemu版本:
qemu-user-static (1:2.5+dfsg-5ubuntu10.4) to 1:2.6.1+dfsg-0~16.04
来自这个PPA https://launchpad.net/~jacob/+archive/ubuntu/virtualisation
改进了很多东西。 (但还没有ipv4网络)
/ var / run现在填充了预期目录(包括网络)
journalctl现在可以工作并返回:
Aug 26 18:02:26 ubuntu systemd-journal[89]: Runtime journal is using 8.0M (max allowed 801.2M, trying to leave 1.1G free of 7.8G available current limit 801.2M). Aug 26 18:02:26 ubuntu systemd-journal[89]: Runtime journal is using 8.0M (max allowed 801.2M, trying to leave 1.1G free of 7.8G available current limit 801.2M). Aug 26 18:02:26 ubuntu systemd-journal[89]: Journal started Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/kernel/yama/ptrace_scope': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '176' to '/proc/sys/kernel/sysrq': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/fs/protected_hardlinks': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '4 4 1 7' to '/proc/sys/kernel/printk': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/kernel/kptr_restrict': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '1' to '/proc/sys/fs/protected_symlinks': Permission denied Aug 26 18:02:27 ubuntu systemd-sysctl[78]: Failed to write '32768' to '/proc/sys/vm/mmap_min_addr': Permission denied Aug 26 18:02:27 ubuntu systemd-udevd[74]: error initializing netlink socket Aug 26 18:02:27 ubuntu systemd-remount-fs[62]: /bin/mount for / exited with exit status 1. Aug 26 18:02:27 ubuntu systemd-udevd[92]: error initializing netlink socket Aug 26 18:02:27 ubuntu systemd[1]: Failed to reset devices.list on /system.slice/systemd-journal-flush.service: Operation not permitted Aug 26 18:02:27 ubuntu systemd[1]: Starting Flush Journal to Persistent Storage... Aug 26 18:02:27 ubuntu systemd[1]: Started Load/Save Random Seed. Aug 26 18:02:27 ubuntu systemd-journal[89]: Forwarding to syslog missed 2 messages. Aug 26 18:02:27 ubuntu systemd-remount-fs[62]: mount: can't find LABEL=cloudimg-rootfs Aug 26 18:02:27 ubuntu systemd[1]: Started Various fixups to make systemd work better on Debian. Aug 26 18:02:27 ubuntu mount[67]: mount: permission denied Aug 26 18:02:27 ubuntu systemd-udevd[108]: error initializing netlink socket Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service: main process exited, code=exited, status=3/NOTIMPLEMENTED Aug 26 18:02:27 ubuntu systemd[1]: Failed to start udev Kernel Device Manager. Aug 26 18:02:27 ubuntu systemd[1]: Unit systemd-udevd.service entered failed state. Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service failed. Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd.service has no holdoff time, scheduling restart. Aug 26 18:02:27 ubuntu systemd[1]: systemd-udevd-kernel.socket failed to listen on sockets: Address family not supported by protocol Aug 26 18:02:27 ubuntu systemd[1]: Failed to listen on udev Kernel Socket. Aug 26 18:02:27 ubuntu systemd[1]: Starting udev Kernel Socket.
相关的错误行似乎是Aug 26 18:02:27 ubuntu systemd-udevd[92]: error initializing netlink socket
更新
我尝试使用dhcp和静态配置运行ifup eth0 -v
,并且两种方式都给出了类似的错误:
dhcp Error getting interfaces; Address family not supported by protocol
Error getting interfaces; Address family not supported by protocol
static Cannot open netlink socket: Address family not supported by protocol
(由于缺乏声誉而回答。)
我有同样的问题。 lxc容器没有获得IPv4地址。 运行dhclient eth0 -v
导致错误消息,幸运的是我带到了这里
获取接口时出错; 协议不支持的地址族
这个post真的救了我的一天。 在构建一个新的qemu二进制文件之后,我可以使用这个默认配置文件使armhf容器加入我的LAN( eno1
是我主机上的以太网接口):
name: default config: {} description: Default LXD profile devices: eth0: name: eth0 nictype: macvlan parent: eno1 type: nic
我正在使用qemu 2.7.0二进制文件,您可以从源代码编译并安装在一些
./configure --target-list=arm-linux-user --static --prefix= make make install
在启动armhf容器之前,只需在那里获得新的qemu
lxc file push
另一个不错的副作用是我现在可以在没有--force
标志的情况下停止容器!
事实certificate,qemu 2.6.1不能很好地工作,以便在一个arm容器中工作。
我将以下3个补丁应用于qemu 2.6.1(在运行apt get source qemu-user-static
)
https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06203.html https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06204.html https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg06205.html
和重建(使用debuild
)
然后从deb文件中提取新构建的qemu-aarch64-static
并安装到容器/usr/lib/lxd/container/$NAME/rootfs/usr/bin
网络现在有效:
eth0 Link encap:Ethernet HWaddr 00:16:3e:54:2e:7c inet addr:10.0.4.110 Bcast:10.0.4.255 Mask:255.255.255.0 inet6 addr: fe80::216:3eff:fe54:2e7c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:949 errors:0 dropped:0 overruns:0 frame:0 TX packets:428 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1285688 (1.2 MB) TX bytes:37196 (37.1 KB)