如果尝试创建臂丛和一个 arm64/一个arch64我的英特尔 64 位系统上的 lxc 容器。
我复制了相关库姆在启动容器之前的文件。
/usr/bin/qemu-arm-static
对于 arm 和/usr/bin/qemu-aarch64-static
arm64。
当我创建其他基于英特尔的 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
产量
[....] 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
产量
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 并没有什么区别)
与我的 arm 容器相比,我的 intel 容器 /run 目录非常稀疏,仅包含lock
和systemd
(而在 intel 上,它包含一个网络子文件夹以及许多其他东西)
我猜这表明(但我真的不知道我在做什么)systemd“启动系统”有问题并且无法启动一堆服务。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
来自此 PPAhttps://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 <E2><86><92> 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 <E2><86><92> 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
更新
我尝试过ifup eth0 -v
使用 dhcp 和静态配置运行,但两种方式都出现了类似的错误:
DHCP服务Error getting interfaces; Address family not supported by protocol
静止的Cannot open netlink socket: Address family not supported by protocol
答案1
(由于缺乏声誉而回答。)
我遇到了完全相同的问题。lxc 容器没有获取 IPv4 地址。运行dhclient eth0 -v
导致错误消息,幸运的是,它把我带到了这里
获取接口时出错;协议不支持地址系列
这个线程真的拯救了我。构建新的 qemu 二进制文件后,我可以让 armhf 容器使用此默认配置文件(eno1
即主机上的以太网接口)加入我的 LAN:
name: default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: macvlan
parent: eno1
type: nic
我正在使用 qemu 2.7.0 二进制文件,你可以从源代码编译它并安装在某个<prefix>
路径中
./configure --target-list=arm-linux-user --static --prefix=<prefix>
make
make install
在启动 armhf 容器之前,先将新的 qemu 放入其中
lxc file push <prefix>/bin/qemu-arm <name>/usr/bin/qemu-arm-static
另一个很好的副作用是,我现在可以在没有--force
标志的情况下停止容器!
答案2
事实证明,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)