尝试自动装机,同时重点了解pxe过程。

Overview

PXE

  • Preboot Execute Environment, supported by Intel.
  • Booting in this mode, client gets it’s own ip and tftp server ip by DHCP.
  • Fetch pxelinux.0 from tftp server and then follow it.
  • pxelinux.cfg contains serveral menus recording booting process.
1
2
3
4
5
6
7
8
default menu.c32
#prompt 0
timout 30
MENU TITLE LinuxTech PXE Menu
LABEL centos7_64
MENU LABEL CentOS 7_x64
KERNEL vmlinuz
APPEND initrd=initrd.img ks=http://xx.xx.xx.xx/ks.cfg
  • Here we only have one item that means installing operating system by kickstart.

DHCP

  • It’s easy to start a DHCP server, but here we need to configure a next-server which locate the tftps server.
  • yum -y install dhcp
  • /etc/dhcp/dhcpd.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# DHCP Server Configuration file.

ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;
allow unknown-clients;

# internal subnet for my DHCP Server
subnet 172.16.35.0 netmask 255.255.255.0 {
range 172.16.35.100 172.16.35.200;
default-lease-time 600;
max-lease-time 7200;

# IP of PXE Server
next-server 172.168.35.10;
filename "pxelinux.0";
}

Tftp Server

  • Trivial File Transfer Protocol, Port 69.
  • We transfer pxelinux.cfg and networkboot/* through tftp.

GUI

1
2
3
yum groupinstall "X Window System"
yum groupinstall "GNOME Desktop"
startx

Kick Start

  • Make a ks.cfg by desktop ui.
  • Config
    • Root password
    • Network
    • Disk Parition

FTP and HTTP

  • Using FTP or HTTP to supply .iso to clients.
  • FTP
    • root directory: /var/ftp/
    • I found /var/ftp/pub had a special authority, read-only file is hidden in that direcotry.
    • We can use other path. /var/ftp/centos
  • HTTP
    • root directory: /var/www/html/
    • mount Centos7.iso /var/www/html/centos

Firewall

  • Enable ports
    • 69
    • 4011
  • Enabel services
    • dhcp
    • ftp
    • http
1
2
3
4
5
6
firewall-cmd --add-service=ftp --permanent
firewall-cmd --add-service=dhcp --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=69/tcp --permanent
firewall-cmd --add-port=69/udp --permanent
firewall-cmd --add-port=4011/udp --permanent

Start Service

1
2
3
4
5
systemctl start xinetd
systemctl start dhcpd
systemctl start vsftpd
systemctl start httpd
systemctl start tftp

Problems

  • Memory
    • I recommend that the client(not installer) has more than 2GB memory.
    • When using VMware to simulate, 1GB memory traps in trouble.

Reference