此时实验室在centos7上配置centos8并装机
导入镜像
//挂载镜像 红帽8
[root@centos-7 ks_mirror]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@centos-7 ks_mirror]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 26G 15G 12G 57% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 12M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 142M 873M 14% /boot
tmpfs 378M 0 378M 0% /run/user/0
/dev/sr0 7.9G 7.9G 0 100% /mnt
[root@centos-7 ks_mirror]# cd
[root@centos-7 ~]# cobbler import --path=/mnt --name=rhel-8 --arch=x86_64
task started: 2021-10-14_115903_import
task started (id=Media import, time=Thu Oct 14 11:59:03 2021)
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/ks_mirror/rhel-8-x86_64:
creating new distro: rhel-8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/rhel-8-x86_64 -> /var/www/cobbler/links/rhel-8-x86_64
creating new profile: rhel-8-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/rhel-8-x86_64 for rhel-8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
[root@centos-7 ~]#
查看cobbler列表镜像
[root@centos-7 ~]# cobbler list
distros:
centos-7-x86_64
rhel-8-x86_64
profiles:
centos-7-x86_64
rhel-8-x86_64
systems:
test01
repos:
images:
mgmtclasses:
packages:
创建创建kickstarts自动安装脚本
[root@centos-7 kickstarts]# pwd
/var/lib/cobbler/kickstarts
[root@centos-7 kickstarts]# ls
anaconda-ks.cfg pxerescue.ks sample_esxi6.ks
centos-7-x86_64.ks redhat-8-x86_64.ks sample.ks
default.ks sample_autoyast.xml sample_old.seed
esxi4-ks.cfg sample_end.ks sample.seed
esxi5-ks.cfg sample_esx4.ks sample.seed.28
install_profiles sample_esxi4.ks
legacy.ks sample_esxi5.ks
[root@centos-7 kickstarts]# vim redhat-8-x86_64.ks
auth --enableshadow --passalgo=sha512
bootloader --location=mbr
clearpart --all --initlabel
part /boot --asprimary --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
text
firewall --disabled
firstboot --disable
keyboard us
lang en_US
url --url=http://192.168.164.128/cobbler/ks_mirror/rhel-8-x86_64
$yum_repo_stanza
reboot
//密码,这要把本机/root/anaconda-ks.cfg中的密码复制过来,这样新的虚拟机就和本机密码一样了
rootpw --iscrypted $6$Un13XuOBCDh/mnz7$lrfN.Hr7JGArrINczu4qewo9d3dHTg2B7FwAny712mq72XohNVXtlve4CLU/UKIjX8uXWS2zQs1J4wHSNZK7L1
selinux --disabled
skipx
timezone Asia/Shanghai --isUtc --nontp
install
zerombr
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
检查ks文件语法是否有误
[root@centos-7 kickstarts]# cobbler profile edit --name rhel-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/redhat-8-x86_64.ks
修改传统网卡
[root@centos-7 kickstarts]# pwd
/var/lib/cobbler/kickstarts
[root@centos-7 kickstarts]# cobbler profile edit --name rhel-8-x86_64 --kopts='net.ifnames=0 biosdevname=0'
查看当前系统cobbler配置文件信息
[root@centos-7 kickstarts]# cobbler profile report
Name : rhel-8-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : rhel-8-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/redhat-8-x86_64.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
Name : centos-7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : centos-7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos-7-x86_64.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
同步
[root@centos-7 kickstarts]# cobbler sync
task started: 2021-10-14_134409_sync
task started (id=Sync, time=Thu Oct 14 13:44:09 2021)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/rhel-8-x86_64
removing: /var/www/cobbler/images/centos-7-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-28-be-2a
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/01-00-50-56-28-BE-2A
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/rhel-8-x86_64
removing: /var/lib/tftpboot/images/centos-7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-8-x86_64/initrd.img
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos-7-x86_64/initrd.img
copying images
generating PXE configuration files
generating: /var/lib/tftpboot/pxelinux.cfg/01-00-50-56-28-be-2a
generating: /var/lib/tftpboot/grub/01-00-50-56-28-BE-2A
generating PXE menu structure
copying files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-8-x86_64/initrd.img
Writing template files for rhel-8-x86_64
copying files for distro: centos-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos-7-x86_64/initrd.img
Writing template files for centos-7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: rhel-8-x86_64
processing boot_files for distro: centos-7-x86_64
cleaning link caches
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
running shell triggers from /var/lib/cobbler/triggers/sync/post/*
running python triggers from /var/lib/cobbler/triggers/change/*
running python trigger cobbler.modules.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
重启所有服务
[root@centos-7 kickstarts]# systemctl restart xinetd
[root@centos-7 kickstarts]# systemctl restart cobblerd
[root@centos-7 kickstarts]# systemctl restart httpd
[root@centos-7 kickstarts]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 127.0.0.1:25151 *:*
LISTEN 0 5 *:873 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 5 :::873 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::443 :::*
红帽8
选择第三个红帽8即可
随后会弹出两个选项
第一个选择yes
第二个选择4即可