pxe远程装机

1:主机 yum install dhcp

    vim /etc/dhcp/dhcpd.conf

      allow booting;
      allow bootp;
      ddns-update-style interim;
      ignore client-updates;
      subnet 192.168.10.0 netmask 255.255.255.0 {
      option subnet-mask 255.255.255.0;
      option domain-name-servers 192.168.10.10;
      range dynamic-bootp 192.168.10.100 192.168.10.200;
      default-lease-time 21600;
      max-lease-time 43200;
      next-server 192.168.10.10;
      filename "pxelinux.0";

      }

  systemctl restart dhcpd.service

  systemctl enable dhcpd.service

2:主机 yum install tftp-server

    yum install xinetd

    vim /etc/xinetd.d/tftp     

      service tftp
      {
        socket_type = dgram
        protocol = udp
        wait = yes
        user = root
        server = /usr/sbin/in.tftpd
        server_args = -s /var/lib/tftpboot
        disable = no
        per_source = 11
        cps = 100 2
        flags = IPv4
      }

    systemctl restart xinetd.service

    firewall-cmd --permanent --add-port=69/udp

    firewall-cmd --reload

3:主机 yum install syslinux

    cd /var/lib/tftpboot

    cp /usr/share/syslinux/pxelinux.0 .

    cp /media/cdrom/images/pxeboot/initrd.img .

    cp /media/cdrom/images/pxeboot/vmlinuz .

    cp /media/cdrom/isolinux/vesamenu.c32 .

    cp /media/cdrom/isolinux/boot.msg .

    mkdir pxelinux.cfg

    cp /media/cdrom/isolinux/isolinux.cfg pxelinux.cfg/default

    vim pxelinux.cfg/default

      default linux
      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 CentOS 7
      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 linux
      menu label ^Install CentOS 7
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=ftp://192.168.10.10 ks=ftp://192.168.10.10/pub/ks.cfg

      label check
      menu label Test this ^media & install CentOS 7
      menu default
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

      menu separator # insert an empty line

      # utilities submenu
      menu begin ^Troubleshooting
      menu title Troubleshooting

      label vesa
      menu indent count 5
      menu label Install CentOS 7 in ^basic graphics mode
      text help
      Try this option out if you're having trouble installing
      CentOS 7.
      endtext
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet

      label rescue
      menu indent count 5
      menu label ^Rescue a CentOS system
      text help
      If the system will not boot, this lets you access files
      and edit config files to try to get it booting again.
      endtext
      kernel vmlinuz
      append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet

      label memtest
      menu label Run a ^memory test
      text help
      If your system is having issues, a problem with your
      system's memory may be the cause. Use this utility to
      see if the memory is working correctly.
      endtext
      kernel memtest

      menu separator # insert an empty line

      label local
      menu label Boot from ^local drive
      localboot 0xffff

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

      label returntomain
      menu label Return to ^main menu
      menu exit

      menu end

4:主机 yum install vsftpd

    systemctl start vsftpd

    systemctl enable vsftpd

    mkdir /var/ftp

    cp -r /media/cdrom/*  /var/ftp

     firewall-cmd --permanent --add-service=ftp

    firewall-cmd --reload

    setsebool -P ftpd_connect_all_unreserved=on

5:主机 mkdir /var/ftp/pub 

    cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg 

    chmod +r /var/ftp/pub/ks.cfg

    vim /var/ftp/pub/ks.cfg   

      #version=DEVEL
      # System authorization information
      auth --enableshadow --passalgo=sha512
      # Use network installation
      url --url="ftp://192.168.10.10"
      # Use text mode install
      text
      # Run the Setup Agent on first boot
      firstboot --enable
      ignoredisk --only-use=sda
      # Keyboard layouts
      keyboard --vckeymap=cn --xlayouts='cn'
      # System language
      lang zh_CN.UTF-8

      # Network information
      network --bootproto=dhcp --device=ens32 --ipv6=auto --no-activate
      network --bootproto=dhcp --hostname=localhost.localdomain
      # Reboot after installation
      reboot
      # Root password
      rootpw --iscrypted $1$zSb4zHfv$YkSNEfHrZhbbDwL2LGTwJ.
      # System services
      services --enabled="chronyd"
      # System timezone
      timezone Asia/Shanghai --isUtc
      # X Window System configuration information
      xconfig --startxonboot
      # System bootloader configuration
      bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
      # Partition clearing information
      clearpart --all --initlabel
      # Disk partitioning information
      part pv.49 --fstype="lvmpv" --ondisk=sda --size=20279
      part /boot --fstype="xfs" --ondisk=sda --size=200
      volgroup centos --pesize=4096 pv.49
      logvol / --fstype="xfs" --size=18367 --name=root --vgname=centos
      logvol swap --fstype="swap" --size=1907 --name=swap --vgname=centos

      %packages
      @^graphical-server-environment
      @base
      @core
      @desktop-debugging
      @dial-up
      @fonts
      @gnome-desktop
      @guest-agents
      @guest-desktop-agents
      @hardware-monitoring
      @input-methods
      @internet-browser
      @multimedia
      @print-client
      @x11
      chrony
      kexec-tools
      kexec-tools

      %end

      %addon com_redhat_kdump --enable --reserve-mb='auto'

      %end

      %anaconda
      pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
      pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
      pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
      %end

6 :客户机开机从主机能获取IP地址既能自动安装!


posted on 2019-06-15 17:52  西虹市市长  阅读(172)  评论(0编辑  收藏  举报

导航