CentOS7全自动安装光盘制作详解 1 复制光盘文件 1)挂载iso镜像 创建目录用于挂载光盘: mkdir /root/centos7挂载iso镜像 mount -o loop CentOS-7.0-1406-x86_64-DVD.iso/root/centos72)复制光盘文件到编辑目录进行编辑 因为挂载上iso镜像是只读的,如果要编辑,需要将文件复制出来,再编辑。 首先创建编辑目录: mkdir /root/centos7_iso复制光盘文件: cp -rf /root/centos7/* /root/centos7_iso/diskinfo文件需求单独拷贝下: cp /root/centos7/.discinfo /root/iso2 编辑ks.cfg文件 系统安装的时候,按照ks.cfg文件的内容进行安装,我们把ks.cfg文件放到isolinux目录下: cd /root/centos7_iso/isolinuxvim ks.cfg我的ks.cfg文件内容如下: #version=RHEL/CentOS7 by xiaoli110install# Keyboard layoutskeyboard 'us'# Reboot after installationreboot# Run the Setup Agent on first bootfirstboot --enableignoredisk --only-use=sda# Keyboard layoutskeyboard --vckeymap=us --xlayouts='cn'# System languagelang 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 passwordrootpw --iscrypted 111111111111111111111111111# System timezonetimezone Asia/Shanghai# System languagelang zh_CN# Firewall configurationfirewall --enabled --ssh # System authorization informationauth --useshadow --passalgo=sha512# Use CDROM installation mediacdrom# Use graphical installgraphical# SELinux configurationselinux --disabled# Do not configure the X Window Systemskipx# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all# Disk partitioning informationpart /boot --fstype="xfs"--size=500part /boot/efi --fstype="xfs"--size=500part swap --fstype="swap"--size=16000part / --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注意点: 1)memu label 后面的内容是在光盘引导起来菜单的内容,^后面的字母是菜单的快捷键; 2)通过inst.ks关键字指明ks.cfg文件位置; 3)inst.stages2标识的是系统按照介质位置,这里使用hd:LABEL表明寻找的是label为CENTOS7的安装介质,使用LABEL关键字的好处是可以精确指定安装介质,为什么label是CENTOS7,是因为我在制作光盘镜像的时候指定的,方法在后面有介绍。 4 配置EFI引导方式 1)EFI简介 EFI可扩展固件接口(ExtensibleFirmware Interface 的缩写),是英特尔主导推出的一种替代BIOS的升级方案。最早由英特尔开发,于2005年将此规范格式交由UEFI论坛来推广与发展,后来并更改名称为Unified EFI(UEFI)。UEFI论坛于2007年1月7日释出并发放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镜像 经过我踩过多个坑,成功的生成镜像,并且能在EFI和mbr环境安装的镜像生成命令如下: 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-boot3)通过-V参数指定光盘label (2)genisop_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 的系统上。 (3)genisop_w_picpath、mkisofs、xorrios几个命令的区别 说起genisop_w_picpath和mkisofs,其实里面是有点故事的。 最早的时候,Linux系统使用cdrtools工具来管理iso及光盘,mkisofs是cdrtools里面的一个工具,后来cdrtools更好了了授权许可,从GPL修改为CDDL许可,开源社区又推出了一套基于GPL的工具,cdrkit,mkisofs也被genisop_w_picpath去掉,现在系统中的mkisofs实际是genisop_w_picpath的软连接: ls -l /usr/bin/mkisofs/usr/bin/mkisofs ->/etc/alternatives/mkisofsls -l /etc/alternatives/mkisofs/etc/alternatives/mkisofs ->/usr/bin/genisop_w_picpathxorrios是另外一个比较流行的制作iso镜像的工具,并且有一个参数-asmkisofs可以和mkiso命令兼容。
' Y- A6 S! ~2 M( D2 J# k6 T4 W) F |