安装系统的话,常用方式就是通过U盘,光盘,kickstart网络自动化安装,网络自动化安装固然好,但是有时候在现场做项目的话根本就没有kickstart环境,甚至连基本的网络建设都没有弄好,此时该如何安装系统呢,通过u盘或者光盘,手动安装的话需要很多选项要自己填写,那么我们能不能把自动化的ks环境做到系统镜像里面去呢,答案是很定的,接下来我们就来介绍CentOS 7.1全自动安装光盘制作


第一步我们挂载原始光盘镜像,假如挂载点是/mnt/cdrom,然后做如下操作


cp -ar /mnt/cdrom/* /tmp/martin/

cp -ar /mnt/cdrom/.treeinfo /tmp/martin/

cp -ar /mnt/cdrom/.discinfo /tmp/martin/

createrepo -g/tmp/martin/repodata/*-comps.xml /tmp/martin/


[root@kvm-vm3 isolinux]# pwd

/tmp/martin/isolinux

[root@Brisbane3-vm3 isolinux]# ls

boot.cat grub.conf   isolinux.bin  ks_a.cfg ks_raid_ab.cfg memtest     TRANS.TBL    vesamenu.c32

boot.msg initrd.img  isolinux.cfg  ks_b.cfg ks_raid_bc.cfg  splash.png  upgrade.img vmlinuz


在该目录下面新建四个ks文件,其实只要一个即可,这里做成四个是为了硬盘不同的分区方案而做的,

这里我们只介绍一个ks_raid_ab.cfg的配置,其实就是一份定义了软raid的分区

# platform=x86, AMD64, or Intel EM64T


# Use text mode install

#text

# Use graphical install

graphical


# Install OS instead of upgrade

install


# Use CDROM media

cdrom


# Use NFS installation media

#nfs --server=172.16.15.10 --dir=/centosinstall


# Use HTTP installation media


#url --url ftp://172.16.15.10/Public/iso/7.1-x64/


# Use FTP installation media

#url --url ftp://<username>:<password>@<server>/<dir>

#url --url ftp://172.16.15.10/


# System language

lang en_US.UTF-8

# System keyboard

keyboard us


# Network information


network --bootproto=dhcp  --hostname martin --onboot=on


#Root password

rootpw  123456


#firewall --enabled --ssh  

firewall --disable  


# System authorization information

authconfig --useshadow  --enablemd5 


# SELinux configuration

selinux --disabled


# System timezone

timezone Asia/Shanghai


# System bootloader configuration

bootloader --location=mbr


# Partition clearing information

#clearpart --all --initlabel --drives=sda

#part /boot --fstype="ext4" --size=300 --ondisk=sda

#part pv.01 --size=4096 --grow --ondisk=sda

#volgroup VolGroup00 --pesize=32768 pv.01

#logvol / --fstype="ext4" --name=LogVol00 --vgname=VolGroup00  --size=1024 --grow  

#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512


# Partition clearing information

clearpart --all --initlabel 

# Soft RAID1 partitioning information

part swap --fstype="swap" --ondisk=sda --size=4096

part raid.01 --fstype="raid" --grow --ondisk=sda --size=1

part swap --fstype="swap" --ondisk=sdb --size=4096

part raid.02 --fstype="raid" --grow --ondisk=sdb --size=1

raid / --device=md0 --fstype="ext4" --level=1 raid.01 raid.02




# Reboot after installation

reboot


# Do not configure the X Window System; if to configure it, uncomment following line

skipx

# X Window System configuration information

#xconfig  --defaultdesktop=GNOME --depth=32 --resolution=1024x768



%packages

@ additional-devel

@ base

@ core

@ debugging

@ gnome-desktop

@ development

@ mariadb

@ emacs

@ web-server

@ network-file-system-client

@ java-platform

@ platform-devel

@ php


expect

iptraf-ng

libaio-devel

libpcap-devel

lksctp-tools

lrzsz

nasm

net-snmp-utils

php-mysql

php-pear

php-soap

system-config-kickstart


# Add these system perfomance enhanced tools

vsftpd

logwatch

postfix

nmap-ncat

nmap

ftp

telnet

lsscsi

# Update the sysstat version from 9.0.4 to 10.1.6

sysstat

%end


[root@kvm-vm3 isolinux]# vim isolinux.cfg  修改该文件,增加如下内容


wKioL1c8dXvycqyjAAB-TREY-Bo351.png


此时我们将该目录/tmp/martin/   重新生成镜像即可,centos7.1原始镜像有7个多G,我们可以对其做裁剪,方法我们下次介绍


我们拿刚才做好的镜像来安装测试,这里选择一台真实的服务器通过bmc远程加载ISO镜像方式来测试

wKioL1c8diqQc4iqAADJVlnDpQI903.png


wKiom1c8dRHQDPhEAABU1HpWoQM729.png


wKioL1c8dnDx43nqAAD_AmPvEXw030.png

wKioL1c8domB-p-jAABMVshFYxE374.png


这里就是我们刚才在上面自定义的,我们选择第三个菜单来做raid分区测试,回车即可


wKioL1c8dwyzwwBDAABllvpLZKE761.png

wKioL1c8duHhK86OAAMbXWZ2JgM367.png


之后就会一直自动化安装