暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

关于银河麒麟的批量安装

DevOps踩坑与实践 2021-10-25
3191

  近遇到了一个不算大的问题,就是信创的国产化操作系统安装,机器可能会有个几十台,没台去装肯定累个够呛……

   开始正题吧,完成任务需要几个工具nginx、tftp-hpa、isc-dhcp-server、系统镜像。

首先安装一个nginx作为http下载文件的用途(这个最简单基本不用配置啥)

    apt install nginx

    还需要一个镜像,当然是麒麟镜像。去官网瞅了下,就这还得注册才给测试链接……忍着恶心注册了一把,拿到链接一看版本还挺丰富。于是下载了一个x86_64版本的镜像。

    因为要用pxe安装所以需要引导文件,于是抽取文件到tftp文件下默认路径是srv/tftp,新建目录grub/下需要两个文件grubx64.efi和grub.cfg,grub.cfg如下内容

      set default="0"


      function load_video {
      insmod efi_gop
      insmod efi_uga
      insmod video_bochs
      insmod video_cirrus
      insmod all_video
      }


      load_video
      set gfxpayload=keep
      insmod gzio
      insmod part_gpt
      insmod ext2


      set timeout=3




      search --no-floppy --set=root -l 'Kylin-Server-10'


      menuentry '1)Install Kylin Desktop V10.1 1106 X86' --class red --class gnu-linux --class gnu --class os {


      linux install/vmlinuz inst.stage2=http://192.168.1.14 quit inst.ks=http://192.168.1.14/ks.cfg
      initrd install/initrd.img


      }

      对应kickstart文件如下:

        # Install OS instead of upgrade
        install
        # Keyboard layouts
        # old format: keyboard us
        # new format:
        keyboard --vckeymap=cn --xlayouts='cn'
        # Root password
        rootpw --iscrypted $1$p9c/UtoB$F/NKPL3Rc92T/MIFuuwXP1
        # Use network installation
        url --url="http://192.168.1.14"
        # System language
        lang zh_CN
        user --name=app --password=$6$HYxUdlffGmKv.D3V$fwl9CSR30j8qN4GURB3CJl7h1OTpwGtKP3LHadU0U4MUDGFCwFBCcef.UqxXWqSKx7adk2nDHZbQIX6lvMOFf0 --iscrypted --gecos="app"
        # System authorization information
        auth --useshadow --passalgo=sha512
        # Use graphical install
        text
        # Run the Setup Agent on first boot
        firstboot --enable
        # SELinux configuration
        selinux --disabled


        # System services
        services --enabled="chronyd"
        ignoredisk --only-use=sda
        # Firewall configuration
        firewall --disabled
        # Network information
        network --bootproto=dhcp --device=enp11s0f1 --onboot=on


        reboot
        eula --agreed
        # System timezone
        timezone Asia/Shanghai
        #network --bootproto=dhcp --device=enp11s0f0 --onboot=on
        # System bootloader configuration
        bootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda
        # Clear the Master Boot Record
        zerombr
        # Partition clearing information
        clearpart --all --initlabel --drives=sda
        # Disk partitioning information
        part boot --fstype="xfs" --size=1024
        part boot/efi --fstype="vfat" --size=512
        part swap --fstype="swap" --size=4096
        part --fstype="xfs" --grow --size=1


        %packages
        chrony
        kexec-tools


        %end


        还需要在/srv/tftp下创建install目录,里面存放initrd.img和vmlinuz两个文件

        下面就是使用mount 挂在镜像光盘mount -o loop Kylin-Server-10-SP2-X86-Release-Build09-20210524.iso /mnt 

        cp -ar * /var/www/html目录下,最后一步就是配置dhcp了

          subnet 192.168.1.0 netmask 255.255.255.0 { 
              range 192.168.1.100 192.168.1.200;
              option broadcast-address 192.168.1.255;
              option routers 192.168.1.14;
              next-server 192.168.1.14;
              filename "grup/grubx64.efi";#uefi引导使用这个文件,legacy引导使用pxelinux.0
              option subnet-mask 255.255.255.0;
              }

              配置完成后就可以顺利的进行网络安装了。


          文章转载自DevOps踩坑与实践,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

          评论