Kickstart 安装 CentOS7
文章目录
环境
- CentOS7.6
- genisoimage 1.1.11
- CentOS-7-x86_64-Minimal-1810.iso
复制 iso 内容到本地磁盘
|
|
创建 isolinux/ks.cfg
- mbr 启动,/home/iso/centos7/isolinux/ks.cfg 内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# Install OS instead of upgrade install # Reboot after installation reboot # 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=cn --xlayouts='cn' # System language lang zh_CN.UTF-8 # Firewall configuration firewall --disabled # SELinux configuration selinux --disabled # Network information #network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --no-activate #network --hostname=localhost.localdomain # Root password(111111) rootpw --iscrypted $6$kD.hMvv5nCY8a/SM$Gnmb4zspkuyL75BP2Gj.1SGUaWBugXkd/zMFhoDndp9CSi8VP7R5JP7rfWzL4y7fy8crH3ryDT4PFkKCc7/xM. # System services services --enabled="chronyd" # System timezone timezone Asia/Shanghai --isUtc # Clear the Master Boot Record zerombr # System bootloader configuration bootloader --location=mbr --boot-drive=sda # Partition clearing information clearpart --none --initlabel # Disk partitioning information part /boot --fstype="xfs" --ondisk=sda --size=512 part / --fstype="xfs" --ondisk=sda --grow --size=1 %packages @^minimal @core chrony %end %post lsblk > /root/lsblk %end %addon com_redhat_kdump --disable --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
- efi 启动,/home/iso/centos7/isolinux/ks.cfg 内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
# Install OS instead of upgrade install # Reboot after installation reboot # 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=cn --xlayouts='cn' # System language lang zh_CN.UTF-8 # Firewall configuration firewall --disabled # SELinux configuration selinux --disabled # Network information #network --bootproto=dhcp --device=eth0 --onboot=off --ipv6=auto --no-activate #network --hostname=localhost.localdomain # Root password(111111) rootpw --iscrypted $6$kD.hMvv5nCY8a/SM$Gnmb4zspkuyL75BP2Gj.1SGUaWBugXkd/zMFhoDndp9CSi8VP7R5JP7rfWzL4y7fy8crH3ryDT4PFkKCc7/xM. # System services services --enabled="chronyd" # System timezone timezone Asia/Shanghai --isUtc # Clear the Master Boot Record zerombr # System bootloader configuration bootloader --location=mbr --boot-drive=sda # Partition clearing information clearpart --none --initlabel # Disk partitioning information part /boot --fstype="xfs" --ondisk=sda --size=512 part /boot/efi --fstype="xfs" --ondisk=sda --size=512 part / --fstype="xfs" --ondisk=sda --grow --size=1 %packages @^minimal @core chrony %end %post %end %addon com_redhat_kdump --disable --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
修改启动项文件
- mbr 启动,只需修改 isolinux/isolinux.cfg
- 删除 “label check” 下的 “menu default” 一行
- 在 “label linux” 一行上方添加如下内容
1 2 3 4 5
label auto menu label ^Auto install CentOS 7 menu default kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=CentOS7 inst.ks=cdrom:/isolinux/ks.cfg quiet
- efi 启动,只需修改 EFI/BOOT/grub.cfg
- 修改第一行
1
set default="0"
- 在 “### BEGIN /etc/grub.d/10_linux ###” 一行下添加如下内容
1 2 3 4
menuentry 'Auto Install CentOS 7' --class fedora --class gnu-linux --class gnu --class os { linuxefi /images/pxeboot/vmlinuz inst.ks=cdrom:/isolinux/ks.cfg inst.stage2=hd:LABEL=CentOS7 quiet initrdefi /images/pxeboot/initrd.img }
- 修改第一行
生成 ISO 镜像
- mbr 启动,执行如下命令
1 2 3 4 5 6 7 8 9 10
genisoimage -v -R -J -T -V CentOS7 \ -b isolinux/isolinux.bin \ -c isolinux/boot.cat \ -cache-inodes \ -joliet-long \ -no-emul-boot \ -boot-load-size 4 \ -boot-info-table \ -o /home/centos7.iso \ /home/iso/centos7
- efi 启动,执行如下命令
1 2 3 4 5 6 7 8 9 10
genisoimage -v -R -J -T -V CentOS7 \ -b images/efiboot.img \ -c isolinux/boot.cat \ -cache-inodes \ -joliet-long \ -no-emul-boot \ -boot-load-size 4 \ -boot-info-table \ -o /home/centos7-efi.iso \ /home/iso/centos7
参考
文章作者 Colben
上次更新 2019-10-29