cobbler 3.3.3 安装Rockylinux9.2系统

2024-05-22 08:48:00 浏览数 (1)

前言

代码语言:javascript复制
# cobbler 的 github 项目地址
    https://github.com/cobbler/cobbler

# cobbler 官网
    https://cobbler.github.io/

# cobbler 开发任务图
    https://github.com/orgs/cobbler/projects/2/views/3

环境准备

系统环境:Rockylinux 9.2

cobbler版本:3.3.3

pxe安装系统镜像:Rocky-9.2-x86_64-dvd.iso

部署

第一步:cobbler系统配置

第一步:置epel-release源、更新软件、关闭防火墙配、重启系统

代码语言:javascript复制
dnf -y install epel-release
dnf clean packages
dnf -y update
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl disable firewalld
reboot

第二步:确认epel源中 Cobbler 的软件版本是 3.3.3

代码语言:javascript复制
# 为什么Cobbler 3.3.3 我们在 AlmaLinux 9 上部署?
# 官方说要找一个长久的平台进行稳定版的构建,  而centos8stream 只有cobbler 3.2.2
dnf --showduplicates list cobbler

第三步:安装cobbler 及其他相关软件

代码语言:javascript复制
# 安装辅助工具
dnf -y install wget lrzsz tree

# 安装 cobbler 服务及其他相关服务包(注意:cobbler 3.3 已经删除 web,cobbler-web 该包不可用,pykickstart : 基于python的管理kickstart文件的库)
dnf -y install httpd dhcp* tftp tftp-server cobbler pykickstart rsync-daemon

# 若是需要 对 windows 进行自动安装的支持,需要装额外这两个python库
# python-hivex:       # 使用 python-hivex 库 来处理Windows注册表文件(还没研究好怎么安装)
# python-pefile:      # 使用 PEfile 库来解析和分析Windows可执行文件的结构和信息
# dnf install -y python3-pip ; pip3 install pefile
dnf install -y python3-pefile wimlib-utils

# 安装pxe,uefi等引导文件(猜的,不晓得干嘛的)
# /var/lib/poepper/loaders中缺少一些网络引导加载程序。如果您只想处理x86/x86_64网络引导,您可以确保已安装syslinux包的*最新版本
dnf -y install syslinux syslinux-extlinux syslinux-tftpboot

# 额外的附件工具
dnf -y install yum-utils dnf-plugins-core

# 安装bootx64.efi引导文件制作工具,这是为了获得 grub2-mkstandalone 该命令(注意这个包的全名,后续生成uefi 引导程序,就是这个名字)
# 这个程序非常关键,安装完成后,后面用 cobbler mkloader 命令才能生成 uefi的引导文件,才能正常给uefi服务器装机
dnf -y install grub2-efi-modules grub2-efi-x64-modules
# dnf -y install grub2-efi-x64-cdboot

# 安装适用于 debian 系列的(将需要它来管理debian部署和存储库)
dnf -y install debmirror

    # 然后将该文件中如下两行注释掉
    vi /etc/debmirror.conf
    #@dists="sid";
    #@arches="i386";

第四步:生成预设的密码(注意满足密码复杂度要求),并写入 cobbler 配置文件

