Linux--pxe安装系统

    xiaoxiao2022-06-30  108

    一.pxe的安装系统简介 PXE(预启动执行环境)工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户端)基本软件设置,从而引导预先安装在服务器中的终端操作系统。 二.pxe的工作流程 1.客户以自己的pxe网卡启动,向本网络中的DHCP端索取ip 2.DHCP服务器返回分给客户机IP以及bootstrap文件的放置位置(该文件一般是放在一台TFTP服务器上) 3. 客户机向本网络中的TFTP服务器索取bootstrap文件 4.客户机取得bootstrap文件后之执行该文件 5.根据bootstrap的执行结果,通过TFTP服务器加载内核和文件系统 6.进入安装画面, 此时可以通过选择FTP,HTTP,NFS方式之一进行安装 三.pxe的具体配置 1.安装软件

    [root@localhost ~]# yum install httpd tftp-server.x86_64 dhcp syslinux -y

    http ##用来共享安装资源 tftp ##提供tftp协议,让客户可以读取预安装环境 dhcp ##分配ip及让客户主机获取pxelinux.0文件 syslinux ##提供pxelinux.0文件 (1)火墙允许http tftp dhcp通过

    [root@localhost ~]# firewall-cmd --permanent --add-service=http success [root@localhost ~]# firewall-cmd --permanent --add-service=tftp success [root@localhost ~]# firewall-cmd --permanent --add-service=dhcp success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]# firewall-cmd --list-all public (default, active) interfaces: eth0 sources: services: dhcp dhcpv6-client http ssh tftp ports: masquerade: no forward-ports: icmp-blocks: rich rules:

    (2)开启http服务

    [root@localhost ~]# systemctl start httpd [root@localhost ~]# systemctl enable httpd ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'

    (3)配置tftp服务

    [root@localhost ~]# vim /etc/xinetd.d/tftp [root@localhost ~]# cat /etc/xinetd.d/tftp|tail -n 5 disable = no ##将yes改为no per_source = 11 cps = 100 2 flags = IPv4 } [root@localhost ~]# systemctl restart xinetd.service

    (4)配置dhcp服务 正常配置dhcp服务 删除35行以后的及27、28行

    [root@localhost ~]# vim /etc/dhcp/dhcpd.conf 7 option domain-name "westos.com"; 8 option domain-name-servers 114.114.114.114; 30 subnet 172.25.254.0 netmask 255.255.255.0 { 31 range 172.25.254.110 172.25.254.130; 32 option routers 172.25.254.250; 33 filename "pxelinux.0"; ##客户主机获得预安装环境头文件 34 next-server 172.25.254.133; ##指定头文件所在的主机的ip 35 } [root@localhost ~]# systemctl start dhcpd [root@localhost ~]# systemctl enable dhcpd

    2.设定共享文件 (1)安装共享yum源作为预安装环境

    [root@localhost ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda1 10473900 3222564 7251336 31% / devtmpfs 469332 0 469332 0% /dev tmpfs 484920 140 484780 1% /dev/shm tmpfs 484920 12808 472112 3% /run tmpfs 484920 0 484920 0% /sys/fs/cgroup /dev/mapper/vg0-vo 483670 2339 451840 1% /home /dev/sr0 3654720 3654720 0 100% /var/www/html/luck

    (2)预安装环境的制作

    [root@localhost ~]# cp -p /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot ##头文件复制至共享目录中 [root@localhost ~]# cp -p /var/www/html/luck/isolinux/* /var/lib/tftpboot/ ##isolinux/目录下有目录、内核和初始化文件等,复制到/var/lib/tftpboot/,在pexlinux.0引导客户主机访问tftp时,访问这些文件 [root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [root@localhost ~]# cp -p /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default ##pexlinux.0的配置文件是/var/lib/tftpboot/pxelinux.cfg/default [root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default 61 label linux 62 menu label ^Install Red Hat Enterprise Linux 7.0 63 kernel vmlinuz 64 append initrd=initrd.img repo=http://172.25.254.133/luck http://172.25.254 /133/ks.cfg ##指定系统安装源,指定自动安装文件

    生成ks.cfg自动花安装脚本参考生成ks.cfg自动安装文件 四.测试安装 进入安装系统


    最新回复(0)