Howto pxe install centos: Difference between revisions

From Vidalinux Wiki
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
= install packages =
= install packages =
install epel repo:
yum install epel-release
first we install the following packages:
first we install the following packages:
  yum install xinetd dhcp vsftpd syslinux syslinux-tftpboot bind-chroot system-config-kickstart tftp tftp-server -y
  yum install xinetd dhcp vsftpd syslinux syslinux-tftpboot bind-chroot system-config-kickstart tftp tftp-server bash-completion bash-completion-extras -y
 
= configure network =
= configure network =
configure your network ip address as static:
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 add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 192.168.1.24/24 ipv4.gateway 192.168.1.254 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes
  nmcli con up eth0
  nmcli con up eth0


Line 29: Line 32:
configure dhcpd daemon:
configure dhcpd daemon:
  cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
  cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
add network interface to'''/usr/lib/systemd/system/dhcpd.service''':
add network interface to '''/etc/systemd/system/dhcpd.service''':
  ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid '''eth0'''
  ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid '''eth0'''
enable service daemon:
enable service daemon:
Line 64: Line 67:
  mkdir /var/lib/tftpboot/networkboot
  mkdir /var/lib/tftpboot/networkboot
  cp /tftpboot/images/centos/x86_64/7.8/* /var/lib/tftpboot/networkboot/
  cp /tftpboot/images/centos/x86_64/7.8/* /var/lib/tftpboot/networkboot/
create the following pxelinux.cfg configuation:
create the following file '''/var/lib/tftpboot/pxelinux.cfg/default''':
  timeout 100
  timeout 100
  default menu.c32
  default menu.c32
Line 72: Line 75:
  MENU LABEL CentOS 7.8 x86_64
  MENU LABEL CentOS 7.8 x86_64
  KERNEL /networkboot/vmlinuz
  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
  append vga=normal initrd=/networkboot/initrd.img inst.repo=ftp://192.168.1.24/install/centos/x86_64/7.8 ramdisk_size=32768
start and enable vsftpd service:
start and enable vsftpd service:
  systemctl enable --now vsftpd
  systemctl enable --now vsftpd
= configure kickstart =
if you have a redhat.com account visit the following url to create your kickstart:
https://access.redhat.com/labs/kickstartconfig
if not use the following tool:
system-config-kickstart --generate mykickstart.cfg
edit the your kickstart:
# Turning on text-mode installation (little quicker than GUI)
text
# Setting up authentication and keyboard
auth --enableshadow --passalgo=sha512
keyboard --vckeymap=us --xlayouts='us'
# Installation files source (CentOS-7.0-1406-x86_64-Minimal.iso)
url --url="ftp://192.168.1.24/install/centos/x86_64/7.8"
# Using only primary disk, ignoring others
ignoredisk --only-use=sda
# Setting up language to English
lang en-US.UTF-8
# Setting up network interface to DHCP
network --bootproto=dhcp --ipv6=auto --hostname=centos-ks.local --activate
# Root password (remember that plaintext only for information purposes)
rootpw --plaintext centos
# Setting up firewall and enabling SSH for remote management
firewall --enabled --service=ssh
# Setting timezone
timezone America/Puerto_Rico
# Setting up Security-Enhanced Linux into enforcing
selinux --enforcing
# Setting up MBR
bootloader --location=mbr --boot-drive=sda
# Setting up Logical Volume Manager and autopartitioning
clearpart --all --drives=sda --initlabel
autopart --type=lvm
# Eject cdrom and reboot
reboot --eject
# Installing only packages for minimal install
%packages
@Core
chrony
%end
copy your kickstart file to ftp:
mkdir /var/ftp/install/ks
cp mykickstart.cfg /var/ftp/install/ks/
edit to add kickstart to '''/var/lib/tftpboot/pxelinux.cfg/default''':
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.1.24/install/centos/x86_64/7.8 ks=ftp://192.168.1.24/install/ks/mykickstart.cfg ramdisk_size=32768
= boot your machine =
to install using this server just boot the machine on the same network and select pxe boot

Latest revision as of 04:51, 16 October 2020

install packages

install epel repo:

yum install epel-release

first we install the following packages:

yum install xinetd dhcp vsftpd syslinux syslinux-tftpboot bind-chroot system-config-kickstart tftp tftp-server bash-completion bash-completion-extras -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.254 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 /etc/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 file /var/lib/tftpboot/pxelinux.cfg/default:

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.1.24/install/centos/x86_64/7.8 ramdisk_size=32768

start and enable vsftpd service:

systemctl enable --now vsftpd

configure kickstart

if you have a redhat.com account visit the following url to create your kickstart:

https://access.redhat.com/labs/kickstartconfig

if not use the following tool:

system-config-kickstart --generate mykickstart.cfg

edit the your kickstart:

# Turning on text-mode installation (little quicker than GUI)
text 

# Setting up authentication and keyboard
auth --enableshadow --passalgo=sha512
keyboard --vckeymap=us --xlayouts='us'

# Installation files source (CentOS-7.0-1406-x86_64-Minimal.iso)
url --url="ftp://192.168.1.24/install/centos/x86_64/7.8"

# Using only primary disk, ignoring others
ignoredisk --only-use=sda

# Setting up language to English
lang en-US.UTF-8

# Setting up network interface to DHCP
network --bootproto=dhcp --ipv6=auto --hostname=centos-ks.local --activate

# Root password (remember that plaintext only for information purposes)
rootpw --plaintext centos

# Setting up firewall and enabling SSH for remote management
firewall --enabled --service=ssh

# Setting timezone
timezone America/Puerto_Rico

# Setting up Security-Enhanced Linux into enforcing
selinux --enforcing

# Setting up MBR
bootloader --location=mbr --boot-drive=sda

# Setting up Logical Volume Manager and autopartitioning
clearpart --all --drives=sda --initlabel
autopart --type=lvm

# Eject cdrom and reboot
reboot --eject

# Installing only packages for minimal install 
%packages
@Core
chrony
%end

copy your kickstart file to ftp:

mkdir /var/ftp/install/ks
cp mykickstart.cfg /var/ftp/install/ks/

edit to add kickstart to /var/lib/tftpboot/pxelinux.cfg/default:

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.1.24/install/centos/x86_64/7.8 ks=ftp://192.168.1.24/install/ks/mykickstart.cfg ramdisk_size=32768

boot your machine

to install using this server just boot the machine on the same network and select pxe boot