Changes between Initial Version and Version 1 of TipAndDoc/Linux/LXC/ArchLinux


Ignore:
Timestamp:
Apr 23, 2016 4:38:48 PM (9 years ago)
Author:
mitty
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TipAndDoc/Linux/LXC/ArchLinux

    v1 v1  
     1[[PageOutline]] 
     2 
     3 * [http://unix.stackexchange.com/questions/71527/arch-linux-pacman-does-not-work-when-chrooting grub2 - Arch linux : pacman does not work when chrooting - Unix & Linux Stack Exchange] 
     4 > Remember to {{{arch-chroot}}} and not simply {{{chroot}}} - that way {{{/proc}}} will be populated and pacman will function as expected. 
     5 
     6 * [http://bryanalves.github.io/2015/07/02/enabling-lxc-archlinux-with-systemd-networkd/ Enabling LXC on Archlinux with systemd-networkd – Bryan's Blah Blog] 
     7 > I’m on a laptop with wireless, so I can’t just create a bridge and give IPs to containers from an upstream DHCP server. I needed to do NAT and essentially simulate/replicate how docker networking works. 
     8 
     9 = DHCP = 
     10 
     11 == no valid interfaces found == 
     12 * Arch Linux 4.4.5-1 
     13 * lxc 1:1.1.5-4 
     14 * dhcpcd 6.10.1-1 
     15 
     16 * # dhcpcd 
     17{{{ 
     18dev: loaded udev 
     19no valid interfaces found 
     20no interfaces have a carrier 
     21forked to background, child pid 65 
     22}}} 
     23 * # dhcpcd eth0 
     24{{{ 
     25DUID 00:01:00:01:1e:8a:6a:5e:ba:4a:37:94:4a:9d 
     26eth0: IAID 16:b6:47:44 
     27eth0: rebinding lease of 192.168.0.185 
     28eth0: NAK: address in use from 192.168.0.1 
     29eth0: message: address in use 
     30eth0: soliciting a DHCP lease 
     31eth0: soliciting an IPv6 router 
     32eth0: offered 192.168.0.172 from 192.168.0.1 
     33eth0: probing address 192.168.0.172/24 
     34eth0: leased 192.168.0.172 for 86400 seconds 
     35eth0: adding route to 192.168.0.0/24 
     36eth0: adding default route via 192.168.0.1 
     37forked to background, child pid 123 
     38}}} 
     39 
     40 * LXCコンテナ内で、udevdが起動しないことが原因の模様 
     41 * strace -f dhcpcd 
     42  * コンテナホスト(検証はKVMゲストで行った) 
     43{{{ 
     44access("/run/udev/control", F_OK) = 0 
     45 
     46open("/sys/devices/virtual/net/lo/uevent", O_RDONLY|O_CLOEXEC) = 9 
     47fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     48fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     49read(9, "INTERFACE=lo\nIFINDEX=1\n", 4096) = 23 
     50read(9, "", 4096)                 = 0 
     51read(9, "", 4096)                 = 0 
     52close(9)                          = 0 
     53open("/run/udev/data/n1", O_RDONLY|O_CLOEXEC) = 9 
     54 
     55open("/sys/devices/pci0000:00/0000:00:03.0/virtio0/net/ens3/uevent", O_RDONLY|O_CLOEXEC) = 9 
     56fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     57fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     58read(9, "INTERFACE=ens3\nIFINDEX=2\n", 4096) = 25 
     59read(9, "", 4096)                 = 0 
     60read(9, "", 4096)                 = 0 
     61close(9)                          = 0 
     62open("/run/udev/data/n2", O_RDONLY|O_CLOEXEC) = 9 
     63}}} 
     64  * LXCコンテナ 
     65{{{ 
     66access("/run/udev/control", F_OK) = -1 ENOENT (No such file or directory) 
     67 
     68open("/sys/devices/virtual/net/lo/uevent", O_RDONLY|O_CLOEXEC) = 9 
     69fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     70fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     71read(9, "INTERFACE=lo\nIFINDEX=1\n", 4096) = 23 
     72read(9, "", 4096)                 = 0 
     73read(9, "", 4096)                 = 0 
     74close(9)                          = 0 
     75open("/run/udev/data/n1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
     76 
     77open("/sys/devices/virtual/net/eth0/uevent", O_RDONLY|O_CLOEXEC) = 9 
     78fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     79fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
     80read(9, "INTERFACE=eth0\nIFINDEX=6\n", 4096) = 25 
     81read(9, "", 4096)                 = 0 
     82read(9, "", 4096)                 = 0 
     83close(9)                          = 0 
     84open("/run/udev/data/n6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
     85write(2, "no valid interfaces found", 25) = 25 
     86write(2, "\n", 1)                 = 1 
     87 
     88write(1, "no interfaces have a carrier\n", 29) = 29 
     89}}} 
     90   * [root@test /]# systemctl status systemd-udevd 
     91{{{ 
     92● systemd-udevd.service - udev Kernel Device Manager 
     93   Loaded: loaded (/usr/lib/systemd/system/systemd-udevd.service; static; vendor preset: disabled) 
     94   Active: inactive (dead) 
     95Condition: start condition failed at Sat 2016-04-02 08:30:59 UTC; 5h 9min ago 
     96           ConditionPathIsReadWrite=/sys was not met 
     97     Docs: man:systemd-udevd.service(8) 
     98           man:udev(7) 
     99}}} 
     100 * arch:Linux_Containers#Systemd_considerations_.28required.29 
     101  * 上記を参考にsystemdの設定を行ったが効果なし 
     102 
     103 * arch:dhcpcd#dhcpcd_and_systemd_network_interfaces 
     104 > {{{dhcpcd.service}}} can be [arch:Enabled] without specifying an interface. This may, however, create a race condition at boot with ''systemd-udevd'' trying to apply a predictable network interface name: 
     105 > {{{ 
     106 > error changing net interface name wlan0 to wlp4s0: Device or resource busy"  
     107 > }}} 
     108 > To avoid it, enable dhcpcd per interface it should bind to as described in [arch:dhcpcd#Running]. The downside of the template unit is, however, that it does not support hot-plugging of a wired connection and will fail if the network cable is not connected. To work-around the failure, see [arch:dhcpcd#Timeout_delay]. 
     109 とのことなので、いずれにせよ{{{dhcpcd.service}}}を使用しないのがよさそう 
     110 
     111 * 古い情報 
     112  * [http://blog.oddbit.com/2013/02/01/dhcpcd-under-lxc/ Odd Bits] {{{dhcpcd[492]: eth0: if_init: Read-only file system}}} 
     113 
     114 == Dependency failed for dhcpcd on eth0. == 
     115 * # systemctl start dhcpcd@eth0 
     116{{{ 
     117A dependency job for dhcpcd@eth0.service failed. See 'journalctl -xe' for details. 
     118}}} 
     119 * # journalctl -xe 
     120{{{ 
     121Apr 10 20:00:56 test3 systemd[1]: Starting of sys-subsystem-net-devices-eth0.device not supported. 
     122-- Subject: Unit sys-subsystem-net-devices-eth0.device has failed 
     123-- Defined-By: systemd 
     124-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
     125-- 
     126-- Unit sys-subsystem-net-devices-eth0.device has failed. 
     127-- 
     128-- The result is unsupported. 
     129Apr 10 20:00:56 test3 systemd[1]: Dependency failed for dhcpcd on eth0. 
     130-- Subject: Unit dhcpcd@eth0.service has failed 
     131-- Defined-By: systemd 
     132-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
     133-- 
     134-- Unit dhcpcd@eth0.service has failed. 
     135-- 
     136-- The result is dependency. 
     137Apr 10 20:00:56 test3 systemd[1]: dhcpcd@eth0.service: Job dhcpcd@eth0.service/start failed with result 'dependency'. 
     138}}} 
     139 
     140 * /usr/lib/systemd/system/dhcpcd@.service 
     141{{{ 
     142[Unit] 
     143Description=dhcpcd on %I 
     144Wants=network.target 
     145Before=network.target 
     146BindsTo=sys-subsystem-net-devices-%i.device 
     147After=sys-subsystem-net-devices-%i.device 
     148 
     149[Service] 
     150Type=forking 
     151PIDFile=/run/dhcpcd-%I.pid 
     152ExecStart=/usr/bin/dhcpcd -q -w %I 
     153ExecStop=/usr/bin/dhcpcd -x %I 
     154 
     155[Install] 
     156WantedBy=multi-user.target 
     157}}} 
     158  * {{{BindsTo=}}}, {{{After=}}}の行を削除することで対応可能 
     159 
     160 * see also 
     161  * [https://bbs.archlinux.org/viewtopic.php?id=164753 Netctl doesn't work in LXC (Linux containers) due to udev dependency / Networking, Server, and Protection / Arch Linux Forums] 
     162  * [https://bugs.archlinux.org/task/35715 FS#35715 : (netctl) fails to start network inside Linux Container]