• PXE装机服务搭建(安装ubuntu18及以下版本)


    这里是工作中对一个pxe装机需求测试记录,所有操作都是在笔记本电脑上VMware虚拟机中实现,内容仅供参考。

    环境介绍:

    1、PXE测试服务器为一台1c2g的VMware虚拟机,网络模式为NAT模式,操作系统为CentOS7.9,IP地址为192.168.1.11。

    2、需要准备一个ubuntu-14.04.6-server-amd64.iso的ISO镜像包。

    3、PXE服务其实是通过http/ftp、TFTP、DHCP服务来实现,这里安装在一台服务器上,可以分开部署。

    4、准备一个ubuntu的网络引导器netboot.tar.gz,注意版本问题。

            网络安装器下载地址:http://cdimage.ubuntu.com/netboot/

    PXE安装ubuntu填坑:

            1、 ubuntu的PXE安装它会要求ubuntu镜像的版本、网络引导器版本和生成ks文件的系统版本必须一致,不然就是各种问题。所以上面介绍环境,我写清楚了镜像文件的全名。

            2、ubuntu版本过高,安装kickstart可能会出现依赖问题,所以这里选择14版本进行安装(18版本测试了也没问题)。

            3、如果需要无人值守安装系统,必须要划分swap分区。

    搭建PXE服务器

    1、安装httpd,pxe装机需要用到httpd服务的功能。这里使用httpd,ftp跟httpd几乎一样。

    yum -y install httpd

    3、创建一个存放系统镜像文件目录,然后把镜像文件cp到该目录中。

    mkdir /var/www/html/ubuntu
    cp -a /mnt/cdrom/* /var/www/html/ubuntu

    4、启动httpd,设置开机启动。

    systemctl start httpd
    systemctl enable httpd

    5、安装TFTP服务,修改配置文件并启动。这里修改一下tftp的根目录,因为还需要测试centos系统,这里做一个区分,如果只安装一个系统,可以不用修改。

    yum -y install tftp-server
    vim /etc/xinetd.d/tftp
          #将disable=yes 修改为 
           disable=no
          #将 server_args = -s /var/lib/tftpboot 修改为
           server_args = -s /var/lib/tftpboot/ubuntu -c
    
    vim /usr/lib/systemd/system/tftpd.service
          #将 ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot  修改为
           ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot/ubuntu
    
    systemctl daemon-reload
    systemctl restart tftp
    systemctl enable tftp

    6、把准备好的ubuntu网络引导器解压到tftp根目录下

    tar zxf netboot.tar.gz -C /var/lib/tftpboot/ubuntu

    7、修改启动菜单文件,将timeout的值从0改为1,是为了让ubuntu安装界面出现会超时,自动选择安装。

    vim /var/lib/tftpboot/ubuntu/pxelinux.cfg/default
        #将  timeout 0 修改为
        timeout 1

    8、修改网络引导器中的txt.cfg文件

    vim /var/lib/tftpboot/ubuntu/ubuntu-installer/amd64/boot-screens/txt.cfg
          #在append后添加以下内容
            ks=http://192.168.1.11/ubuntu/ks.cfg preseed/url=http://192.168.1.11/ubuntu/ubuntu-server.seed netcfg/get_nameservers=192.168.1.11

    修改后文件内容如下:

    9、挂载ISO镜像,把镜像文件cp到/var/www/html/ubuntu目录下。

    mount /dev/cdrom /mnt/cdrom
    cp -a /mnt/cdrom/* /var/www/html/ubuntu/

    10、复制镜像文件中的ubuntu-server.seed文件到/var/www/html/ubuntu目录下并添加配置。

    cp /var/www/html/ubuntu/preseed/ubuntu-server.seed /var/www/html/ubuntu/
    vim /var/www/html/ubuntu/ubuntu-server.seed 
          #在文件最后加入以下配置
          d-i live-installer/net-image string http://192.168.1.11/ubuntu/install/filesystem.squashfs
          d-i pkgsel/include string openssh-server

    11、安装DHCP服务器,并且添加配置,启动。客户端会请求到dhcp服务器,dhcp服务器会提供给客户端IP信息、tftp信息、pxe引导文件信息等。所以,在客户端网络环境中,不要配置其他的dhcp服务器了。

    yum -y install dhcp
    cat <<EOF >> /etc/dhcp/dhcpd.conf
    subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.100 192.168.1.200;         #dhcp服务为客户端分配的ip范围 
        option domain-name-servers 8.8.8.8;        #dns
        option domain-name "internal.example.org"; 
        option routers 192.168.1.1;                #网关
        option broadcast-address 192.168.1.255;    #广播
        default-lease-time 21600;                  #租约时间,默认值是600,单位是秒
        max-lease-time 43200;                      #最大租约时间
        next-server 192.168.1.11;                  #指定TFTP服务器的地址
        filename "pxelinux.0";                     #指定PXE引导程序的文件名
    }
    EOF
    systemctl start dhcpd
    systemctl enable dhcpd

    12、准备ks.cfg文件(test用户密码是1q2w3e4r)。

    cat <<EOF > /var/www/html/ubuntu/ks.cfg
    #Generated by Kickstart Configurator
    #platform=x86
    
    #System language
    lang en_US
    #Language modules to install
    langsupport en_US
    #System keyboard
    keyboard us
    #System mouse
    mouse
    #System timezone
    timezone America/New_York
    #Root password
    rootpw --disabled
    #Initial user
    user test --fullname "test" --iscrypted --password $1$923Ky0S9$dRr5NVm9eitEibM3EE1a/.
    #Reboot after installation
    reboot
    #Use text mode install
    text
    #Install OS instead of upgrade
    install
    #Use Web installation
    url --url http://192.168.1.11/ubuntu/
    #System bootloader configuration
    bootloader --location=mbr 
    #Clear the Master Boot Record
    zerombr yes
    #Partition clearing information
    clearpart --all --initlabel 
    #Disk partitioning information
    part /boot --fstype ext4 --size 200 
    part swap --size 2048 
    part / --fstype ext4 --size 15800 
    #System authorization infomation
    auth --useshadow --enablemd5 
    #Network information
    network --bootproto=dhcp --device=eth0
    #Firewall configuration
    firewall --disabled 
    #Do not configure the X Window System
    skipx
    
    EOF

    图形界面配置ks文件这里就不做介绍了,跟centos的一样,先安装kickstart,然后用软件做配置后保存即可。可以参考:PXE装机服务搭建(安装CentOS7)

  • 相关阅读:
    这可能是全网最全的流媒体知识科普文章
    JavaCV实战专栏文章目录(JavaCV速查手册)
    JavaCV复杂滤镜filter特效处理入门教程和常用案例汇总
    【PC桌面软件的末日,手机移动端App称王】写在windows11支持安卓,macOS支持ios,龙芯支持x86和arm指令翻译
    如何在龙芯架构和国产化操作系统平台上运行javacv
    如何在国产龙芯架构平台上运行c/c++、java、nodejs等编程语言
    JavaCV开发详解之35:使用filter滤镜实现画中画,以屏幕画面叠加摄像头画面为例
    JavaCV开发详解之34:使用filter滤镜实现字符滚动和无限循环滚动字符叠加,跑马灯特效制作
    JavaCV开发详解之33:使用filter滤镜实现动态日期时间叠加
    JavaCV开发详解之32:使用filter滤镜实现中文字符叠加
  • 原文地址:https://www.cnblogs.com/NanZhiHan/p/15002414.html
Copyright © 2020-2023  润新知