当前位置:   article > 正文

CentOS7 搭建 pxe 环境,安装UOS_uos pxe

uos pxe

PXE协议详解:

        PXE,预启动执行环境(Preboot eXecution Environment,PXE,也被称为预执行环境)提供了一种使用网络接口(Network Interface)启动计算机的机制。这种机制让计算机的启动可以不依赖本地数据存储设备(如硬盘)或本地已安装的操作系统。

        PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动。协议分为client和server两端,支持工作站通过网络从远端服务器下载映像,并由此支持来自网络的操作系统的启动过程,其启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中并执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务器中的终端操作系统

PXE工作原理:

    1.PXE client从自己的PXE网卡启动,向本网络中的DHCP服务器请求ip地址

    2.DHCP服务器收到dhcp请求后,分配dhcp地址池中ip给PXE client

    3.PXE client向本网络中的TFTP服务器索取bootstarp文件(core.efi)

    4.PXE client取得bootstarp文件后之执行pxelinux.0(grub.cfg)文件引导,使用pxelinux环境来引导os安装程序。

    5.PXE client然后读取pxelinux.cfg(mips64el)文件夹中的default(grub.cfg)引导文件,通过TFTP服务器加载内核vmlinuz和根文件系统(boot.msg,vesamenu.c32,initrd.img,splash.jpg),根据grub启动菜单选择共享服务器nfs上面下载系统安装包开始安装系统。

服务安装及配置流程(虚拟机IP:192.168.1.228)

一、DHCP安装及配置

  1. [root@localhost ~]# yum install -y dhcp*
  2. [root@localhost ~]# vim /etc/dhcp/dhcpd.conf
  3. ##############dhcp.conf
  4. default-lease-time 600;
  5. max-lease-time 7200;
  6. ddns-update-style none;
  7. option space PXE;
  8. option PXE.mtftp-ip code 1 = ip-address;
  9. option PXE.mtftp-cport code 2 = unsigned integer 16;
  10. option PXE.mtftp-sport code 3 = unsigned integer 16;
  11. option PXE.mtftp-tmout code 4 = unsigned integer 8;
  12. option PXE.mtftp-delay code 5 = unsigned integer 8;
  13. option arch code 93 = unsigned integer 16;
  14. subnet 192.168.1.0 netmask 255.255.255.0 {
  15. #option routers 192.168.1.254;
  16. option time-offset -18000;
  17. range dynamic-bootp 192.168.1.2 192.168.1.253;
  18. default-lease-time 21600;
  19. max-lease-time 43200;
  20. #range 192.168.1.2 192.168.1.253
  21. class "pxeclinets" {
  22. match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
  23. next-server 192.168.1.228; #服务器IP,也就是本地IP
  24. if option arch = 00:07 or arch = 00:09 {
  25. filename "uefi/core.efi";
  26. } else {
  27. #filename "pxelinux/pxelinux.0";
  28. filename "core.efi"; #引导文件
  29. }
  30. }
  31. }
  32. #############dhcp.conf
  33. [root@localhost ~]# systemctl start dhcpd
  34. [root@localhost ~]# systemctl enable dhcpd

二、TFTP安装及配置

  1. [root@localhost ~]# yum install -y tftp*
  2. ##安装xinetd守护进程,因为tftp依赖于xinetd
  3. [root@localhost ~]# yum install -y xinetd
  4. [root@localhost ~]# vim /etc/xinetd.d/tftp
  5. # default: off
  6. # description: The tftp server serves files using the trivial file transfer \
  7. # protocol. The tftp protocol is often used to boot diskless \
  8. # workstations, download configuration files to network-aware printers, \
  9. # and to start the installation process for some operating systems.
  10. service tftp
  11. {
  12. socket_type = dgram
  13. protocol = udp
  14. wait = yes
  15. user = root
  16. server = /usr/sbin/in.tftpd
  17. server_args = -s /var/lib/tftpboot #这里是默认路径(即为根目录)
  18. disable = no #这里改为no
  19. per_source = 11
  20. cps = 100 2
  21. flags = IPv4
  22. }
  23. ~
  24. ~

关闭并配置开机自动关闭系统防火墙(重要!否则会导致PXE Client无法访问TFPT服务)

# systemctl stop firewalld

# systemctl disable firewalld

