制作CentOS 5.9自动安装光盘iso镜像
准备环境:先手动安装一台centos5.9系统
[[email protected] ~]# mkdir /iso
[[email protected] ~]# mount -o loop /dev/cdrom /media
#注意有了两个.开头的文件,也要拷过去 .treeinfo与.discinfo这两个隐藏文件
[[email protected] ~]# cp -a /media/ /iso
[[email protected] ~]# cp ks.cfg /iso/media/ #一般按照我下面配就行了
[[email protected] ~]# vim ks.cfg #rootpw可以在手动安装系统的anaconda-ks.cfg找到当时设置加密后的密码
# Kickstart file automatically generated by anaconda.
install
text
cdrom
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$c/EHNTH5$3bRky/m4LJpozrExEQpMP1
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda
# 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 ext3 --size=200 --ondisk=sda
part / --fstype ext3 --size=30720 --ondisk=sda
part swap --size=6144 --ondisk=sda
part /data --fstype ext3 --size=1 --grow --ondisk=sda
skipx
reboot
%packages
@base
@core
@development-tools
@editors
@text-internet
keyutils
iscsi-initiator-utils
trousers
fipscheck
device-mapper-multipath
lrzsz
[[email protected] ~]# cd /iso/media/
[[email protected] ~]# chmod +w isolinux/isolinux.cfg
[[email protected] ~]# vim isolinux/isolinux.cfg #一般按照我下面配就行了
default elive
prompt 1
timeout 50
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label elive
kernel vmlinuz
append ks=cdrom:/ks.cfg initrd=initrd.img
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -
#精简rpm包缩小iso镜像文件
[[email protected] ~]# cd /iso/media/CentOS
#删除java、openoffice、eclipse的rpm包,寻找占用空间大且不必要的rpm包删除
[[email protected] CentOS]# ls|grep ^java |xargs rm -f
[[email protected] CentOS]# ls|grep ^openoffice|xargs rm -f
[[email protected] CentOS]# ls|grep ^eclipse|xargs rm -f
[[email protected] CentOS]# rm -f gimp-help-2-0.1.0.10.1.1.noarch.rpm kdelibs-apidocs-3.5.4-26.el5.centos.1.x86_64.rpm thunderbird-10.0.11-1.el5.centos.x86_64.rpm kde-i18n-Spanish-3.5.4-1.noarch.rpm evolution-help-2.12.3-19.el5.x86_64.rpm
[[email protected] CentOS]# du -sh
3.5G #嗯,差不多了就这样吧
[[email protected] CentOS]# cd ..
#如果没有mkisofs命令 自己rpm包安装一下
[[email protected] media]# mkisofs -r -T -J -V "CentOS" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /tmp/CENTOS_5.9_FINAL-NEW.iso /iso/media/
[[email protected] tmp]# ls -lh /tmp/
-rw-r--r-- 1 root root 3.7G Mar 29 15:10 CENTOS_5.9_FINAL-NEW.iso
接下来来刻录DVD光盘:(将空的光盘放入光驱中)
打开UltraISO
慢慢等待刻录完成收工
如果要对已做好的iso镜像里的文件进行修改(如ks.cfg),操作如下:
需求:原ks.cfg在分区的时候只对应sda这种硬盘,而HP硬盘的不支持(/dev/cciss/c0d0p)
part /boot --fstype ext3 --size=200 --ondisk=sda
part / --fstype ext3 --size=30720 --ondisk=sda
part swap --size=6144 --ondisk=sda
part /data --fstype ext3 --size=1 --grow --ondisk=sda
只要把上面的--ondisk=sda全部删除,就可以支持所有硬盘了
1.把镜像里的文件提取到桌面,修改ks.cfg,把--ondisk=sda全部删除
转载于:https://blog.51cto.com/80888888/1333239