CentOS 6.4 订制企业级操作系统专属光盘

订制思路:

使用kickstart生成自动应答文件,可能你做过使用kickstart 通过网络自动安装。现在我们的做法是把自动应用文件写入到光盘,通过光盘怎么部署企业级操作系统。

订制目的:

自动化安装企业级的操作系统。

需求分析:

1.安装过程需要你手动交互

2.CentOS 6开始,文本安装是不能手动分区的,如果是图形安装,对于远程安装操作系统来说,操作非常痛苦。

3.使用DVD安装,即使你使用minimal安装,可能还不能满足你的需求,感觉包还是很多。我们公司的操作系统是不允许使用vi的,只允许使用sed,所以只能自己定制光盘了


CentOS 6.4 Mini 光盘下载链接:

http://centos.arcticnetwork.ca/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso


订制步骤:

Step1: 挂载mini光盘到本地目录,用于调整。

# mkdir /opt/centos6.4

# mount /dev/cdrom /media/

# cp -arf /media/. /opt/centos6.4/ #注意这里是. 而不是* 如果是*号的话,隐藏文件是不会拷贝过去的。


Step2: 编辑ks.cfg文件,些文件可以用system-config-kickstart生成


# vim /opt/centos6.4/isolinux/ks.cfg

# Kickstart file automatically generated by anaconda.

#version=DEVEL

install

cdrom

lang en_US.UTF-8

keyboard us

network --onboot yes --device eth0 --bootproto static --ip 192.168.0.2 -- netmask 255.255.255.0 --gateway 192.168.0.1 --noipv6 --nameserver 192.168.6.200 --hostname minisys

rootpw -- iscrypted $6$PYlQysGL4L.ffkhZ$Ji1NP6wP0wERjiQATmHnbX

#Use text mode install

text

firstboot --disable

# Reboot after installation

reboot

firewall --disabled

authconfig --enableshadow --passalgo=sha512

selinux --disabled

timezone Asia/Shanghai

bootloader --location=mbr --md5pass="$1$0.fOz0Lx$roMC.zg3TE/3N5HPJnOvR0" --append="crashkernel=auto rhgb quiet"

# The following is the partition information you requested

# Note that any partitions you deleted are not expressed

# here so unless you clear all partitions first, this is

# not guaranteed to work

clearpart --all --initlabel

part /boot --fstype=ext4 --size=200

part swap --grow --maxsize=4096 --size=2048

part / --fstype=ext4 --grow --size=1


%packages --nobase

@core

-libselinux

-selinux-policy-targeted

-selinux-policy

-libselinux-utils

-vim-minimal

-dhclient

%end

#@代表要安装的包组,-代表不安装


Step3: 修改isolinux.cfg 使其应用ks.cfg文件。

# vim /opt/centos6.4/isolinux/isolinux.cfg

18 label linux

19 menu label ^Install or upgrade an existing system

20 menu default

21 kernel vmlinuz

22 append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img


# 行号代表大概位置,主要更改append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img


Step4:安装mkisofs 用于打包成光盘

# yum install -y mkisofs #安装mkisofs软件包,用于制作.iso光盘文件

# cd /opt

mkisofs -o /MiniCentOS6.4.iso -J -r -v -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "Centos6.4 Mini install" /opt/centos6.4


#mkisofs具体参数意义,请mkisofs --help


ERROR整理:

ERROR1:

Unable to read package metadata. This may be due to a missing repodata directory. Please ensure that your install tree has been correctly generated.

cannot find a valid baseurl for repo:CentOS

解决方法:

去掉光盘isolinux/ks.cfg里面的这行:

repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100