Howto pxe install centos

From Vidalinux Wiki
Jump to navigation Jump to search

install packages

first we install the following packages:

yum install xinetd dhcp vsftpd syslinux syslinux-tftpboot bind-chroot system-config-kickstart tftp tftp-server -y

configure network

configure your network ip address as static:

nmcli con add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 192.168.1.24/24 ipv4.gateway 192.168.1.24 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes
nmcli con up eth0

configure dhcpd server

create dhcpd config file /etc/dhcp/dhcpd.conf:

Allow booting;
Allow bootp;
authoritative;

# Subnet definition
subnet 192.168.1.0 netmask 255.255.255.0 {
# Parameters for the local subnet
option routers               192.168.1.254;
option subnet-mask           255.255.255.0;
option domain-name           "example.com";
option domain-name-servers   192.168.1.254;
default-lease-time           21600;
max-lease-time               43200;
# Client IP range
range dynamic-bootp 192.168.1.100 192.168.1.200;
filename  "pxelinux.0";
next-server  192.168.1.24;
}

configure dhcpd daemon:

cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/

add network interface to/usr/lib/systemd/system/dhcpd.service:

ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid eth0

enable service daemon:

systemctl daemon-reload
systemctl enable --now dhcpd

configure tftp server

configure tftp service edit /etc/xinetd.d/tftp:

service tftp
{
	socket_type		= dgram
	protocol		= udp
	wait			= yes
	user			= root
	server			= /usr/sbin/in.tftpd
	server_args		= -s /var/lib/tftpboot
	disable			= no
	per_source		= 11
	cps			= 100 2
	flags			= IPv4
}

start and enable service:

systemctl enable --now xinetd

configure pxe content

create temporary directory and download centos iso:

mkdir /usr/share/isos && cd /usr/share/isos
wget http://centos.osuosl.org/7.8.2003/isos/x86_64/CentOS-7-x86_64-DVD-2003.iso

add the following line to /etc/fstab:

/usr/share/isos/CentOS-7-x86_64-DVD-2003.iso /var/ftp/install/centos/x86_64/7.8	iso9660 loop 0 0

mount the iso:

mount /var/ftp/install/centos/x86_64/7.8

create directories and copy related files to /var/lib/tftpboot:

mkdir /var/lib/tftpboot/pxelinux.cfg
mkdir /var/lib/tftpboot/networkboot
cp /tftpboot/images/centos/x86_64/7.8/* /var/lib/tftpboot/networkboot/

create the following pxelinux.cfg configuation:

timeout 100
default menu.c32

menu title PXE installation
LABEL CentoS 7.8 x86_64
MENU LABEL CentOS 7.8 x86_64
KERNEL /networkboot/vmlinuz
append vga=normal initrd=/networkboot/initrd.img inst.repo=ftp://192.168.24.202/install/centos/x86_64/7.8 ramdisk_size=32768