龙空技术网

制作CentOS 7 ISO镜像自动化安装

随心所欲 46

前言:

目前看官们对“win7镜像安装教程 iso”大约比较珍视,看官们都想要知道一些“win7镜像安装教程 iso”的相关知识。那么小编也在网摘上汇集了一些有关“win7镜像安装教程 iso””的相关文章,希望朋友们能喜欢,大家快快来了解一下吧!

1、环境介绍

本实验使用CentOS 7.6 制作自动安装ISO镜像。

本实验准备两个ks.cfg文件,分别是Minimal Install安装和Server with GUI安装。

2、制作步骤如下2.1 安装system-config-kickstart

# 安装system-config-kickstart工具,此工具需要系统是图形桌面。~]# yum install -y system-config-kickstart

提示:在CentOS 7上使用system-config-kickstart工具无法选择安装包,如下图1

图1

解决方法如下:

~]# mount /dev/cdrom /mnt  //挂载镜像到系统上~]# cat /etc/yum.repos.d/development.repo  //创建development.repo文件(提示文件名:可以是任意名字)[development] -->这行内容是主要的name=cdrom baseurl=

再次执行:system-config-kickstart命令,显示结果如下图2:

图2

2.2 使用system-config-kickstart生成ks.cfg文件配置:Basic Configuration:配置:Installation Method配置:Boot Loader Options配置:Partition Information配置:Authentication,默认就行了配置:Firewalld Configuration,关掉SELinux和firewalld配置:Display Configuration安装包选择

提示:Pre-Installation Script和Post-Installation Script根据实际情况添加。

配置完后,保存ks.cfg文件:

ks7-minimal.cfg内容如下:

~]# cat ks7-minimal.cfg //最终内容如下:#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Install OS instead of upgradeinstall# Keyboard layoutskeyboard 'us'# Root passwordrootpw --iscrypted $1$h.jLq6b8$2jLNP25Zl8q43.IXVhsqz.# System languagelang en_US# System authorization informationauth  --useshadow  --passalgo=sha512# Use CDROM installation mediacdrom# Use text mode installtext# SELinux configurationselinux --disabled# Do not configure the X Window Systemskipx# Firewall configurationfirewall --disabled# Reboot after installationreboot# System timezonetimezone Asia/Shanghai# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel# Disk partitioning informationpart /boot --fstype="xfs" --size=300part swap --fstype="swap" --size=2048part / --fstype="xfs" --grow --size=1%post%end%packages  # 下面是选择的安装包,根据实际情况调整。@^minimal@corekexec-tools%end

按照上面方法生成一个ks7-servergui.cfg。

与ks7-minimal.cfg不同地方,如下,其他都一样。

还有就是选择的安装包不同,具体看ks7-servergui.cfg文件内容

~]# cat ks7-servergui.cfg    //最终内容如下:#platform=x86, AMD64, or Intel EM64T#version=DEVEL# Install OS instead of upgradeinstall# Keyboard layoutskeyboard 'us'# Root passwordrootpw --iscrypted $1$OHsn0fll$lCYLSYyNs3uc6WXm33Mbc1# System languagelang en_US# System authorization informationauth  --useshadow  --passalgo=sha512# Use CDROM installation mediacdrom# Use text mode installtext# Disable Initial Setup on first bootfirstboot --disable# SELinux configurationselinux --disabled# Firewall configurationfirewall --disabled# Reboot after installationreboot# System timezonetimezone Asia/Shanghai# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel# Disk partitioning informationpart /boot --fstype="xfs" --size=200part swap --fstype="swap" --size=2048part / --fstype="xfs" --grow --size=1%postsystemctl set-default graphical.target   %end%packages  # 下面是选择的安装包,根据实际情况调整。@^graphical-server-environment@base@compat-libraries@core@desktop-debugging@development@dial-up@fonts@gnome-desktop@guest-agents@guest-desktop-agents@hardware-monitoring@input-methods@internet-browser@multimedia@print-client@x11kexec-tools%end

检查ks文件的语法错误:使用ksvalidator命令

