cobbler最小化安装centos8
阅读原文时间:2023年07月08日阅读:3

centos8 已经发布了GA版本,迫不及待的想尝鲜了,然后现实总是那么残酷,一直安装失败,具体安装步骤如下:

假设cobbler已配置完成。

1、下载centos8 iso镜像

wget http://mirrors.aliyun.com/centos/8.0.1905/isos/x86_64/CentOS-8-x86_64-1905-dvd1.iso

2、挂载

$ mount -o loop CentOS-8-x86_64-1905-dvd1.iso /mnt/
$ cd /mnt/
$ cp -r * /iso/centos8.0/
$ cd /iso/centos8.0/
AppStream BaseOS EFI images isolinux media.repo TRANS.TBL

3、配置kickstart文件

$ cat /var/lib/cobbler/kickstarts/centos8.0.ks

#version=RHEL8

System authorization information

auth --enableshadow --passalgo=sha512

System bootloader configuration

bootloader --location=mbr --boot-drive=sda

Partition clearing information

clearpart --all --initlabel

Use text mode install

#text
graphical

Firewall configuration

firewall --disabled

Run the Setup Agent on first boot

firstboot --disable

ignoredisk --only-use=sda

System keyboard

keyboard --vckeymap=us --xlayouts='us'

System language

lang en_US.UTF-8

Use network installation

url --url=$tree

If any cobbler repo definitions were referenced in the kickstart profile, include them here.

$yum_repo_stanza

Network information

$SNIPPET('network_config')

Reboot after installation

reboot

#Root password

rootpw --iscrypted $default_password_crypted

SELinux configuration

selinux --disabled

Do not configure the X Window System

skipx

System timezone

timezone --utc Asia/Shanghai

Install OS instead of upgrade

install

Clear the Master Boot Record

zerombr

Allow anaconda to partition the system as needed

#autopart

part /boot --fstype="xfs" --ondisk=sda --size=500
part swap --fstype="swap" --ondisk=sda --size=2048
part / --fstype="xfs" --ondisk=sda --size=1 --grow
part biosboot --fstype="BIOS Boot" --ondisk=sda --size=2

%pre

$SNIPPET('log_ks_pre')

$SNIPPET('kickstart_start')

$SNIPPET('pre_install_network_config')

Enable installation monitoring

$SNIPPET('pre_anamon')

%end

%packages

@^minimal-environment
@standard

%end

4、cobbler 导入

$ cobbler import --name=centos8.0 --path=/iso/centos8.0 --kickstart=/var/lib/cobbler/kickstarts/centos8.0.ks --arch=x86_64

发现报错,报错如下:

No signature matched

$ cobbler import --name=centos8.0 --path=/iso/centos8.0 --kickstart=/var/lib/cobbler/kickstarts/centos8.0.ks
task started: 2019-10-16_074659_import
task started (id=Media import, time=Wed Oct 16 07:46:59 2019)
No signature matched in /var/www/cobbler/ks_mirror/centos8.0
!!! TASK FAILED !!!

解决:

$ cobbler signature update
task started: 2019-10-16_074829_sigupdate
task started (id=Updating Signatures, time=Wed Oct 16 07:48:29 2019)
Successfully got file from https://cobbler.github.io/signatures/2.8.x/latest.json
*** TASK COMPLETE ***

5、装机

然后装机过程中报错了,截图未报错,报错信息是:报错的界面是配置"Installation Source",报错为:"Error setting up base repository",反复测试依然有问题,不知道怎么设置,没办法,只能从iso那块下手了,检查iso文件内容。

6、iso配置

iso中有AppStream和BaseOS两个目录,目录中都有Packages目录和repodata目录,将BaseOS中的 BaseOS/repodata/586a8e96ad3b73414e5c6ae94a5e4f128a087fcb0ca9837674573a8d6cac4a9c-comps-BaseOS.x86_64.xml 拷贝到 BaseOS 同级目录下,并将 AppStream/Packages 下的auth*包文件全部拷贝到BaseOS/Packages 下,然后使用 createrepo -g 586a8e96ad3b73414e5c6ae94a5e4f128a087fcb0ca9837674573a8d6cac4a9c-comps-BaseOS.x86_64.xml . 创建repodata目录。

$ cd /iso/centos8.0/
$ ls
AppStream BaseOS EFI images isolinux media.repo TRANS.TBL
$ cp AppStream/Packages/auth* BaseOS/Packages/
$ cp BaseOS/repodata/586a8e96ad3b73414e5c6ae94a5e4f128a087fcb0ca9837674573a8d6cac4a9c-comps-BaseOS.x86_64.xml ./

$ ls
586a8e96ad3b73414e5c6ae94a5e4f128a087fcb0ca9837674573a8d6cac4a9c-comps-BaseOS.x86_64.xml AppStream BaseOS EFI images isolinux media.repo TRANS.TBL

$ createrepo -g 586a8e96ad3b73414e5c6ae94a5e4f128a087fcb0ca9837674573a8d6cac4a9c-comps-BaseOS.x86_64.xml .
Spawning worker 0 with 167 pkgs
Spawning worker 39 with 166 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

$ rm -rf AppStream/repodata BaseOS/repodata

重新使用cobbler import,再使用最小化安装。

当然我配置的可能哪里出了问题,导致出现了"Error setting up base repository"报错,如果哪位大神解决了这个问题,欢迎评论区告知一声。