PXE
  • aliang 2022-12-28 15:02:15 1444

        相信每一位在机房工作的同仁们少不了的就装系统,少量还好当一天装个十几个二十台还是同一个系统那真是够了,可能大家会说pe里面可是克制镜像,做系统时候直接还原还是很快的,但是一个型号的机房不可能只有一个型号的设备啊,况且机房是接受托管的。那么不同型号的设备如何省时省力呢?
        那就一起来来了解下pxe+kickstart
        PXE+Kickstart无人值守安装操作系统,PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/严格来说,PXE 并不是一种安装方式,而是一种引导方式。Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务器中的终端操作系统。
        PXE+Kickstart安装
    安装过程:

    一、关闭了selinux iptables
     vim /etc/sysconfig/selinux
    更改成 SELINUX=disabled
    service iptables stop
    chkconfig iptables off

    二、配置yum源以及用yum安装
     yum install -y httpd* tftp-server-* xinetd-* system-config-kickstart-* syslinux dhcp*
    挂载Linxu iso镜像
     mount /dev/cdrom   /mnt
    cp -rf   /mnt/*   /var/www/html/
     
    三、配置tftp加载文件

    开机启动:
     vi /etc/xinetd.d/tftp
    disable                 = no 
    #disable的直由yes变为no
    加载FTP文件:
     mkdir /tftpboot/
    cd /tftpboot/
    cp /usr/lib/syslinux/pxelinux.0 /tftpboot  实验时候lib下没有syslinux目录正确cp /usr/share/syslinux/pxelinux.0 /tftpboot
    cp /var/www/html/images/pxeboot/initrd.img   /tftpboot
    cp /var/www/html/images/pxeboot/vmlinux   /tftpboot
    cp /var/www/html/images/pxeboot/vmlinux   /tftpboot
    mkdir pxelinux.cfg
    cp /var/www/html/isolinux/isolinux.cfg   /tftpboot/pxelinux.cfg/default
    四、配置dhcp文件
     vim /etc/dhcp/dhcpd.conf
     # # DHCP Server Configuration file.
    #   see /usr/share/doc/dhcp*/dhcpd.conf.sample
    ddns-update-style interim;
    ignore client-updates;
    subnet 192.168.100.0 netmask 255.255.255.0 {
    option routers 192.168.100.1;
    option subnet-mask 255.255.255.0;
    range 192.168.100.100 192.168.100.200;
    next-server 192.168.100.60;
    filename "pxelinux.0";
    allow booting;
    allow bootp;
    }
     
    五、配置KickSyack自动安装配置文件
    图形界面配置:
     #system-config-kickstart
    Could not open display because no X server is running.报错信息  由于是最小化的系统  没有桌面
    yum groupinstall "Desktop"
    yum groupinstall chinese-support
    #startx
    #system-config-kickstart
    Shell配置:参考代码区进行修改。
      
    六、后续工作重启服务以及开机启动
     service httpd restart 
    service xinetd restart
    service dhcpd restart
    chkconfig httpd on
    chkconfig xinetd on
    chkconfig dhcpd on
    代码:
     [root@wh-kickstart-100-60 ~]# vim /tftpboot/pxelinux.cfg/default
     default linux
    prompt 0
    timeout 10
    display boot.msg
    F1 boot.msg
    F2 options.msg
    F3 general.msg
    F4 param.msg
    F5 rescue.msg
    label linux
      kernel vmlinuz
      append initrd=initrd.img ks=http://192.168.100.60/ks.cfg  ksdevice=eth0 (ksdevice单网卡可以不写 多网卡必须要有 不然会卡在配置网卡界面)
    label text
      kernel vmlinuz
      append initrd=initrd.img text
    label ks
      kernel vmlinuz
      append ks initrd=initrd.img
    label local
      localboot 1
    label memtest86
      kernel memtest
      append -

     [root@wh-kickstart-100-60 ~]# vim /etc/dhcp/dhcpd.conf
     #
    # DHCP Server Configuration file.
    #   see /usr/share/doc/dhcp*/dhcpd.conf.sample  
    #
    ddns-update-style interim;
    ignore client-updates;
    subnet 192.168.100.0 netmask 255.255.255.0 {
    option routers 192.168.100.1;
    option subnet-mask 255.255.255.0;
    range 192.168.100.100 192.168.100.200;
    next-server 192.168.100.60;
    filename "pxelinux.0";
    allow booting;
    allow bootp;
    }

     [root@wh-kickstart-100-60 ~]# vim /var/www/html/ks.cfg 
     #platform=x86, AMD64, or Intel EM64T
    # System authorization information
    auth  --useshadow  --enablemd5
    # System bootloader configuration
    bootloader --location=mbr
    # Partition clearing information
    clearpart --none
    # Use graphical install
    graphical
    # Firewall configuration
    firewall --enabled
    # Run the Setup Agent on first boot
    firstboot --disable
    # System keyboard
    keyboard us
    # System language
    lang en_US
    # Installation logging level
    logging --level=info
    # Use network installation
    url --url=http://192.168.100.60/
    # Network information (网络配置需要注意的:要么自动获取  预设固定ip的话 要设置和环境一个网段的ip)
    network --bootproto=dhcp --device=eth0 --onboot=on
    #Root password
    rootpw --iscrypted $1$vraKvWxT$xevNz205XcKgz8pnf43BV1
    # SELinux configuration
    selinux --disabled
    # System timezone
    timezone  Asia/Shanghai
    # Install OS instead of upgrade
    install
    # X Window System configuration information
    xconfig  --defaultdesktop=GNOME --depth=8 --resolution=640x480
    # Disk partitioning information
    part / --bytes-per-inode=4096 --fstype="ext3" --size=4096
    part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
    part swap --bytes-per-inode=4096 --fstype="swap" --size=1024
    part /home --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
    %packages
    @gnome-desktop

    DHCP介绍:
    ddns-update-style interim:这个是动态获取IP地址啦。必须放在第一项哇。
    ignore client-updates:服务端与客户端传输相关
    Subnet:获取IP段,要配置正确。
    Routers:是路由地址
    Range:dhcp分配IP段。
    next-server:是tftp地址。
    Allow booting bootp:放行传输和协议。
        希望这些对IDC工作的各位有所帮助,更多内容请关注:陆网科技