2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LTSPを授業で使うことを試してみた(その2:ブートさせてみよう)

Last updated at Posted at 2017-10-18

ブートしないじゃないか?!

スクリーンショット 2017-10-19 4.51.34.png

その1のラストで盛大にコケてくれたLTSPのブート。
このあたりはネットワーク周りを調整していく必要があるのですよ。
順次見ていきましょう。

vboxnet0インターフェースを見てみる

まず、VirtualBox側を見てみます。VirtualBoxの環境設定画面を開き、ネットワーク設定にてホストオンリーネットワークを調べてみます。vboxnet0などが見えると思いますが、詳細を(右のネジ回しっぽいボタンで)開いて確認すると、

スクリーンショット 2017-10-19 4.49.31.png スクリーンショット 2017-10-19 4.53.02.png

ブート時に取得していたIPアドレス(192.168.56.101/24)はVirtualBox側のDHCPで取得しちゃってたことになるのですね。ということでDHCPサーバー機能を解除(チェックを外す)して起動し直してみると…

スクリーンショット 2017-10-19 4.41.38.png

という具合にDHCPの応答がなくなったということがわかりました。あれ? LTSPの側でDHCPはいってなかったっけ?となるのです。

DHCPサーバー(Vagrant VM)を見てみる

ということで今度はVagrantで作っているVMの検証です。

systemctlでDHCPサーバーの状態を確認
ubuntu@ubuntu-xenial:~$ sudo systemctl status isc-dhcp-server.service --no-pager
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2017-10-19 04:31:42 JST; 25min ago
     Docs: man:dhcpd(8)
 Main PID: 8385 (code=exited, status=1/FAILURE)

Oct 19 04:31:42 ubuntu-xenial sh[8385]: Not configured to listen on any interfaces!
Oct 19 04:31:42 ubuntu-xenial sh[8385]: If you think you have received this message due to a bug rather
Oct 19 04:31:42 ubuntu-xenial sh[8385]: than a configuration issue please read the section on submitting
Oct 19 04:31:42 ubuntu-xenial sh[8385]: bugs on either our web page at www.isc.org or in the README file
Oct 19 04:31:42 ubuntu-xenial sh[8385]: before submitting a bug.  These pages explain the proper
Oct 19 04:31:42 ubuntu-xenial sh[8385]: process and the information we find helpful for debugging..
Oct 19 04:31:42 ubuntu-xenial sh[8385]: exiting.
Oct 19 04:31:42 ubuntu-xenial systemd[1]: isc-dhcp-server.service: Main process exited, code=exited, status=1/FAILURE
Oct 19 04:31:42 ubuntu-xenial systemd[1]: isc-dhcp-server.service: Unit entered failed state.
Oct 19 04:31:42 ubuntu-xenial systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.

あら、動いてない。DHCPサーバーが動かないとなると設定の確認ですね。
ここで注意! LTSP環境を導入した場合、DHCPサーバーの設定ファイルが一般に知られている/etc/dhcp/dhcpd.confではなく、/etc/ltsp/dhcpd.confになってます。
既にDHCPサーバーが入っている場合、クイックハックというかsystemdのオーバーライドが必要になりますが、それはまたのちほどやるとします。まずはこのミニ環境で走らせることが大切。

現状のdhcpd.confを見てみる
 ubuntu@ubuntu-xenial:/etc/ltsp$ cat /etc/ltsp/dhcpd.conf.dist
 ... 
 subnet 192.168.67.0 netmask 255.255.255.0 {
     range 192.168.67.20 192.168.67.250;
     option domain-name "example.com";
     option domain-name-servers 192.168.67.1;
     option broadcast-address 192.168.67.255;
     option routers 192.168.67.1;
     next-server 192.168.67.1;
 #    get-lease-hostnames true;
     option subnet-mask 255.255.255.0;
     option root-path "/opt/ltsp/i386";
     if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" 
 {
         filename "/ltsp/i386/pxelinux.0";
     } else {
         filename "/ltsp/i386/nbi.img";
     }
 }

あらら、またネットワークがえらいことになってる。Vagrantの初期設定では192.168.33.10/24で設定しています。

Vagrantfile抜粋
  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.10"

ということで調整します。67を33に変えればとりあえずOKそうですね。

DHCPのレンジ調整
ubuntu@ubuntu-xenial:~$ sed -e 's/67/33/g' /etc/ltsp/dhcpd.conf
...
authoritative;

