首页 > 其他分享 >cnetos7 ISO 镜像自定义制作

cnetos7 ISO 镜像自定义制作

时间:2024-03-12 11:33:36浏览次数:23  
标签:CentOS7 自定义 isolinux -- cfg ks ISO cnetos7

  简介:

     此自定义镜像针对centos7 系统版本,通过tar 打包原系统服务将其放入ISO镜像中在安装时执行解压导入新安装系统中实现系统服务的自定义安装。针对cnetos7 目前只测试出这一种方案,暂时没找到其他好的方案实现系统的模板ISO制作,目前版本存在缺陷镜像中的tar包非加密存在安全问题。如果有更好的方案还请大佬指导。

   制作系统tar包

      原系统将服务进行删减,删除没用的日志和缓存数据保证系统的最小可用。删减完成后运行以下命令将系统打包:

tar cvpzf backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/dev --exclude=/etc/fstab --exclude=/boot  --exclude=/backup.tar.gz --exclude=/mnt --exclude=/sys --exclude=/media  --exclude=/etc/sysconfig/network-scripts/ / 

   使用原centos7 mini镜像进行挂载修改

  

#镜像名称:CentOS-7-x86_64-Minimal-2009.iso
#将其挂载到系统中(随便一个操作系统用来制作系统镜像)
#安装必要依赖
yum install -y  genisoimage

#挂载镜像
mount -o loop  ./CentOS-7-x86_64-Minimal-2009.iso  /mnt

