トーク:PXEブート用サーバを構築する

提供:maruko2 Note.
移動: 案内, 検索

目次

Mac OS X で Linux の PXE ブートサーバを構築する

tftp のインストール

Mac OS X 標準の tftpd を使用

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Disabled</key>
        <true/>
        <key>Label</key>
        <string>com.apple.tftpd</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/libexec/tftpd</string>
                <string>-i</string>
                <string>/private/tftpboot</string>
        </array>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <true/>
        </dict>
        <key>InitGroups</key>
        <true/>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <dict>
                        <key>SockServiceName</key>
                        <string>tftp</string>
                        <key>SockType</key>
                        <string>dgram</string>
                </dict>
        </dict>
</dict>
</plist>
MacPorts を利用する場合: [表示する]

dhcpd のインストール

$ sudo port -vc install dhcp
###########################################################
# A startup item has been generated that will aid in
# starting dhcp with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load dhcp
###########################################################
 
NOTE:
 
-The dhcpd .conf and .leases files must be named and located as shown for dhcpd to find them:
        /opt/local/etc/dhcp/dhcpd.conf (there is a sample file)
        /opt/local/var/db/dhcpd/dhcpd.leases (use the touch command to create a blank one)
$ port contents dhcp
Port dhcp contains:
  /Library/LaunchDaemons/org.macports.dhcpd.plist
  /opt/local/bin/omshell
  /opt/local/etc/dhcp/dhclient.conf.sample
  /opt/local/etc/dhcp/dhcpd.conf.sample
  /opt/local/etc/LaunchDaemons/org.macports.dhcpd/org.macports.dhcpd.plist
  /opt/local/include/dhcpctl.h
  /opt/local/include/isc-dhcp/boolean.h
  /opt/local/include/isc-dhcp/dst.h
  /opt/local/include/isc-dhcp/int.h
  /opt/local/include/isc-dhcp/lang.h
  /opt/local/include/isc-dhcp/list.h
  /opt/local/include/isc-dhcp/result.h
  /opt/local/include/isc-dhcp/types.h
  /opt/local/include/omapip/alloc.h
  /opt/local/include/omapip/buffer.h
  /opt/local/include/omapip/omapip.h
  /opt/local/lib/libdhcpctl.a
  /opt/local/lib/libomapi.a
  /opt/local/sbin/dhclient
  /opt/local/sbin/dhclient-script
  /opt/local/sbin/dhcpd
  /opt/local/sbin/dhcrelay
  /opt/local/share/man/cat1/omshell.1.gz
  /opt/local/share/man/cat3/dhcpctl.3.gz
  /opt/local/share/man/cat3/omapi.3.gz
  /opt/local/share/man/cat3/omshell.3.gz
  /opt/local/share/man/cat5/dhclient.conf.5.gz
  /opt/local/share/man/cat5/dhclient.leases.5.gz
  /opt/local/share/man/cat5/dhcp-eval.5.gz
  /opt/local/share/man/cat5/dhcp-options.5.gz
  /opt/local/share/man/cat5/dhcpd.conf.5.gz
  /opt/local/share/man/cat5/dhcpd.leases.5.gz
  /opt/local/share/man/cat8/dhclient-script.8.gz
  /opt/local/share/man/cat8/dhclient.8.gz
  /opt/local/share/man/cat8/dhcpd.8.gz
  /opt/local/share/man/cat8/dhcrelay.8.gz
  /opt/local/var/db/dhcpd/.turd_dhcp
  /opt/local/var/db/dhcpd/dhcpd.leases

設定

pxelinux.0

$ curl -O http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.03.tar.bz2
$ tar xjf syslinux-4.03.tar.bz2
$ sudo cp syslinux-4.03/core/pxelinux.0 /private/tftpboot/
$ rm -Rf syslinux-4.03*

pxeboot 起動イメージ

sudo mkdir -p /private/tftpboot/centos5/{i386,x86_64}
cd /private/tftpboot/centos5/i386
sudo curl -O http://ftp.riken.jp/Linux/centos/5/os/i386/images/pxeboot/initrd.img
sudo curl -O http://ftp.riken.jp/Linux/centos/5/os/i386/images/pxeboot/vmlinuz
cd /private/tftpboot/centos5/x86_64
sudo curl -O http://ftp.riken.jp/Linux/centos/5/os/x86_64/images/pxeboot/initrd.img
sudo curl -O http://ftp.riken.jp/Linux/centos/5/os/x86_64/images/pxeboot/vmlinuz

pxelinux.cfg

$ sudo mkdir /private/tftpboot/pxelinux.cfg
$ sudo vi /private/tftpboot/pxelinux.cfg/default
label centos5_i386
  kernel centos5/i386/vmlinuz
  append load initrd=centos5/i386/initrd.img devfs=nomount
label centos5_x86_64
  kernel centos5/x86_64/vmlinuz
  append load initrd=centos5/x86_64/initrd.img devfs=nomount

dhcpd.conf

$ sudo vi /opt/local/etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
 
subnet 192.168.1.0 netmask 255.255.255.0 {
   option routers              192.168.1.254;
   option subnet-mask          255.255.255.0;
   option domain-name          "maruko2.com";
   option domain-name-servers  192.168.1.50;
   range                       192.168.1.1 192.168.1.254;
   default-lease-time          21600;
   max-lease-time              43200;
   filename                    "pxelinux.0";
}

dhcpd.leases

$ sudo touch /opt/local/var/db/dhcpd/dhcpd.leases

起動

$ sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.dhcpd.plist 

停止

$ sudo launchctl unload /System/Library/LaunchDaemons/tftp.plist
$ sudo launchctl unload /Library/LaunchDaemons/org.macports.dhcpd.plist
LINEで送る このエントリーをはてなブックマークに追加
個人用ツール
名前空間
変種
表示
操作
案内
ツールボックス

注目のページ

このサイトのはてなブックマーク数