Changes between Version 55 and Version 56 of TipAndDoc/Linux/LXC


Ignore:
Timestamp:
Apr 23, 2016 4:39:18 PM (8 years ago)
Author:
mitty
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TipAndDoc/Linux/LXC

    v55 v56  
    11[[PageOutline]] 
     2[[TitleIndex(TipAndDoc/Linux/LXC,format=group)]] 
    23 
    34 * LinuX Container 
     
    122123 > > No, this is a non-fatal error, so you're just fine. 
    123124 
    124  * [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] 
    125  > Remember to {{{arch-chroot}}} and not simply {{{chroot}}} - that way {{{/proc}}} will be populated and pacman will function as expected. 
    126  
    127  * [http://bryanalves.github.io/2015/07/02/enabling-lxc-archlinux-with-systemd-networkd/ Enabling LXC on Archlinux with systemd-networkd – Bryan's Blah Blog] 
    128  > 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. 
    129  
    130125 = two NICs in one container = 
    131126 * [http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg02037.html Re: (Lxc-users) two NICs in container] 
     
    307302  * [http://blog.xe.bz/archives/51645042.html AKIBA de: (メモ) tarの--numeric-ownerオプションはどう働くのか?] 
    308303 
    309  = DHCP = 
    310  
    311  == no valid interfaces found == 
    312  * Arch Linux 4.4.5-1 
    313  * lxc 1:1.1.5-4 
    314  * dhcpcd 6.10.1-1 
    315  
    316  * # dhcpcd 
    317 {{{ 
    318 dev: loaded udev 
    319 no valid interfaces found 
    320 no interfaces have a carrier 
    321 forked to background, child pid 65 
    322 }}} 
    323  * # dhcpcd eth0 
    324 {{{ 
    325 DUID 00:01:00:01:1e:8a:6a:5e:ba:4a:37:94:4a:9d 
    326 eth0: IAID 16:b6:47:44 
    327 eth0: rebinding lease of 192.168.0.185 
    328 eth0: NAK: address in use from 192.168.0.1 
    329 eth0: message: address in use 
    330 eth0: soliciting a DHCP lease 
    331 eth0: soliciting an IPv6 router 
    332 eth0: offered 192.168.0.172 from 192.168.0.1 
    333 eth0: probing address 192.168.0.172/24 
    334 eth0: leased 192.168.0.172 for 86400 seconds 
    335 eth0: adding route to 192.168.0.0/24 
    336 eth0: adding default route via 192.168.0.1 
    337 forked to background, child pid 123 
    338 }}} 
    339  
    340  * LXCコンテナ内で、udevdが起動しないことが原因の模様 
    341  * strace -f dhcpcd 
    342   * コンテナホスト(検証はKVMゲストで行った) 
    343 {{{ 
    344 access("/run/udev/control", F_OK) = 0 
    345  
    346 open("/sys/devices/virtual/net/lo/uevent", O_RDONLY|O_CLOEXEC) = 9 
    347 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    348 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    349 read(9, "INTERFACE=lo\nIFINDEX=1\n", 4096) = 23 
    350 read(9, "", 4096)                 = 0 
    351 read(9, "", 4096)                 = 0 
    352 close(9)                          = 0 
    353 open("/run/udev/data/n1", O_RDONLY|O_CLOEXEC) = 9 
    354  
    355 open("/sys/devices/pci0000:00/0000:00:03.0/virtio0/net/ens3/uevent", O_RDONLY|O_CLOEXEC) = 9 
    356 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    357 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    358 read(9, "INTERFACE=ens3\nIFINDEX=2\n", 4096) = 25 
    359 read(9, "", 4096)                 = 0 
    360 read(9, "", 4096)                 = 0 
    361 close(9)                          = 0 
    362 open("/run/udev/data/n2", O_RDONLY|O_CLOEXEC) = 9 
    363 }}} 
    364   * LXCコンテナ 
    365 {{{ 
    366 access("/run/udev/control", F_OK) = -1 ENOENT (No such file or directory) 
    367  
    368 open("/sys/devices/virtual/net/lo/uevent", O_RDONLY|O_CLOEXEC) = 9 
    369 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    370 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    371 read(9, "INTERFACE=lo\nIFINDEX=1\n", 4096) = 23 
    372 read(9, "", 4096)                 = 0 
    373 read(9, "", 4096)                 = 0 
    374 close(9)                          = 0 
    375 open("/run/udev/data/n1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
    376  
    377 open("/sys/devices/virtual/net/eth0/uevent", O_RDONLY|O_CLOEXEC) = 9 
    378 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    379 fstat(9, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 
    380 read(9, "INTERFACE=eth0\nIFINDEX=6\n", 4096) = 25 
    381 read(9, "", 4096)                 = 0 
    382 read(9, "", 4096)                 = 0 
    383 close(9)                          = 0 
    384 open("/run/udev/data/n6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) 
    385 write(2, "no valid interfaces found", 25) = 25 
    386 write(2, "\n", 1)                 = 1 
    387  
    388 write(1, "no interfaces have a carrier\n", 29) = 29 
    389 }}} 
    390    * [root@test /]# systemctl status systemd-udevd 
    391 {{{ 
    392 ● systemd-udevd.service - udev Kernel Device Manager 
    393    Loaded: loaded (/usr/lib/systemd/system/systemd-udevd.service; static; vendor preset: disabled) 
    394    Active: inactive (dead) 
    395 Condition: start condition failed at Sat 2016-04-02 08:30:59 UTC; 5h 9min ago 
    396            ConditionPathIsReadWrite=/sys was not met 
    397      Docs: man:systemd-udevd.service(8) 
    398            man:udev(7) 
    399 }}} 
    400  * arch:Linux_Containers#Systemd_considerations_.28required.29 
    401   * 上記を参考にsystemdの設定を行ったが効果なし 
    402  
    403  * arch:dhcpcd#dhcpcd_and_systemd_network_interfaces 
    404  > {{{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: 
    405  > {{{ 
    406  > error changing net interface name wlan0 to wlp4s0: Device or resource busy"  
    407  > }}} 
    408  > 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]. 
    409  とのことなので、いずれにせよ{{{dhcpcd.service}}}を使用しないのがよさそう 
    410  
    411  * 古い情報 
    412   * [http://blog.oddbit.com/2013/02/01/dhcpcd-under-lxc/ Odd Bits] {{{dhcpcd[492]: eth0: if_init: Read-only file system}}} 
    413  
    414  == Dependency failed for dhcpcd on eth0. == 
    415  * # systemctl start dhcpcd@eth0 
    416 {{{ 
    417 A dependency job for dhcpcd@eth0.service failed. See 'journalctl -xe' for details. 
    418 }}} 
    419  * # journalctl -xe 
    420 {{{ 
    421 Apr 10 20:00:56 test3 systemd[1]: Starting of sys-subsystem-net-devices-eth0.device not supported. 
    422 -- Subject: Unit sys-subsystem-net-devices-eth0.device has failed 
    423 -- Defined-By: systemd 
    424 -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
    425 -- 
    426 -- Unit sys-subsystem-net-devices-eth0.device has failed. 
    427 -- 
    428 -- The result is unsupported. 
    429 Apr 10 20:00:56 test3 systemd[1]: Dependency failed for dhcpcd on eth0. 
    430 -- Subject: Unit dhcpcd@eth0.service has failed 
    431 -- Defined-By: systemd 
    432 -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel 
    433 -- 
    434 -- Unit dhcpcd@eth0.service has failed. 
    435 -- 
    436 -- The result is dependency. 
    437 Apr 10 20:00:56 test3 systemd[1]: dhcpcd@eth0.service: Job dhcpcd@eth0.service/start failed with result 'dependency'. 
    438 }}} 
    439  
    440  * /usr/lib/systemd/system/dhcpcd@.service 
    441 {{{ 
    442 [Unit] 
    443 Description=dhcpcd on %I 
    444 Wants=network.target 
    445 Before=network.target 
    446 BindsTo=sys-subsystem-net-devices-%i.device 
    447 After=sys-subsystem-net-devices-%i.device 
    448  
    449 [Service] 
    450 Type=forking 
    451 PIDFile=/run/dhcpcd-%I.pid 
    452 ExecStart=/usr/bin/dhcpcd -q -w %I 
    453 ExecStop=/usr/bin/dhcpcd -x %I 
    454  
    455 [Install] 
    456 WantedBy=multi-user.target 
    457 }}} 
    458   * {{{BindsTo=}}}, {{{After=}}}の行を削除することで対応可能 
    459  
    460  * see also 
    461   * [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] 
    462   * [https://bugs.archlinux.org/task/35715 FS#35715 : (netctl) fails to start network inside Linux Container]