subnet 192.168.33.0 netmask 255.255.255.0 {
    range 192.168.33.20 192.168.33.250;
    option domain-name "example.com";
    option domain-name-servers 192.168.33.1;
    option broadcast-address 192.168.33.255;
    option routers 192.168.33.1;
    next-server 192.168.33.1;
#    get-lease-hostnames true;
    option subnet-mask 255.255.255.0;
    option root-path "/opt/ltsp/i386";
    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
        filename "/ltsp/i386/pxelinux.0";
    } else {
        filename "/ltsp/i386/nbi.img";
    }
}
# いけそうなので置換する
ubuntu@ubuntu-xenial:~$ sed -i.bak -e 's/67/33/g' /etc/ltsp/dhcpd.conf
...
authoritative;

subnet 192.168.33.0 netmask 255.255.255.0 {
    range 192.168.33.20 192.168.33.250;
    option domain-name "example.com";
    option domain-name-servers 192.168.33.1;
    option broadcast-address 192.168.33.255;
    option routers 192.168.33.1;
    next-server 192.168.33.1;
#    get-lease-hostnames true;
    option subnet-mask 255.255.255.0;
    option root-path "/opt/ltsp/i386";
    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
        filename "/ltsp/i386/pxelinux.0";
    } else {
        filename "/ltsp/i386/nbi.img";
    }
}

これで再起動をかけてチェックすると、とりあえずDHCPサーバーは稼働していることがわかります。

DHCPサーバーのサー起動とチェック
ubuntu@ubuntu-xenial:~$ sudo systemctl restart isc-dhcp-server.service
ubuntu@ubuntu-xenial:~$ sudo systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-10-19 05:07:57 JST; 4s ago
     Docs: man:dhcpd(8)
 Main PID: 1816 (dhcpd)
    Tasks: 1
   Memory: 9.1M
      CPU: 12ms
   CGroup: /system.slice/isc-dhcp-server.service
           └─1816 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/ltsp/dhcpd.conf

Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]: Sending on   LPF/enp0s8/08:00:27:96:cd:c7/192.168.33.0/24
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]:
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]: No subnet declaration for enp0s3 (10.0.2.15).
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]: ** Ignoring requests on enp0s3.  If this is not what
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]:    you want, please write a subnet declaration
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]:    in your dhcpd.conf file for the network segment
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]:    to which interface enp0s3 is attached. **
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]:
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]: Sending on   Socket/fallback/fallback-net
Oct 19 05:07:57 ubuntu-xenial dhcpd[1816]: Server starting service.

おまけ: Vagrantの設定で、通常のNAT通信(enp0s3)とprivate_network(enp0s8)という2つのインターフェースで稼働している状況です。そのため、サブネットの一致しないenp0s3については無視しましたというメッセージが追加されているのがわかると思いますが、気にしないでおきましょう。気になる人は/etc/default/isc-dhcp-serverでも書き換えてください。

これでDHCPサーバーが動いたでしょうから、LTCP Clientを起動し、様子を見てみましょう。

スクリーンショット 2017-10-19 5.12.11.png

DHCPサーバーが応答し、192.168.33.20が取得できたことがわかりました。もらったデータに従い、PXELinuxブートローダーが動き出そうとしますが… 取得できていません。
取得元がおかしいわけで、サーバーがVagrant VMで与えてる192.168.33.10でなく192.168.33.1になっています。修正しましょう。

192.168.33.1をポイントしているところを修正してサーバー再起動
ubuntu@ubuntu-xenial:~$ sed -e 's/33.1;/33.10;/g' /etc/ltsp/dhcpd.conf
...
authoritative;

subnet 192.168.33.0 netmask 255.255.255.0 {
    range 192.168.33.20 192.168.33.250;
    option domain-name "example.com";
    option domain-name-servers 192.168.33.10;
    option broadcast-address 192.168.33.255;
    option routers 192.168.33.10;
    next-server 192.168.33.10;
#    get-lease-hostnames true;
    option subnet-mask 255.255.255.0;
    option root-path "/opt/ltsp/i386";
    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
        filename "/ltsp/i386/pxelinux.0";
    } else {
        filename "/ltsp/i386/nbi.img";
    }
}

# 変更が大丈夫そうなので適用して再起動
ubuntu@ubuntu-xenial:~$ sudo sed -i.bak -e 's/33.1;/33.10;/g' /etc/ltsp/dhcpd.conf
ubuntu@ubuntu-xenial:~$ sudo systemctl restart isc-dhcp-server.service
ubuntu@ubuntu-xenial:~$ sudo systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-10-19 05:16:27 JST; 2s ago
     Docs: man:dhcpd(8)
 Main PID: 1842 (dhcpd)
    Tasks: 1
   Memory: 9.1M
      CPU: 10ms
   CGroup: /system.slice/isc-dhcp-server.service
           └─1842 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/ltsp/dhcpd.conf

Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]: Sending on   LPF/enp0s8/08:00:27:96:cd:c7/192.168.33.0/24
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]:
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]: No subnet declaration for enp0s3 (10.0.2.15).
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]: ** Ignoring requests on enp0s3.  If this is not what
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]:    you want, please write a subnet declaration
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]:    in your dhcpd.conf file for the network segment
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]:    to which interface enp0s3 is attached. **
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]:
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]: Sending on   Socket/fallback/fallback-net
Oct 19 05:16:27 ubuntu-xenial dhcpd[1842]: Server starting service.
スクリーンショット 2017-10-19 5.17.19.png

