在Windows上制作CentOS自动安装的光盘的教程

2020-01-30 14:30:23于丽

1 复制光盘文件

1)挂载iso镜像

创建目录用于挂载光盘:
 

复制代码mkdir /root/centos7

挂载iso镜像
 

复制代码mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos7

2)复制光盘文件到编辑目录进行编辑

因为挂载上iso镜像是只读的,如果要编辑,需要将文件复制出来,再编辑。

首先创建编辑目录:
 

复制代码mkdir /root/centos7_iso

复制光盘文件:
 

复制代码cp -rf /root/centos7/* /root/centos7_iso/

diskinfo文件需求单独拷贝下:
 

复制代码cp /root/centos7/.discinfo /root/iso

2 编辑ks.cfg文件

系统安装的时候,按照ks.cfg文件的内容进行安装,我们把ks.cfg文件放到isolinux目录下:
 

复制代码cd /root/centos7_iso/isolinux
vim ks.cfg

我的ks.cfg文件内容如下:
 
复制代码
#version=RHEL/CentOS7 by xiaoli110
install
# Keyboard layouts
keyboard 'us'
# Reboot after installation
reboot
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
#network --bootproto=dhcp --device=enp2s0 --onboot=off --ipv6=auto
#network --bootproto=dhcp --device=enp3s0 --onboot=off --ipv6=auto
#network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted 111111111111111111111111111
# System timezone
timezone Asia/Shanghai
# System language
lang zh_CN
# Firewall configuration
firewall --enabled --ssh

# System authorization information
auth --useshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs"--size=500
part /boot/efi --fstype="xfs"--size=500
part swap --fstype="swap"--size=16000
part / --fstype="xfs" --grow--size=1

%packages
@base
@core
@development
@hardware-monitoring
@performance
@remote-system-management
%end

 

注意:

1)因为CentOS7系统网卡规则更复杂,为了ks.cfg更通用,最好ks.cfg不用制定网卡配置。

2)为了兼容mbr方式和EFI方式,同时创建了/boot和/boot/efi分区。

3配置mbr引导方式

编辑isoliuux目录下的isolinux.cfg文件,添加自己的内容,在isolinux.cfg文件中label linux下面添加自己的label: