Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up PXE on Ubuntu

Package Requirements

apt install isc-dhcp-server tftpd-hpa inetutils-inetd pxelinux nginx

DHCP

cp -pi /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.dist
vi /etc/dhcp/dhcpd.conf

allow bootp;
ddns-update-style none;
allow unknown-clients;

subnet 10.0.0.0 netmask 255.255.252.0 {
}

subnet 10.8.8.0 netmask 255.255.255.0 {
        range 10.8.8.100 10.8.8.199;
        next-server 10.8.8.1;
        filename "pxelinux.0";
}

#allow booting;
#option option-128 code 128 = string;
#option option-129 code 129 = text;

ifconfig NETWORK_INTERFACE 10.8.8.1/24 up
tail -F /var/log/syslog &
systemctl restart isc-dhcp-server

resulting process,

dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

TFTP

cp -pi /etc/default/tftpd-hpa /etc/default/tftpd-hpa.dist
vi /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -s"
RUN_DAEMON="yes"

ls -lhF /usr/sbin/in.tftpd
systemctl restart tftpd-hpa

resulting process,

/usr/sbin/in.tftpd --listen --user tftp --address :69 -l -s /var/lib/tftpboot

CentOS Repositories

#mkdir mnt/; mount CentOS-7-x86_64-DVD-1708.iso mnt/
#cp -R mnt/ /var/lib/tftpboot/CentOS7x64-1708/
#umount mnt/; rmdir mnt/

Choose a mirror.

remote="rsync://mirror.yandex.ru/centos/"
#remote="rsync://mirror.logol.ru/centos/"

rsync -az --delete $remote/7.4.1708/os/x86_64/ centos7x64/
unset remote

PXE Configuration

ls -ldhF /var/lib/tftpboot

cp -i /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftpboot/
cp -i /usr/lib/syslinux/modules/bios/libutil.c32 /var/lib/tftpboot/
#cp -i /usr/lib/syslinux/modules/bios/meminfo.c32 /var/lib/tftpboot/
cp -i /usr/lib/syslinux/modules/bios/menu.c32 /var/lib/tftpboot/
cp -i  /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftpboot/

mkdir /var/lib/tftpboot/pxelinux.cfg/
vi /var/lib/tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
menu title PXE

label centos7x64 rescue
kernel ../centos7x64/images/pxeboot/vmlinuz
append initrd=../centos7x64/images/pxeboot/initrd.img ip=dhcp method=http://10.8.8.1/centos7x64/ rescue

label centos7x64 installer
kernel ../centos7x64/images/pxeboot/vmlinuz
append initrd=../centos7x64/images/pxeboot/initrd.img ip=dhcp method=http://10.8.8.1/centos7x64/ text

label centos7x64 DANGEROUS AUTOMATED INSTALL
kernel ../centos7x64/images/pxeboot/vmlinuz
append initrd=../centos7x64/images/pxeboot/initrd.img ip=dhcp method=http://10.8.8.1/centos7x64/ ks=http://10.8.8.1/centos7x64.cfg text

HTTP

vi /etc/nginx/sites-enabled/default

    root /var/lib/tftpboot;

    systemctl restart nginx
    curl -s localhost
    curl -s localhost/CentOS7x64-1708/

References


Home | GitHub | Donate | Contact