CentOS7全自动安装光盘制做详解


CentOS7全自动安装光盘制做详解node

1 复制光盘文件linux

1)挂载iso镜像ios

建立目录用于挂载光盘:redis

mkdir /root/centos7

挂载iso镜像vim

mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos7

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

由于挂载上iso镜像是只读的,若是要编辑,须要将文件复制出来,再编辑。bash

首先建立编辑目录:网络

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

label linux
 menu label ^Install CentOS 7
 kernel vmlinuz
 append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS7 quiet
 
label custom
 menu label ^Custom CentOS 7 by xiaoli110
 kernel vmlinuz
 append initrd=initrd.img inst.stage2=hd:LABEL=CENTOS7 inst.ks=cdrom:/isolinux/ks.cfg

注意点:

1memu label 后面的内容是在光盘引导起来菜单的内容,^后面的字母是菜单的快捷键;

2)经过inst.ks关键字指明ks.cfg文件位置;

3inst.stages2标识的是系统按照介质位置,这里使用hd:LABEL代表寻找的是labelCENTOS7的安装介质,使用LABEL关键字的好处是能够精确指定安装介质,为何labelCENTOS7,是由于我在制做光盘镜像的时候指定的,方法在后面有介绍。

4 配置EFI引导方式

1EFI简介

EFI可扩展固件接口(ExtensibleFirmware Interface 的缩写),是英特尔主导推出的一种替代BIOS的升级方案。最先由英特尔开发,于2005年将此规范格式交由UEFI论坛来推广与发展,后来并更更名称为Unified EFI(UEFI)UEFI论坛于200717日释出并发放2.1版本的规格,其中增长与改进了加密编码(cryptography)、网络认证(network authentication)与用户接口架构(User Interface Architecture)。

EFI是用模块化,C语言风格的参数堆栈传递方式,动态连接的形式构建的系统,较BIOS而言更易于实现,容错和纠错特性更强,缩短了系统研发的时间。

EFI在概念上很是相似于一个低阶的操做系统,而且具备操控全部硬件资源的能力。

2)配置EFI引导

进入光盘目录EFI/BOOT/,编辑grub.cfg文件,添加本身的菜单:

menuentry 'Install CentOS 7' --class fedora--class gnu-linux --class gnu --class os {
       linuxefi /p_w_picpaths/pxeboot/vmlinuz inst.stage2=hd:LABEL=CENTOS7 quiet
       initrdefi /p_w_picpaths/pxeboot/initrd.img
}
menuentry 'Install CentOS 7 custom byxiaoli110' --class fedora --class gnu-linux --class gnu --class os {
       linuxefi /p_w_picpaths/pxeboot/vmlinuz inst.ks=cdrom:/isolinux/ks.cfginst.stage2=hd:LABEL=CENTOS7 quiet
       initrdefi /p_w_picpaths/pxeboot/initrd.img
}

mbr方式相似,指明ks.cfg文件位置和安装源位置。

5 生成iso镜像

通过我踩过多个坑,成功的生成镜像,而且能在EFImbr环境安装的镜像生成命令以下:

genisop_w_picpath -v -cache-inodes -joliet-long -R -J -T -V CENTOS7 -o /root/centos7.iso    \
-c isolinux/boot.cat    -bisolinux/isolinux.bin      \
-no-emul-boot -boot-load-size 4-boot-info-table    \
-eltorito-alt-boot     -b p_w_picpaths/efiboot.img       -no-emul-boot .

 

1)中间踩过的几个坑:

1)制做镜像要使用CentOS7的系统,不要使用CentOS6的系统,由于二者系统的genisop_w_picpath命令的版本不同,6的系统制做出来的iso不能在efi环境启动;

 

2)若是要在efi启动,须要添加以下参数:

 

 -eltorito-alt-boot     -bp_w_picpaths/efiboot.img       -no-emul-boot

3)经过-V参数指定光盘label

 

2genisop_w_picpath命令参数简介

-o 指定映像文件的名称。

-b指定在制做可开机光盘时所需的开机映像文件。

-c 制做可开机光盘时,会将开机映像文件中的no-eltorito-catalog所有内容做成一个文件。

-no-emul-boot  非模拟模式启动。

-boot-load-size 4   设置载入部分的数量。

-boot-info-table 在启动的图像中现实信息。

-joliet-long   使用 joliet 格式的目录与文件名称,长文件名支持。

-R -rock    使用 Rock RidgeExtensions

-J -joliet    使用 Joliet 格式的目录与文件名称。

-v -verbose    执行时显示详细的信息。

-T -translation-table    创建文件名的转换表,适用于不支持 Rock Ridge Extensions 的系统上。

3genisop_w_picpathmkisofsxorrios几个命令的区别

提及genisop_w_picpathmkisofs,其实里面是有点故事的。

最先的时候,Linux系统使用cdrtools工具来管理iso及光盘,mkisofscdrtools里面的一个工具,后来cdrtools更好了了受权许可,从GPL修改成CDDL许可,开源社区又推出了一套基于GPL的工具,cdrkitmkisofs也被genisop_w_picpath去掉,如今系统中的mkisofs实际是genisop_w_picpath的软链接:

ls -l /usr/bin/mkisofs
/usr/bin/mkisofs ->/etc/alternatives/mkisofs
ls -l /etc/alternatives/mkisofs
/etc/alternatives/mkisofs ->/usr/bin/genisop_w_picpath

xorrios是另一个比较流行的制做iso镜像的工具,而且有一个参数-asmkisofs能够和mkiso命令兼容。

相关文章
相关标签/搜索