代码语言:javascript复制
[root@localhost ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$NZtN7V.1$66vFx2Vlf4WVh.woJj/Yt1

[root@localhost ~]# vi /etc/cobbler/settings.yaml
default_password_crypted: "$1$NZtN7V.1$66vFx2Vlf4WVh.woJj/Yt1"

第五步:配置cobbler 主配置文件

代码语言:javascript复制
[root@localhost ~]# vi /etc/cobbler/settings.yaml

# 修改cobbler_server的ip地址为本机ip
server: 10.99.10.122

# 设置tftp的ip地址为本机ip(ipv6 必须设置为非 ::1的情况)
next_server_v4: 10.99.10.122
next_server_v6: "fe80::7a63:968b:e2a:4e5b"

# 打开DHCP功能
manage_dhcp: true
manage_dhcp_v4: true

# collber控制tftp
manage_tftpd: true

# 当bios首选启动项是pxe时,此项设置为true,可避免重启反复安装系统,否则为false
pxe_just_once: true

第六步:配置cobbler 管理的 dhcp服务模板文件

代码语言:javascript复制
# 修改了dhcp模板文件/etc/cobbler/dhcp.template后,需运行cobbler sync命令,将由cobbler自动将模板文件同步到 dhcpd的配置文件 /etc/dhcp/dhcpd.conf
[root@localhost cobbler]# vi /etc/cobbler/dhcp.template

subnet 10.99.10.0 netmask 255.255.255.0 {
    option routers             10.99.10.1;
    option domain-name-servers 114.114.114.114;
    option subnet-mask         255.255.255.0;
    # 注意这个池的范围不能太小了,太小 会报 no free leases 错误,参考链接:https://blog.csdn.net/weixin_34113237/article/details/92938469
    range dynamic-bootp        10.99.10.40 10.99.10.70;
    default-lease-time         21600;
    max-lease-time             43200;
    next-server                $next_server_v4;

第七步:重启服务开机自启动服务

代码语言:javascript复制
# 设置开机自启动
systemctl enable httpd
systemctl enable cobblerd
systemctl enable rsyncd
systemctl enable tftp
systemctl enable dhcpd

systemctl start cobblerd
# 检查相关服务配置项
cobbler check; cobbler sync

# 启动相关软件
systemctl start httpd
systemctl start rsyncd
systemctl start tftp
systemctl start dhcpd

# 检查相关服务是否正常(dhcp 使用udp 67、tftp 使用 udp 69、cobbler 使用 tcp 80)
[root@localhost ~]# ss -tunlp
Netid State  Recv-Q Send-Q Local Address:Port  Peer Address:PortProcess                                                                                                     
udp   UNCONN 0      0            0.0.0.0:67         0.0.0.0:*    users:(("dhcpd",pid=20320,fd=7))                                                                           
udp   UNCONN 0      0          127.0.0.1:323        0.0.0.0:*    users:(("chronyd",pid=674,fd=5))                                                                           
udp   UNCONN 0      0            0.0.0.0:34986      0.0.0.0:*    users:(("dhcpd",pid=20320,fd=20))                                                                          
udp   UNCONN 0      0                  *:69               *:*    users:(("in.tftpd",pid=20201,fd=0),("systemd",pid=1,fd=53))                                                
udp   UNCONN 0      0              [::1]:323           [::]:*    users:(("chronyd",pid=674,fd=6))                                                                           
udp   UNCONN 0      0               [::]:34111         [::]:*    users:(("dhcpd",pid=20320,fd=21))                                                                          
tcp   LISTEN 0      5          127.0.0.1:25151      0.0.0.0:*    users:(("cobblerd",pid=20194,fd=4))                                                                        
tcp   LISTEN 0      128          0.0.0.0:22         0.0.0.0:*    users:(("sshd",pid=686,fd=3))                                                                              
tcp   LISTEN 0      5            0.0.0.0:873        0.0.0.0:*    users:(("rsync",pid=20197,fd=4))                                                                           
tcp   LISTEN 0      128             [::]:22            [::]:*    users:(("sshd",pid=686,fd=4))                                                                              
tcp   LISTEN 0      511                *:80               *:*    users:(("httpd",pid=20062,fd=4),("httpd",pid=20060,fd=4),("httpd",pid=20059,fd=4),("httpd",pid=20057,fd=4))
tcp   LISTEN 0      5               [::]:873           [::]:*    users:(("rsync",pid=20197,fd=5))

第八步:生成pxe、efi生成引导加载程序,并同步到tftp-server的运行目录中

代码语言:javascript复制
# 可以参观下这里 ls /usr/share/syslinux/

# 自 v2.8.5 版本开始 cobbler get-loaders 这个命令就已经不可用了(生成引导加载程序 cobbler mkloaders 此命令适用cobblerV3.3.1及之后的版本)
# 另外:cobbler 3.2.2 可以使用这个脚本生成引导加载程序,/usr/share/cobbler/bin/mkgrub.sh
[root@localhost ~]# cd /var/lib/cobbler/loaders/
[root@localhost loaders]# ls
[root@localhost loaders]# cobbler mkloaders
task started: 2023-11-01_152206_mkloaders
task started (id=Create bootable bootloader images, time=Wed Nov  1 15:22:06 2023)
running python triggers from /var/lib/cobbler/triggers/task/mkloaders/pre/*
running shell triggers from /var/lib/cobbler/triggers/task/mkloaders/pre/*
shell triggers finished successfully
Unable to find "shim.efi" file. Please adjust "bootloaders_shim_file" regex. Bailing out of linking the shim!
ipxe directory did not exist. Please adjust the "bootloaders_ipxe_folder". Bailing out of iPXE setup!
GRUB2 modules directory for arch "aarch64" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "arm" did no exist. Skipping GRUB2 creation
Successfully built bootloader for arch "arm64-efi"!
GRUB2 modules directory for arch "i386-efi" did no exist. Skipping GRUB2 creation
Successfully built bootloader for arch "i386-pc-pxe"!
GRUB2 modules directory for arch "i686" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "IA64" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "powerpc-ieee1275" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "x86_64-efi" did no exist. Skipping GRUB2 creation
*** TASK COMPLETE ***

[root@localhost loaders]# ls
grub  ldlinux.c32  libutil.c32  memdisk  menu.c32  pxelinux.0
[root@localhost loaders]# tree -h
.
├── [  109]  grub
│   ├── [   23]  arm64-efi -> /usr/lib/grub/arm64-efi
│   ├── [ 356K]  grub.0
│   ├── [ 2.1M]  grubaa64.efi   # 这个不晓得,安装了 grub2-efi-modules 之后跑 cobbler mkloaders会生成
│   ├── [ 2.0M]  grubx86.efi    # 注意这个程序是x86 下的uefi引导程序,安装了 grub2-efi-x64-modules 之后跑 cobbler mkloaders会生成
│   ├── [   21]  i386-pc -> /usr/lib/grub/i386-pc
│   └── [   24]  x86_64-efi -> /usr/lib/grub/x86_64-efi
├── [   31]  ldlinux.c32 -> /usr/share/syslinux/ldlinux.c32
├── [   31]  libutil.c32 -> /usr/share/syslinux/libutil.c32
├── [   27]  memdisk -> /usr/share/syslinux/memdisk
├── [   28]  menu.c32 -> /usr/share/syslinux/menu.c32
└── [   30]  pxelinux.0 -> /usr/share/syslinux/pxelinux.0

# 看看tftp-server 的运行目录下,当前的文件
[root@localhost loaders]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
boot  etc  grub  grub.cfg  images  images2  ipxe  ppc  pxelinux.cfg  s390x

# 使用cobbler sync 将 cobbler 生成的 引导程序加载文件 同步到 tftp-server的运行目录 /var/lib/tftpboot/
[root@localhost tftpboot]# cobbler sync

[root@localhost tftpboot]# ls
boot  etc  grub  grub.cfg  images  images2  ipxe  ldlinux.c32  libutil.c32  memdisk  menu.c32  ppc  pxelinux.0  pxelinux.cfg  s390x

第九步:导入CentOS-8-Stream镜像,并生成对应的ks引导文件

代码语言:javascript复制
    # 注意:ISO镜像 必须是完整镜像 ,不能是 "live cd iso" 之类,还有 不能 挂载到 /tmp 及其子目录,因为 cobbler 3有安全机制,使用选项Private Temporary Directory来增强应用程序的安全性
    # 1、挂载iso到 /mnt目录
    [root@localhost ~]# mount CentOS-Stream-8-x86_64-latest-dvd1.iso /mnt/
    [root@localhost ~]# ls /mnt/
    AppStream  BaseOS  EFI  EULA  GPL  LICENSE  extra_files.json  images  isolinux  media.repo

    # 2、导入镜像(他会自动将/mnt 里面的rpm包 同步到/var/www/cobbler/distro_mirror 这个新cobbler版本的镜像存放目录)
    # --name  // 定义安装源名字;
    # --arch  // 指定安装源平台;(这个选项可不写,因为它通常会被自动检测到。我们在本示例中这样做是为了防止发现多个架构)
    # --path  // 镜像路径;
    [root@localhost ~]# cobbler import --name=CentOS-Stream-8 --arch=x86_64 --path=/mnt
    task started: 2023-11-01_164146_import
    task started (id=Media import, time=Wed Nov  1 16:41:46 2023)
    running python triggers from /var/lib/cobbler/triggers/task/import/pre/*
    running shell triggers from /var/lib/cobbler/triggers/task/import/pre/*
    import_tree; ['/mnt', 'CentOS-Stream-8', None, None, None]
    importing from a network location, running rsync to fetch the files first
    running: rsync -a  '/mnt/' /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64 --progress
    Found a candidate signature: breed=redhat, version=rhel8
    Found a matching signature: breed=redhat, version=rhel8
    Adding distros from path /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64:
    creating new distro: CentOS-Stream-8-x86_64
    trying symlink: /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64 -> /var/www/cobbler/links/CentOS-Stream-8-x86_64
    trying hardlink /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-Stream-8-x86_64/vmlinuz
    trying hardlink /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-Stream-8-x86_64/initrd.img
    trying hardlink /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-Stream-8-x86_64/vmlinuz
    trying hardlink /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-Stream-8-x86_64/initrd.img
    processing boot_files for distro: CentOS-Stream-8-x86_64
    skipping symlink, destination (/var/www/cobbler/links/CentOS-Stream-8-x86_64) exists
    Writing template files for CentOS-Stream-8-x86_64
    running python triggers from /var/lib/cobbler/triggers/change/*
    running python trigger cobbler.modules.scm_track
    running python trigger cobbler.modules.managers.genders
    running python triggers from /var/lib/cobbler/triggers/add/distro/post/*
    running shell triggers from /var/lib/cobbler/triggers/add/distro/post/*
    creating new profile: CentOS-Stream-8-x86_64
    running python triggers from /var/lib/cobbler/triggers/change/*
    running python trigger cobbler.modules.scm_track
    running python trigger cobbler.modules.managers.genders
    running shell triggers from /var/lib/cobbler/triggers/change/*
    grab_tree found 2 children (including settings) of this object
    processing boot_files for distro: CentOS-Stream-8-x86_64
    skipping symlink, destination (/var/www/cobbler/links/CentOS-Stream-8-x86_64) exists
    starting descent into /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64 for CentOS-Stream-8-x86_64
    processing repo at : /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/AppStream
    need to process repo/comps: /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/AppStream
    looking for /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/AppStream/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/AppStream/repodata
    processing repo at : /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/BaseOS
    need to process repo/comps: /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/BaseOS
    looking for /var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/BaseOS/repodata/*comps*.xml
    Keeping repodata as-is :/var/www/cobbler/distro_mirror/CentOS-Stream-8-x86_64/BaseOS/repodata
    grab_tree found 2 children (including settings) of this object
    processing boot_files for distro: CentOS-Stream-8-x86_64
    skipping symlink, destination (/var/www/cobbler/links/CentOS-Stream-8-x86_64) exists
    Writing template files for CentOS-Stream-8-x86_64
    *** TASK COMPLETE ***

    # 3、使用cobbler 自动生成ks文件(注意这个名字,是上面import的名字 拼接的)
    root@localhost ~]# cobbler profile get-autoinstall --name CentOS-Stream-8-x86_64

    # 4、将上面生成的ks文件,写入到cobbler的ks配置文件目录中(要自行新创建的文件)
    # 注意:cobbler 3.3.3 有个bug,生成的ks中 $tree 是个变量,不能直接用,要手动改成 真实值
    [root@localhost ~]# cd /var/lib/cobbler/templates/
    [root@localhost templates]# vi CentOS-Stream-8.ks
# Sample kickstart file for current EL, Fedora based distributions.

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
# BUG 就在这里
# url --url=$tree
url --url=http://10.99.10.122/cblr/links/CentOS-Stream-8-x86_64
#url --url=http://10.99.10.122/cobbler/links/CentOS-Stream-8-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://10.99.10.122/cobbler/distro_mirror/CentOS-Stream-8-x86_64/AppStream
repo --name=source-2 --baseurl=http://10.99.10.122/cobbler/distro_mirror/CentOS-Stream-8-x86_64/BaseOS

# Network information
network --bootproto=dhcp --device=eth0 --onboot=on  

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$NZtN7V.1$66vFx2Vlf4WVh.woJj/Yt1
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &

curl "http://10.99.10.122/cblr/svc/op/trig/mode/pre/profile/CentOS-Stream-8-x86_64" -o /dev/null

# Enable installation monitoring

%end

%packages
%end

%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1

%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
curl "http://10.99.10.122/cblr/svc/op/yum/profile/CentOS-Stream-8-x86_64" --output /etc/yum.repos.d/cobbler-config.repo

# End yum configuration

# Start post_install_network_config generated code
# End post_install_network_config generated code

# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)

# Start koan environment setup
echo "export COBBLER_SERVER=10.99.10.122" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 10.99.10.122" > /etc/profile.d/cobbler.csh
# End koan environment setup

# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration

# Begin cobbler registration
# cobbler registration is disabled in /etc/cobbler/settings.yaml
# End cobbler registration

# Enable post-install boot notification

# Start final steps

curl "http://10.99.10.122/cblr/svc/op/autoinstall/profile/CentOS-Stream-8-x86_64" -o /root/cobbler.ks
curl "http://10.99.10.122/cblr/svc/op/trig/mode/post/profile/CentOS-Stream-8-x86_64" -o /dev/null
# End final steps
%end

第十步:将刚才导入的镜像 和创建的 ks进行关联,然后修改安装时调用的内核参数

代码语言:javascript复制
# 修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@localhost ~]# cobbler profile edit --name CentOS-Stream-8-x86_64 --autoinstall CentOS-Stream-8.ks

# 配置网卡名称为传统网卡名称eth0(修改安装时调用的内核参数)
[root@localhost ~]# cobbler profile edit --name CentOS-Stream-8-x86_64 --kernel-options 'net.ifnames=0 biosdevname=0'

# 再次查看
[root@localhost ~]# cobbler profile report --name CentOS-Stream-8-x86_64

# 同步
[root@localhost ~]# cobbler sync

# 去查看tftp去引导文件
[root@localhost templates]# cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler | https://cobbler.github.io
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT local

LABEL local
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

LABEL CentOS-Stream-8-x86_64
    MENU LABEL CentOS-Stream-8-x86_64
    kernel /images/CentOS-Stream-8-x86_64/vmlinuz
    append initrd=/images/CentOS-Stream-8-x86_64/initrd.img net.ifnames=0 biosdevname=0  kssendmac inst.ks=http://10.99.10.122/cblr/svc/op/autoinstall/profile/CentOS-Stream-8-x86_64
    ipappend 2
MENU end 

第十一步:需要修改dhcp的模版,并再次执行 cobbler sync 后就可以进行系统安装测试了

代码语言:javascript复制
# cobbler 管理dhcp的模版文件       /etc/cobbler/dhcp.template
# tftp-server 的 uefi引导文件路径  /var/lib/tftpboot/grub/grubx86.efi

# 1、由于服务器采用uefi方式引导,需要修改dhcp的模版,让tftp找到正确的uefi引导文件
    [root@localhost ~]# vi /etc/cobbler/dhcp.template
        # UEFI-64-1
        else if option system-arch = 00:07 {
            #filename "grub/grubx64.efi";     # 注释这行,添加下一行
            filename "grub/grubx86.efi";
        }
        # UEFI-64-2
        else if option system-arch = 00:08 {
            filename "grub/grubx64.efi";
        }
        # UEFI-64-3
        else if option system-arch = 00:09 {
            filename "grub/grubx64.efi";
        }

# 2、再次同步,然后执行装机(cobbler sync 会先根据模版文件 生成服务需要的配置文件,然后同步到服务的目录,然后重启服务)
    [root@localhost ~]# cobbler sync

附一、自动化配置

Cobbler 自动化装机相关服务配置文件

代码语言:javascript复制
# 1、dhcp与tftp相关
    /etc/cobbler/dhcp.template  # cobbler 的 dhcp 模版文件
    /etc/dhcp/dhcpd.conf        # dhcpd 服务的配置文件

# 2、bootloaders 网络引导程序相关
    /usr/share/syslinux/                # 原始syslinux软件带的

    cobbler mkloaders           # cobbler 3 生成 bootloader的命令
    /var/lib/cobbler/loaders/   # 上面生成的文件,存放与这里
    [root@localhost loaders]# tree /var/lib/cobbler/loaders/
    ├── grub
    │   ├── arm64-efi -> /usr/lib/grub/arm64-efi
    │   ├── grub.0              # 普通 bios pxe的引导加载程序
    │   ├── grubaa64.efi        # 不清楚是什么价格
    │   ├── grubx86.efi         # x86架构下 uefi的网络引导加载程序
    │   ├── i386-pc -> /usr/lib/grub/i386-pc
    │   └── x86_64-efi -> /usr/lib/grub/x86_64-efi
    ├── ldlinux.c32 -> /usr/share/syslinux/ldlinux.c32
    ├── libutil.c32 -> /usr/share/syslinux/libutil.c32
    ├── memdisk -> /usr/share/syslinux/memdisk
    ├── menu.c32 -> /usr/share/syslinux/menu.c32
    └── pxelinux.0 -> /usr/share/syslinux/pxelinux.0    # 普通 bios pxe的引导加载程序

    /var/lib/tftpboot/                  # tftpd软件的工作目录
    /var/lib/tftpboot/pxelinux.0        # bios pxe
    /var/lib/tftpboot/grub/grub.0       # bios pxe
    /var/lib/tftpboot/grub/grubx86.efi  # uefi pxe

# 3、引导后加载的目录MENU菜单
    [root@localhost ~]# cd /etc/cobbler/boot_loader_conf/    # 这是 cobbler 控制的各个模版
    [root@localhost boot_loader_conf]# tree
    ├── bootcfg.template
    ├── grub.template
    ├── grub_menu.template
    ├── grub_submenu.template
    ├── ipxe.template
    ├── ipxe_menu.template
    ├── ipxe_submenu.template
    ├── pxe.template
    ├── pxe_menu.template       # bios pxe 的 menu 模版(实测修改后,cobbler sync 后,tftp文件是生效的,但实际却看不到效果)
    └── pxe_submenu.template

    /var/lib/tftpboot/pxelinux.cfg/default      # 从 bios 的 pxe 引导后的菜单
    /var/lib/tftpboot/ipxe/default.ipxe         # 从 uefi 的 ipxe 引导后的菜单

# 4、ks模版文件目录
    /var/lib/cobbler/templates/

# 5、镜像软件包存放目录(如rpm等)
    /var/www/cobbler/distro_mirror

附二、cobbler的BUG

Cobbler 3.3.3 和 3.3.4 的已知BUG(ks 中 $tree 变量有问题)

该问题请参考:github上的开发规划 解决办法:可以另外装一个 基于CentOS-Stream-8的 Cobbler 3.2.2 来生成ks

附三、注意事项

附三、CentOS-Stream-8 部署 cobbler 3.2.2的注意事项(只说特殊点)

代码语言:javascript复制
# 1、最开始步骤,C8S 安装cobbler(安装epel源,cobbler,使用官方源)rocky9上不用执行此三行
    [root@localhost ~]# dnf install epel-release -y
    [root@localhost ~]# dnf module list|grep cobbler
    cobbler              3               default [d]                              Versatile Linux deployment server                                                                                                                                                                                                         
    cobbler              3.3             default [d]                              Versatile Linux deployment server
    [root@localhost ~]# dnf module enable cobbler:3 -y

# 2、cobbler 3.2.2 还有web管理包,可以装上 cobbler-web(python3-gunicorn  这包顺手装的)
    dnf -y cobbler-web python3-gunicorn

# 3、若是需要 对 windows 进行自动安装的支持,需要装额外这两个包
    # python-hivex:       # 使用 python-hivex 库 来处理Windows注册表文件
    # python-pefile:      # 使用 PEfile 库来解析和分析Windows可执行文件的结构和信息
    dnf install python3-hivex python3-pefile wimlib-utils

# 4、配置cobbler 主配置文件
    [root@localhost ~]# vi /etc/cobbler/settings.yaml
    #修改cobbler_server的ip地址为本机ip
    server: 10.99.10.122
    #设置tftp的ip地址为本机ip
    next_server: 10.99.10.122
    #打开DHCP功能
    manage_dhcp: true

# 5、在生成pxe、efi生成引导加载程序,并同步到tftp-server的运行目录中(方式不一样)
    [root@localhost cobbler]# ls /usr/share/syslinux/
    altmbr.bin    cptime.c32     disk.c32      gptmbr_c.bin  ifmemdsk.c32    isolinux.bin        liblua.c32   mbr.bin      pmload.c32    sanboot.c32     vesainfo.c32
    altmbr_c.bin  cpu.c32        dmi.c32       gptmbr_f.bin  ifplop.c32      isolinux-debug.bin  libmenu.c32  mbr_c.bin    poweroff.c32  sdi.c32         vesamenu.c32
    altmbr_f.bin  cpuid.c32      dmitest.c32   gpxecmd.c32   isohdpfx.bin    kbdmap.c32          libutil.c32  mbr_f.bin    prdhcp.c32    sysdump.c32     vpdtest.c32
    cat.c32       cpuidtest.c32  dosutil       hdt.c32       isohdpfx_c.bin  kontron_wdt.c32     linux.c32    memdisk      pwd.c32       syslinux64.exe  whichsys.c32
    chain.c32     debug.c32      elf.c32       hexdump.c32   isohdpfx_f.bin  ldlinux.c32         lpxelinux.0  meminfo.c32  pxechn.c32    syslinux.c32    zzjson.c32
    cmd.c32       dhcp.c32       ethersel.c32  host.c32      isohdppx.bin    lfs.c32             ls.c32       menu.c32     pxelinux.0    syslinux.com
    cmenu.c32     diag           gfxboot.c32   ifcpu64.c32   isohdppx_c.bin  libcom32.c32        lua.c32      pci.c32      reboot.c32    syslinux.exe
    config.c32    dir.c32        gptmbr.bin    ifcpu.c32     isohdppx_f.bin  libgpl.c32          mboot.c32    pcitest.c32  rosh.c32      vesa.c32
    [root@localhost cobbler]# cd /var/lib/cobbler/loaders/
    [root@localhost loaders]# ls
    [root@localhost loaders]# /usr/share/cobbler/bin/mkgrub.sh      # 使用该命令生成 bootloaders
    [root@localhost loaders]# ls
    grub  ldlinux.c32  menu.c32  pxelinux.0
    [root@localhost loaders]# tree
    ├── grub
    │   ├── grub.0
    │   ├── grubaa64.efi
    │   ├── grub.ppc64le
    │   └── grubx64.efi
    ├── ldlinux.c32 -> /usr/share/syslinux/ldlinux.c32
    ├── menu.c32 -> /usr/share/syslinux/menu.c32
    └── pxelinux.0 -> /usr/share/syslinux/pxelinux.0

# 5、上一步生成的 uefi 网络引导程序,在使用cobbler sync 后,同步到 下面路径
    #(注意这里是 grubx64.efi 不是 cobbler 3.3.3 版本中的 grubx84.efi,所以连dhcp模版都不要改)
    /var/lib/tftpboot/grub/grubx64.efi

0 人点赞