cat ks.cfg #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=static --device=eno5 --gateway=192.168.1.254 --ip=192.168.1.118 --nameserver=114.114.114.114 --netmask=255.255.255.0 --ipv6=auto --activate ##指定网卡静态IP信息 network --bootproto=dhcp --device=eno6 --onboot=off --ipv6=auto network --bootproto=dhcp --device=eno7 --onboot=off --ipv6=auto network --bootproto=dhcp --device=eno8 --onboot=off --ipv6=auto network --hostname=localhost.localdomain # Root password rootpw --iscrypted $6$JEae7CpqKVn5//ec$qdY1Js76iK/VQMAXjJUkrBlzeBNnMr5sCphC3miskYW3pw2nokXhSaoIRggiS3eI2TRKGXM2EmKsiuyjRp4Do1 # 设置用户名和密码 # 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 swap --fstype="swap" --ondisk=sda --size=65536 part /boot --fstype="xfs" --ondisk=sda --size=500 part /tmp --fstype="xfs" --ondisk=sda --size=102400 part /opt --fstype="xfs" --ondisk=sda --size=1024 part /boot/efi --fstype="efi" --ondisk=sda --size=500 --fsoptions="umask=0077,shortname=winnt" part /usr/local --fstype="xfs" --ondisk=sda --size=102400 part / --fstype="xfs" --ondisk=sda --size=102400 part /home --fstype="xfs" --ondisk=sda --size=51200 part /usr --fstype="xfs" --ondisk=sda --size=10240 part /var --fstype="xfs" --ondisk=sda --size=1 --grow # 剩余全部给 /var下 %packages # 安装软件应用 @^minimal @compat-libraries @core @debugging @development 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 reboot拓展
- 更改三个文件,指定镜像标签和KS文件,都是在镜像挂载目录
vim EFI/BOOT/grub.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:/ks.cfg inst.stage2=hd:LABEL=CentOS7 quiet
initrdefi /images/pxeboot/initrd.img
}
vim isolinux/isolinux.cfg
label linux
menu label ^Install CentOS 7
kernel vmlinuz
menu default
append initrd=initrd.img inst.ks=hd:LABEL=CentOS7:/ks.cfg inst.stage2=hd:LABEL=CentOS7 quiet
label check
menu label Test this ^media & install CentOS 7
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOSx207x20x86_64 rd.live.check quiet
vim isolinux/grub.conf
title Install CentOS 7
findiso
kernel @KERNELPATH@ @ROOT@ quiet inst.ks=cdrom:/ks.cfg
initrd @INITRDPATH@
- 制作命令
genisoimage -joliet-long -V CentOS7 -o CentOS7.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 /root/centos_install # -o 指定镜像标签,和上面的配置文件里的一样, # 打包的镜像也是这个名字,如***.iso 另外也可以加路径,指定生成到哪里
genisoimage -joliet-long -V CentOS7 -o CentOS7.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 /root/centos_install