#复制镜像到/ISO目录
mkdir  /ISO
cp -a  /mnt/*  /ISO

#修改镜像内容
#1、制作应答文件ks.cfg
#2、修改/ISO/isolinux/isolinux.cfg
#3、修改/ISO/isolinux/grub.conf
#4、修改/ISO/EFI/BOOT/grub.cfg
#5、修改镜像的LABEL为CentOS7 原系统为 CentOS\x207\x20x86_64 由于带空格所以有\x20 为了有些系统不识别这里给换成CentOS7
#6、放入tar包

cat>/ISO/isolinux/ks.cfg<<EOF
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
#ignoredisk --only-use=sda

# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information
network  --bootproto=dhcp --device=ens33 --onboot=off --onboot=on --ipv6=auto --no-activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$rOMaGigzYAyI5Ata$3RzuCFJ2Oksrr6ZpLf0sJI2C8qa4dkP.k1RhCpf5hm5Si4lWvBE8YyOVmZ5uMyI6eIXhKfewTciTr7OKyO/bB0
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part pv.156 --fstype="lvmpv" --ondisk=sda --size=9215
part /boot --fstype="xfs" --ondisk=sda --size=1024
volgroup centos --pesize=4096 pv.156
logvol /  --fstype="xfs" --grow --maxsize=51200 --size=1024 --name=root --vgname=centos
logvol swap  --fstype="swap" --size=1023 --name=swap --vgname=centos

%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

%post --nochroot
cp /run/install/repo/Packages/backup.tar.gz /mnt/sysimage/
chmod +x /mnt/sysimage/etc/rc.d/rc.local
echo "cd / && tar xpfz backup.tar.gz -C /  && rm -f /backup.tar.gz && rm -f /etc/sysconfig/network-scripts/ifcfg-ens192 && reboot " >>  /mnt/sysimage/etc/rc.d/rc.local
%end
EOF

#其中倒数第二行有个: rm -f /etc/sysconfig/network-scripts/ifcfg-ens192  是删除原系统网卡配置文件,需要根据自己系统进行修改。

#isolinux.cfg  quiet后增加inst.ks=cdrom:/isolinux/ks.cfg
#debug --graphics
default=1
splashimage=@SPLASHPATH@
timeout 60
hiddenmenu
title Install CentOS 7
findiso
kernel @KERNELPATH@ @ROOT@ quiet inst.ks=cdrom:/isolinux/ks.cfg
initrd @INITRDPATH@

#/ISO/isolinux/grub.conf   quiet后增加inst.ks=cdrom:/isolinux/ks.cfg
#debug --graphics
default=1
splashimage=@SPLASHPATH@
timeout 60
hiddenmenu
title Install CentOS 7
findiso
kernel @KERNELPATH@ @ROOT@ quiet inst.ks=cdrom:/isolinux/ks.cfg
initrd @INITRDPATH@


#/ISO/EFI/BOOT/grub.cfg   /images/pxeboot/vmlinuz之后增加 inst.ks=hd:LABEL=CentOS7:/isolinux/ks.cfg
### BEGIN /etc/grub.d/10_linux ###
menuentry'Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os {
  linuxefi /images/pxeboot/vmlinuz inst.ks=hd:LABEL=CentOS7:/isolinux/ks.cfg  inst.stage2=hd:LABEL=CentOS7  quiet
  initrdefi /images/pxeboot/initrd.img
}

#修改  CentOS\x207\x20x86_64 为  CentOS7
sed -i 's/CentOS\\x207\\x20x86_64/CentOS7/g' /ISO/isolinux/isolinux.cfg
sed -i 's/CentOS\\x207\\x20x86_64/CentOS7/g' /ISO/EFI/BOOT/grub.cfg
sed -i 's/CentOS 7 x86_64/CentOS7/g' /ISO/EFI/BOOT/grub.cfg



#放入tar包
cp  backup.tar.gz  /ISO/Packages

#重新制作镜像
cd  /
genisoimage -joliet-long -V "CentOS7" -o CentOS7-test.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
 -boot-load-size 4 -boot-info-table -R -J -v -cache-inodes -T -eltorito-alt-boot -e images/efiboot.img -no-emul-boot /ISO

#使服务器BOIS模式能够识别U盘系统
isohybrid CentOS7-test.iso

  

标签:CentOS7,自定义,isolinux,--,cfg,ks,ISO,cnetos7
From: https://www.cnblogs.com/chenjiye/p/18067802

相关文章

  • Vue3自定义指令实现权限控制
    使用Pinia(Vue.js的轻量级状态管理库,是Vuex的替代品)来管理用户权限,并结合自定义指令控制元素的显隐。步骤操作如下:1、安装Pinia:npminstallpinia或yarnaddpinia解释:安装Pinia库,这是一个轻量级的状态管理库,适用于Vue3。2、创建PiniaStore://stores/user.jsimport{......
  • SpringBoot自定义validation注解校验参数只能为指定的值
    需求:实体类中某个属性的值必须为指定的值,比如0或者1SpringBoot版本:2.4.8validation 依赖<!--数据校验--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency>......
  • Qt 自定义控件
    参考:https://blog.csdn.net/danshiming/article/details/134383612https://blog.csdn.net/u011832219/article/details/128531359 1、创建自定义控件新建qt项目(项目1),选择其他项目中的“Qt设计师自定义控件”,构建套件的版本类型需要与'帮助'列表中'AboutQtCreator'弹窗的......
  • uniapp自定义导航栏
    uniapp项目自定义顶部导航栏1.创建组件完整代码navigation.vue<template><viewclass="navbar-header":style="isfixed?'padding-top'+navHeight+'px':'padding-top:0px'"><viewclass="navbarcustom......
  • RAG实战5-自定义prompt
    RAG实战5-自定义prompt在阅读本文之前,先阅读RAG实战4。在RAG实战4中我们分析了LlamaIndex中RAG的执行过程,同时留下了一个尚待解决的问题:LlamaIndex中提供的prompttemplate都是英文的,该如何使用中文的prompttemplate呢?直接看以下代码:importloggingimportsysimporttorchf......
  • 自定义事件提醒程序
    因为各大软件无法实现每隔自定义固定天数进行事件提醒的功能,在此用Python写了一个简易的Windows端事件提醒弹窗程序。注意没有做界面,只是把事件写死在了程序中,设置为开机自启动,挂在后台一直运行(cpu占用率几乎为0%),到点就会进行弹窗提醒。Step0.环境配置建议新建一个环境,后面用......
  • VMware ESXi 7.0 Update 3p 下载 - 领先的裸机 Hypervisor (安全更新)
    VMwareESXi7.0Update3p下载-领先的裸机Hypervisor(安全更新)VMwareESXi7.0Update3pStandard&AllCustomImageforESXi7.0U3InstallCD请访问原文链接:https://sysin.org/blog/vmware-esxi-7-u3/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org......
  • A. k-th divisor
    https://codeforces.com/problemset/problem/762/AThisisaeasyproblembasedonnumbertheory.Wejustsimplyiterateifrom1tothevalueofsqrt(n),andcheckifnisdivisblebythevalueofiandfindallofitsdivisors,thensortthemandgetthea......
  • macOS Ventura 13.6.5 (22G621) 正式版发布,ISO、IPSW、PKG 下载 (安全更新)
    macOSVentura13.6.5(22G621)正式版发布,ISO、IPSW、PKG下载(安全更新)3月8日凌晨,macOSSonoma14.4发布,同时带来了macOSVentru13.6.5和macOSMonterey12.7.4安全更新。macOSVentura13.6及更新版本,如无特殊说明皆为安全更新,不再赘述。请访问原文链接:https://......
  • macOS Ventura 13.6.5 (22G621) Boot ISO 原版可引导镜像下载
    macOSVentura13.6.5(22G621)BootISO原版可引导镜像下载3月8日凌晨,macOSSonoma14.4发布,同时带来了macOSVentru13.6.5和macOSMonterey12.7.4安全更新。macOSVentura13.6及更新版本,如无特殊说明皆为安全更新,不再赘述。本站下载的macOS软件包,既可以拖拽到......