X86

1、环境准备

  • Centos7.6 mini版
  • DHCP服务器地址(虚拟机):192.168.100.100
  • TFTP服务器地址(虚拟机):192.168.100.100
  • 物理机地址(网关地址):192.168.100.1
  • 操作系统基目录,为每个操作系统创建单独的目录,需要时将ISO挂载对应目录即可。该目录为httpd服务的工作目录
    /var/www/html/
  • 放置系统的内核文件,该目录为TFTP工作目录
    /pxeserver/tftp

2、安装配置DHCP服务

  • 安装DHCP服务

    [root@bogon yum.repos.d]# yum install dhcp -y
    [root@bogon ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 
    [root@bogon ~]# cd /etc/dhcp/
    [root@bogon dhcp]# cp dhcpd.conf{,.bak}
    
  • 配置修改
    DHCP配置文件的修改位置及内容:

     47 subnet 192.168.100.0 netmask 255.255.255.0 {
     48   range 192.168.100.101 192.168.100.254;
     49   option domain-name-servers 114.114.114.114;
     50   option domain-name "pxeserver.local";
     51   option routers 192.168.100.1;
     52   option broadcast-address 192.168.100.255;
     53   default-lease-time 600;
     54   max-lease-time 7200;
     55   filename "pxelinux.0";
     56   next-server 192.168.100.100;
     57 }

    配置的网段根据实际中试用的网段配置,其中filename为pxe启动文件,next-server为TFTP服务器地址,由于DHCP、TFTP、HTTP等服务在同一台服务器上所以可以直接填写pxe服务器地址。

  • 启动服务并设置为开启自启动

    [root@localhost ~]# systemctl start dhcpd
    [root@localhost ~]# systemctl enable dhcpd

3、安装TFTP服务

  • 安装TFTP服务

    [root@localhost ~]# yum install xinetd tftp*
  • 配置tftp服务

    service tftp
    {
          socket_type             = dgram
          protocol                = udp
          wait                    = yes
          user                    = root
          server                  = /usr/sbin/in.tftpd
          server_args             = -s /pxeserver/tftp -c
          disable                 = no
          per_source              = 11
          cps                     = 100 2
          flags                   = IPv4
    }
  • 启动TFTP服务并设置开机自启

    [root@localhost ~]# systemctl start tftp
    [root@localhost ~]# systemctl enable tftp
    

4、安装配置SYSLINUX

  • 安装syslinux

    [root@localhost ~]# yum install syslinux* -y
  • 将相应文件拷贝到对应目录下

    [root@localhost ~]# cp -rp /usr/share/syslinux/* /pxeserver/tftp/ 
  • 创建pxelinux.cfg目录

    [root@localhost ~]# mkdir /pxeserver/tftp/pxelinux.cfg

5、安装配置HTTPD

  • 安装http服务

    [root@localhost ~]# yum install httpd* -y
  • 启动httpd服务并设置开机自启

    [root@localhost ~]# systemctl start httpd
    [root@localhost ~]# systemctl enable httpd

6、安装操作系统

  • 在/var/www/html/下创建CentOS7目录

    [root@localhost ~]# mkdir /var/www/html/CentOS7
  • 将系统盘的文件拷贝或挂载ISO到这个目录下
  • 在/pxeserver/tftp下先创建CentOS7目录,将系统盘isolinux内的vmliniz和initrd.img文件拷贝至该目录下

    mkdir /pxeserver/tftp/CentOS7
    cp /var/www/html/CentOS7/isolinux/vmlinuz /pxeserver/tftp/CentOS7
    cp /var/www/html/CentOS7/isolinux/initrd.img /pxeserver/tftp/CentOS7
  • 创建PXE引导文件,从光盘文件的isolinux中把isolinux.cfg复制到/pxeserver/tftp/pxelinux.cfg/下并命名为default。
default vesamenu.c32
timeout 600

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title ##########PXE BOOT Menu#########
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label 1
  menu label ^Install CentOS 7 x86_64
  kernel CentOS7/vmlinuz
  append initrd=CentOS7/initrd.img inst.stage2=http://192.168.100.100/CentOS7_x86 quiet


menu separator # insert an empty line

# utilities submenu


menu separator # insert an empty line
menu separator # insert an empty line


menu end

ARM

使用dnsmapq服务,该服务可以提供DNC,DHCP和TFTP,适合小型局域网环境使用。

PXE配置文件如下:

[root@localhost ~]# cat /etc/dnsmasq.conf |egrep -v "#|^$"
port=0
interface=enp0s8
listen-address=192.168.166.10
dhcp-range=192.168.166.100,192.168.166.150,255.255.255.0
dhcp-boot=grubaa64.efi
enable-tftp
tftp-root=/var/tftp
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
[root@localhost ~]# 

tftp目录内容:

[root@localhost ~]# ll /var/tftp/
total 60976
-rwxrwxrwx 1 root root  2654208 Mar 21 03:59 grubaa64.efi
-rwxrwxrwx 1 root root      816 Mar 21 04:02 grub.cfg
-rwxrwxrwx 1 root root 52017464 Mar 21 03:58 initrd.img
-rwxrwxrwx 1 root root      441 Mar 21 03:58 TRANS.TBL
-rwxrwxrwx 1 root root  7756624 Mar 21 03:58 vmlinuz

GRUB配置文件:

[root@localhost ftpd]# cat grub.cfg 
set default="1"

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=60
### END /etc/grub.d/00_header ###

search --no-floppy --set=root -l 'BCLinux'

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install BigCloud-Enterprise-Linux-for-Euler 21.10' --class red --class gnu-linux --class gnu --class os {
        set root=(tftp,192.168.166.10)
        linux vmlinuz inst.stage2=http://192.168.166.10/BClinux ro inst.geoloc=0 console=tty0 smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me
        initrd initrd.img
}

IPXE配置

[root@localhost ~]# cat /etc/dnsmasq.conf |egrep -v "^#|^$"
port=0
interface=enp0s8
listen-address=192.168.188.10
dhcp-range=192.168.188.100,192.168.188.150,255.255.255.0
# 地址绑定
dhcp-host=90:17:3f:82:7d:70,192.168.188.110,cn1
dhcp-host=f4:b7:8d:d1:ae:32,192.168.188.111,cn2

dhcp-ignore=tag:!known
dhcp-vendorclass=BIOS,PXEClient:Arch:00000
dhcp-match=set:ipxe,175
dhcp-boot=tag:!ipxe,tag:BIOS,undionly.kpxe
dhcp-boot=tag:!ipxe,tag:!BIOS,ipxe.efi
dhcp-boot=tag:ipxe,menu/boot.ipxe

enable-tftp
tftp-root=/tftpboot
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig

tftp目录:

[root@localhost ~]# tree /tftpboot/
/tftpboot/
├── ipxe.efi
└── menu
    └── boot.ipxe

1 directory, 2 files
[root@localhost ~]# 

boot.ipex配置文件的内容:

[root@localhost ~]# cat /tftpboot/menu/boot.ipxe 
#!ipxe
:start
menu PXE Boot Options
item shell iPXE shell
item bclinux-net Bclinux 21.10 installation
item exit  Exit to BIOS
choose --default bclinux-net --timeout 10000 option && goto ${option}
:shell
shell
:bclinux-net
set server_root http://192.168.188.10/media/bclinux-21.10
initrd ${server_root}/images/pxeboot/initrd.img
kernel ${server_root}/images/pxeboot/Image inst.repo=${server_root} ip=dhcp ipv6.disable initrd=initrd.img inst.geoloc=0 devfs=nomount
boot
:exit
exit

标签: none

添加新评论