启动并配置开机自动启动xinetd进程

# systemctl start xinetd  systemctl restart xinetdtftp服务搜xinetd服务管理)

# systemctl enable xinetd

# systemctl start tftp

三、NFS安装及配置(nfs-utils)

  1. [root@localhost ~]# yum install -y nfs*
  2. [root@localhost ~]# systemctl start nfs
  3. [root@localhost ~]# systemctl enable nfs
  4. [root@localhost ~]# systemctl status nfs
  5. [root@localhost ~]# vim /etc/exports
  6. ######配置iso文件路径及IP(虚拟机光驱路径)
  7. /run/media/root/UOS 192.168.1.228/24(rw,sync,all_squash)
  8. ######配置iso文件路径及IP
  9. ######挂载文件目录
  10. [root@localhost ~]# exportfs -a
  11. [root@localhost ~]# showmount -e 192.168.1.228
  12. [root@localhost ~]# systemctl restart rpcbind
  13. [root@localhost ~]# systemctl restart nfs

Loongarch平台安装文件准备及配置

1、根据dhcp.conf放置core.efi文件

 2、提取ISO中grub.cfg文件到/var/lib/tftpboot/目录

  1. set default=1
  2. set timeout=6
  3. set menu_color_normal=white/black
  4. set menu_color_highlight=yellow/black
  5. search --no-floppy --set=root -l 'Fedora-MATE'
  6. menuentry 'Install UnionTech OS Desktop 20 Professional' {
  7. echo 'Loading kernel ...'
  8. linux /boot/vmlinuz-4.19.0-loongson-3-desktop root=live:CDLABEL=UOS console=ttyS0,115200 rdinit=/init loongson loglevel=7 ro rd.live.image rd.live.dir=live rd.live.squashimg=filesystem.squashfs livecd-installer locales=zh_CN.UTF-8 boot=live rd.luks=0 rd.md=0
  9. echo 'Loading ramdisk ...'
  10. initrd /boot/initrd.img-4.19.0-loongson-3-desktop
  11. echo 'boot ...'
  12. boot
  13. echo 'after boot ...'
  14. }
  15. menuentry 'PXE Install UOS' {
  16. echo 'Loading kernel ...'
  17. linux /mips64el/vmlinuz-4.19.0-loongson-3-desktop root=/dev/nfs nfsroot=192.168.1.228:/run/media/root/UOS rw loglevel=7 console=ttyS0,115200 console=tty rd.live.image rd.live.dir=live rd.live.squashimg=filesystem.squashfs livecd-installer locales=zh_CN.UTF-8 boot=live rd.luks=0 rd.md=0 rd.debug ip=dhcp
  18. #linux /mips64el/vmlinuz-4.19.0-loongson-3-desktop root=/dev/nfs nfsroot=192.168.1.228:/var/nfs/mips64el rw console=tty livecd-installer locales=zh_CN.UTF-8 boot=live
  19. echo 'Loading initrd ...'
  20. initrd /mips64el/initrd.img-4.19.0-loongson-3-desktop
  21. }
  22. menuentry 'Test Install OS' {
  23. echo 'Loading kernel ...'
  24. linux /mips64el/vmlinuz-4.19.0-loongson-3-desktop root=/dev/nfs nfsroot=192.168.1.228:/mnt/hgfs/vmshare/loongarch64 rw loglevel=7 console=ttyS0,115200 console=tty rd.live.image rd.live.dir=live rd.live.squashimg=filesystem.squashfs livecd-installer locales=zh_CN.UTF-8 boot=live rd.luks=0 rd.md=0 rd.debug ip=dhcp
  25. echo 'Loading ramdisk ...'
  26. initrd /mips64el/initrd.img-4.19.0-loongson-3-desktop
  27. boot
  28. }

 3、根据exports中设置的共享路径设置grub.cfg文件

 4、根据grub.cfg文件放置系统内核文件(vmlinuz,initrd.img)

 /var/lib/tftpboot为根目录

************注意事项************

1、权限不足,exports中要添加(rw,sync,all_squash)

 2、IP不正确,要与exports中地址一致

 3、nfs未正常开启

 4、未正确配置exports并启用

 5、内核文件有问题(vmlinuz)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/889066
推荐阅读
相关标签
  

闽ICP备14008679号