例如:~]# ksvalidator ks7-servergui.cfg

2.3 复制光盘下内容到data目录下

~]# mkdir /data~]# cp -rv /mnt/ /data/myiso~]# ls -l /data/myisototal 320-rw-r--r--. 1 root root     14 Jul  3 18:10 CentOS_BuildTagdrwxr-xr-x. 3 root root     35 Jul  3 18:10 EFI-rw-r--r--. 1 root root    227 Jul  3 18:10 EULA-rw-r--r--. 1 root root  18009 Jul  3 18:10 GPLdrwxr-xr-x. 3 root root     57 Jul  3 18:10 imagesdrwxr-xr-x. 2 root root    198 Jul  3 18:10 isolinuxdrwxr-xr-x. 2 root root     43 Jul  3 18:10 LiveOSdrwxr-xr-x. 2 root root 221184 Jul  3 18:12 Packagesdrwxr-xr-x. 2 root root   4096 Jul  3 18:12 repodata-rw-r--r--. 1 root root   1690 Jul  3 18:12 RPM-GPG-KEY-CentOS-7-rw-r--r--. 1 root root   1690 Jul  3 18:12 RPM-GPG-KEY-CentOS-Testing-7-r--r--r--. 1 root root   2883 Jul  3 18:12 TRANS.TBL
2.4 将生成ks.cfg文件复制到/data/myiso目录下
~]# cp ks7-minimal.cfg ks7-servergui.cfg /data/myiso/
2.5 生成yum 元数据
~]# cd /data/myiso/repodata/[root@localhost repodata]# ls276ebf1746f2994d58b786a62e58727962f4b633cac7b289b0ef18e80df7578e-other.xml.gz2ff4471767c82fed8b27981c603e3dc9d6559ca69e162f5ca2bb53f2450c8b08-primary.sqlite.bz25504e9b031f0f2ee7e377b28b5cd0d4785a093acf37e86b4397611341540d7c1-other.sqlite.bz2aced7d22b338fdf7c0a71ffcf32614e058f4422c42476d1f4b9e9364d567702f-c7-x86_64-comps.xmlbc140c8149fc43a5248fccff0daeef38182e49f6fe75d9b46db1206dc25a6c1c-c7-x86_64-comps.xml.gzc4a7811896f3a65404455f3631907adaca3bb9bcd93acb6e476a9a7708abe8c7-filelists.sqlite.bz2e005e92e5e4a30b46c189587e09bfdfdc30500df3f4479637d1a9c2a9798aa6e-filelists.xml.gzf4267434952367b8ee0a241f62540b0778b74911e27241d09d60ccdb657ba1a2-primary.xml.gzrepomd.xmlTRANS.TBL# 1.将目录下*-comps.xml文件备份一下~]# cp aced7d22b338fdf7c0a71ffcf32614e058f4422c42476d1f4b9e9364d567702f-c7-x86_64-comps.xml /root/# 2.将目录下所有文件都删除~]# rm -rf *# 3.将备份xml文件复制到当前目录下~]# cp /root/aced7d22b338fdf7c0a71ffcf32614e058f4422c42476d1f4b9e9364d567702f-c7-x86_64-comps.xml .# 4.生成元数据[root@localhost repodata]# cd ..[root@localhost myiso]# createrepo -g repodata/aced7d22b338fdf7c0a71ffcf32614e058f4422c42476d1f4b9e9364d567702f-c7-x86_64-comps.xml .Spawning worker 0 with 4021 pkgsWorkers FinishedSaving Primary metadataSaving file lists metadataSaving other metadataGenerating sqlite DBsSqlite DBs complete[root@localhost myiso]# ls repodata/276ebf1746f2994d58b786a62e58727962f4b633cac7b289b0ef18e80df7578e-other.xml.gz399b24dae0f470cd0894ebe02e98fa57a997b0a01f5b399e0643d4adc7f29c61-primary.sqlite.bz249f2e4b0981b9e348c16fe51da18b982dedc42ed5cf3dd963514fc0c738e9462-primary.xml.gz5504e9b031f0f2ee7e377b28b5cd0d4785a093acf37e86b4397611341540d7c1-other.sqlite.bz2aced7d22b338fdf7c0a71ffcf32614e058f4422c42476d1f4b9e9364d567702f-c7-x86_64-comps.xmlbc140c8149fc43a5248fccff0daeef38182e49f6fe75d9b46db1206dc25a6c1c-c7-x86_64-comps.xml.gzc4a7811896f3a65404455f3631907adaca3bb9bcd93acb6e476a9a7708abe8c7-filelists.sqlite.bz2e005e92e5e4a30b46c189587e09bfdfdc30500df3f4479637d1a9c2a9798aa6e-filelists.xml.gzrepomd.xml# 5.删除TRANS.TBL [root@localhost myiso]# find -name TRANS.TBL ./EFI/BOOT/fonts/TRANS.TBL./EFI/BOOT/TRANS.TBL./EFI/TRANS.TBL./images/pxeboot/TRANS.TBL./images/TRANS.TBL./isolinux/TRANS.TBL./LiveOS/TRANS.TBL./Packages/TRANS.TBL./TRANS.TBL[root@localhost myiso]# find -name TRANS.TBL -exec rm {} \;
2.6 修改isolinux.cfg文件内容
~]# cd /data/myiso/isolinux/~]# cat isolinux.cfg  //修改后内容如下:default vesamenu.c32timeout 600display boot.msg# Clear the screen when exiting the menu, instead of leaving the menu displayed.# For vesamenu, this means the graphical background is still displayed without# the menu itself for as long as the screen remains in graphics mode.menu clearmenu background splash.pngmenu title CentOS 7menu vshift 8menu rows 18menu margin 8#menu hiddenmenu helpmsgrow 15menu tabmsgrow 13# Border Areamenu color border * #00000000 #00000000 none# Selected itemmenu color sel 0 #ffffffff #00000000 none# Title barmenu color title 0 #ff7ba3d0 #00000000 none# Press [Tab] messagemenu color tabmsg 0 #ff3a6496 #00000000 none# Unselected menu itemmenu color unsel 0 #84b8ffff #00000000 none# Selected hotkeymenu color hotsel 0 #84b8ffff #00000000 none# Unselected hotkeymenu color hotkey 0 #ffffffff #00000000 none# Help textmenu color help 0 #ffffffff #00000000 none# A scrollbar of some type? Not sure.menu color scrollbar 0 #ffffffff #ff355594 none# Timeout msgmenu color timeout 0 #ffffffff #00000000 nonemenu color timeout_msg 0 #ffffffff #00000000 none# Command prompt textmenu color cmdmark 0 #84b8ffff #00000000 nonemenu color cmdline 0 #ffffffff #00000000 nonemenu separator # insert an empty linelabel CentOS Server GUI  menu label ^Install CentOS 7 Server GUI  kernel vmlinuz  append initrd=initrd.img ks=cdrom:/ks7-servergui.cfgmenu separator # insert an empty linelabel CentOS minimal  menu label ^Install CentOS 7 minimal  kernel vmlinuz  append initrd=initrd.img ks=cdrom:/ks7-minimal.cfgmenu separator # insert an empty linelabel local  menu label Boot from ^local drive  menu default  localboot 0xffff
2.7 制作iso镜像
[root@localhost ~]# mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "CentOS 7.6 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat  -o /root/CentOS-7.6-x86_64-boot.iso /data/myiso/......以上省略Total translation table size: 1019973Total rockridge attributes bytes: 450366Total directory bytes: 681984Path table size(bytes): 140Done with: The File(s)                             Block(s)    2239478Writing:   Ending Padblock                         Start Block 2240077Done with: Ending Padblock                         Block(s)    150Max brk space used 4240002240227 extents written (4375 MB)
3、测试制作的ISO镜像

新建虚拟机进行安装,如下是选择显示安装菜单界面。

以上制作的ISO镜像测试结果,可以实现自动安装。

标签: #win7镜像安装教程 iso