yum -y install tftp-server httpd dhcp syslinux
html
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
egrep -v "^#|^$" /etc/dhcp/dhcpd.conf
linux
option domain-name "contoso.com"; option domain-name-servers ns1.contoso.com, contoso.com; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 192.168.10.0 netmask 255.255.255.0 { //服務端IP網段及掩碼 option routers 192.168.10.254; //網關 option subnet-mask 255.255.255.0; //掩碼 option domain-name-servers 192.168.10.2; range dynamic-bootp 192.168.10.100 192.168.10.120; //dhcp分發的地址範圍 default-lease-time 21600; //設置默認的IP租用期限 max-lease-time 43200; //設置最大的IP租用期限 next-server 192.168.10.7; //TFTP服務器地址 filename "pxelinux.0"; //指定引導文件位置,這裏是TFTP根目錄下的pxelinux.0 }
systemctl start dhcpd.service
# default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = yes per_source = 11 cps = 100 2 flags = IPv4 }
[Unit] Description=Tftp Server Requires=tftp.socket Documentation=man:in.tftpd [Service] ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot StandardInput=socket [Install] Also=tftp.socket
啓動tftp-server服務
systemctl start tftp.socket
vim
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
#基於pxe安裝使用的光盤上的文件(本身本地掛載光盤便可)或者是yum倉庫裏mkdir /var/lib/tftpboot/pxelinux.cfg/
default menu.c32 #加載時顯示的默認菜單控制的程序(配置沒法啓動,menu.c32 改爲Linux) prompt 5 #顯示提示符時間 timeout 30 #超時時長 MENU TITLE CentOS 7 PXE Menu #標題爲CentOS7 PXE Menu LABEL linux #指明下面菜單項的label MENU LABEL Install CentOS 7 x86_64 #菜單的label KERNEL vmlinuz #指明kernel文件 APPEND initrd=initrd.img inst.repo=http://192.168.121.17/centos7 ks=http://192.168.121.17/centos7.cfg #附加給kernel的參數,inst.repo能夠是教室的ftp服務器,或者把光盤當作yum倉庫,把它做爲一個網站的訪問就能夠了
mkdir -pv /media/cdrom
mount -r /dev/cdrom /media/cdrom
mkdir -pv /var/www/html/centos7/
mount --bind /media/cdrom /var/www/html/centos7
centos
#platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$kncWgT41$Z37pYAKljSaTTQ4EadDqE1 # Use network installation url --url="http://10.2.1.10/centos7" # System language lang en_US # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Firewall configuration firewall --disabled # Network information network --bootproto=dhcp --device=ens33 network --hostname=localhost.pxe # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="xfs" --size=1024 part swap --fstype="swap" --size=4096 part / --fstype="xfs" --grow --size=1 %post systemctl disable postfix.service %end %packages @^minimal @compat-libraries @debugging @development bash-completion dos2unix lrzsz nmap sysstat tree vim wget %end