今度はちゃんと192.168.33.10が渡ってますが、やはりファイルが無いと文句が出ます。
パスを見ると、i386と出てますね。今回は64ビットなんでamd64です。書き換えですね。

i386 → amd64
ubuntu@ubuntu-xenial:~$ sudo sed  -e 's/i386/amd64/' /etc/ltsp/dhcpd.conf
...
authoritative;

subnet 192.168.33.0 netmask 255.255.255.0 {
    range 192.168.33.20 192.168.33.250;
    option domain-name "example.com";
    option domain-name-servers 192.168.33.10;
    option broadcast-address 192.168.33.255;
    option routers 192.168.33.10;
    next-server 192.168.33.10;
...
    option subnet-mask 255.255.255.0;
    option root-path "/opt/ltsp/amd64";
    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
        filename "/ltsp/amd64/pxelinux.0";
    } else {
        filename "/ltsp/amd64/nbi.img";
    }
}

# 問題なさそうなので適用
ubuntu@ubuntu-xenial:~$ sudo sed -i.bak -e 's/i386/amd64/' /etc/ltsp/dhcpd.conf
ubuntu@ubuntu-xenial:~$ sudo systemctl restart isc-dhcp-server.service
ubuntu@ubuntu-xenial:~$ sudo systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-10-19 05:20:31 JST; 4s ago
     Docs: man:dhcpd(8)
 Main PID: 1880 (dhcpd)
    Tasks: 1
   Memory: 9.1M
      CPU: 11ms
   CGroup: /system.slice/isc-dhcp-server.service
           └─1880 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/ltsp/dhcpd.conf
...

今度は?

<img width="733" alt="スクリーンショット 2017-10-19 5.21.24.png" src="https://qiita-image-store.s3.amazonaws.com/0/146518/5ed29739-2ee4-9a14-501e-7597cce03456.png">

よっしゃ、カーネルはロードしたし、initrd.imgを読み込んでるぞ…

でも残念ながらその後のリモートディスクイメージを読み出すところでこけちゃって動きません(数分放置すればinitrd内蔵のシェルが動く…はず)。

<img width="731" alt="スクリーンショット 2017-10-19 5.22.34.png" src="https://qiita-image-store.s3.amazonaws.com/0/146518/9e0f1cf6-6547-f650-e0a4-da5a6c91dc24.png">

<img width="733" alt="スクリーンショット 2017-10-19 5.24.26.png" src="https://qiita-image-store.s3.amazonaws.com/0/146518/bb06023b-3ea3-a201-b74d-51827c231afe.png">

はい、緊急シェルが動きました。

なぜルートイメージが取得できないのかは、やはり`dhcpd.conf`にポイントがあります。

```text:dhcpd.conf抜粋
    if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {
        filename "/ltsp/amd64/pxelinux.0";
    } else {
        filename "/ltsp/amd64/nbi.img";
    }

LTSPでの起動の過程でDHCPが2回(以上?)動きます。
1回目はOS起動前のPXEの状況です

  1. まずはOS起動前のPXE環境です。この時クライアントからサーバーにvendor-class-identifierという識別情報を送ってくるので、それがPXEClientであればPXE用Linuxブートローダー(pxelinux.0)を返しています
  2. 起動後のinitrd(initramfs)の中で再度DHCPが走るので、そのときはクライアントからの値が異なります。そこで/ltsp/amd64/nbi.imgを返してます

ということで2回目のところで失敗しているのですね。対応しましょう。/etc/ltsp/dhcpd.confにて、

          filename "/opt/ltsp/images/amd64.img";

と返すファイルを存在しているものに差し替えておけばいいのです。これで動きました。

スクリーンショット 2017-10-19 6.00.13.png

あらま随分カオスな… まぁ、とりあえず動けばいいのでまずはここから。

おまけ: どういうわけか、dhcpd.conffilenameを書き換えても動かないことがありました。バックスクロールさせてみると、なぜかIP再取得の際に忌まわしき192.168.56.0/24を取得しちゃってました。この場合はVagrant VMも含めて一旦全て停止し、VirtualBoxを終了・再起動させてみるとよさそうです。どうも内蔵DHCPサーバーが居残ってるのでしょうね。

ということでひとまずここまで。このディスプレイマネージャ(LDM)には早々に撤退してもらいますのでログインスクリーンさえ出ればまず勝利なのです。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?