[PXE] PXE環境の構築メモ

TFTPサーバ

インストール&起動

$ apt-get install -y tftpd-hpa

TFTP設定

root@TX120S3-02:/home/ftp# cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/ftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

自動起動

$ systemctl enable tftpd-hpa
$ systemctl restart tftpd-hpa

DHCPサーバ

インストール

$ apt-get install -y isc-dhcp-server

DHCPサーバ設定

$ cat <<EOF > /etc/dhcp/dhcpd.conf
subnet 192.168.25.0 netmask 255.255.255.0 {
  range 192.168.25.10 192.168.25.250;
  option domain-name-servers 8.8.8.8;
  filename "pxelinux.0";
}
EOF

自動起動

$ systemctl enable isc-dhcp-server

Ubuntuイメージの準備

イメージ解凍

$ wget -q http://ftp.riken.jp/Linux/ubuntu/dists/xenial/main/installer-amd64/current/images/netboot/netboot.tar.gz -O ubuntu-16.04-netboot.tar.gz
$ mkdir ubuntu-16.04-netboot
$ tar zxf ubuntu-16.04-netboot.tar.gz -C ubuntu-16.04-netboot

TFTPの準備

$ mkdir -p /home/ftp
$ tftpboot_dir=/home/ftp
$ sudo cp -a ubuntu-16.04-netboot/ubuntu-installer /home/ftp/
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/pxelinux.0 ${tftpboot_dir}/
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/ldlinux.c32 ${tftpboot_dir}/
$ sudo mkdir ${tftpboot_dir}/boot-screens
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/libcom32.c32 ${tftpboot_dir}/boot-screens
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/libutil.c32 ${tftpboot_dir}/boot-screens
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/vesamenu.c32 ${tftpboot_dir}/boot-screens
$ sudo mkdir ${tftpboot_dir}/pxelinux.cfg
$ cd ${tftpboot_dir}/pxelinux.cfg
$ sudo ln -s ../boot-screens/syslinux.cfg default

$ cat <<EOF > ${tftpboot_dir}/boot-screens/syslinux.cfg
path boot-screens
include boot-screens/menu.cfg
default boot-screens/vesamenu.c32
prompt 0
timeout 100
console 0
serial 0 115200 0
EOF


$ cat <<EOF > ${tftpboot_dir}/boot-screens/menu.cfg
menu hshift 13
menu width 49
menu margin 8
menu tabmsg

menu title Installer boot menu
label auto-ubuntu-16.04
        menu label ^Ubuntu 16.04 automated install
        kernel ubuntu-installer/amd64/linux
        append auto=true priority=critical vga=788 initrd=ubuntu-installer/amd64/initrd.gz preseed/url=tftp://192.168.25.3/preseed/ubuntu-16.04-preseed.cfg preseed/interactive=false console=tty0 console=ttyS0,115200n8r
menu begin ubuntu-16.04
        menu title Ubuntu 16.04
        label mainmenu
                menu label ^Back..
                menu exit
        include ubuntu-installer/amd64/boot-screens/menu.cfg
menu end
EOF


$ cat <<EOF > ${tftpboot_dir}/preseed/ubuntu-16.04-preseed.cfg
d-i debian-installer/locale string en_US
d-i debian-installer/language string en
d-i debian-installer/country string JP
d-i keyboard-configuration/xkb-keymap select jp106
d-i passwd/user-fullname string
d-i passwd/username string ubuntu
d-i passwd/root-password password ubuntu
d-i passwd/root-password-again password ubuntu
d-i passwd/user-password password ubuntu
d-i passwd/user-password-again password ubuntu
d-i user-setup/allow-password-weak boolean true
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i mirror/country string manual
d-i mirror/http/hostname string http://jp.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true
d-i time/zone string Asia/Tokyo
d-i partman/confirm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm_nooverwrite boolean true
d-i partman-auto/disk string /dev/[sv]da
d-i partman-auto/method string lvm
d-i partman-auto/choose_recipe select atomic
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-partitioning/confirm_write_new_label boolean true
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string /dev/[sv]da
d-i pkgsel/update-policy select none
d-i pkgsel/include string unity ubuntu-desktop openssh-server

### Running post-install !!
d-i preseed/late_command string \
    cp /ubuntu-16.04-postinstall /target/post-install; \
    cd /target; \
    chroot ./ ./post-install; \
    rm -f ./post-install

d-i pkgsel/update-policy select none
d-i pkgsel/include string unity ubuntu-desktop openssh-server
d-i finish-install/reboot_in_progress note

EOF

対象ホストをipmitoolsよりPEXで起動させる

t-kawano@maas:~$ sudo ipmitool -I lanplus -H t03-ipmi -U admin -P admin chassis bootdev pxe
t-kawano@maas:~$ sudo ipmitool -I lanplus -H t03-ipmi -U admin -P admin power reset

Updated: 2018年12月8日 — 12:23 PM

Leave a Reply

Your email address will not be published. Required fields are marked *

備忘録の覚書 © 2017 Frontier Theme