rm-fpackage.txt
运行package.sh脚本,会筛选出我们需要的一些rpm包,rpm包放置在我们定制系统盘的/root/iso目录下的CentOS目录中。
[root@localhost ~]# sh package.sh
4、把原镜像除了CentOS目录外的文件全部复制至/root/iso目录下
[root@localhost ~]# rsync -av --exclude=CentOS /mnt/ /root/iso
5、解开initrd.img文件(查看是gzip文件)
[root@localhost ~]# mkdir /tmp/initrd
[root@localhost ~]# cd /tmp/initrd
[root@localhost initrd]# gzip -dc /root/iso/isolinux/initrd.img | cpio -ivd
[root@localhost initrd]# cd modules
[root@localhost modules]# gzip -dc modules.cgz | cpio -ivd
modules子目录中的modules.cgz是经过gzip压缩过的cpio包,将其解开。
6、解压LogicMegaRAIDSAS1078 raid卡驱动文件megasr.img文件(这里以附件的形式上传到博文后面,请自行解压,导入)
[root@localhost modules]# mkdir /tmp/megasr
[root@localhost modules]# mount -o loop /root/megasr.img /media
[root@localhost modules]# cp /media/* /tmp/megasr
[root@localhost modules]# cd /tmp/megasr/
[root@localhost megasr]# gzip -dc modules.cgz | cpio -ivd
[root@localhost megasr]# cp 2.6.18-194.el5/megasr.ko /tmp/initrd/modules/2.6.18-194.el5/x86_64/
[root@localhost megasr]# cat modules.alias >> /tmp/initrd/modules/modules.alias
mkdir /tmp/megasr
7、生成新的initrd.img文件
就像我们以前所做的,修改了源码包中的内容就势必再次打包恢复,这里我们需要把修改过的内容打包成一个initrd.img文件,不过这里要注意打包时的压缩格式,modules.cgz文件用的是crc格式,而initrd.img文件用的是newc格式,命令参数不要弄错。
[root@localhost megasr]# cd /tmp/initrd/modules
[root@localhost modules]# find 2.6.18-53.el5 | cpio -o -H crc | gzip -9 > modules.cgz
[root@localhost modules]# rm -rf 2.6.18-53.el5
[root@localhost modules]# cd ..
[root@localhost initrd]# find . | cpio -o -H newc | gzip -9 > /tmp/initrd.img
8、将打包好的initrd.img文件复制到/root/iso/isolinux目录
[root@localhost initrd]# cp /tmp/initrd.img /root/iso/isolinux
9、上述第3步操作中,在/root/iso/CentOS目录下的软件包仅是我们定制的一些系统自带的rpm软件包;除此之外,我们还需要增加一些系统不自带的软件包,如:
MegaCli与nload,并且禁止了ipv6协议。
(其中MegaCli-2.00.15-1.i386.rpm与nload-0.7.4.tar.gz软件包详见博文后面的nload与MegaCli工具附件,请自行解压开来,上传到服务器上)
[root@localhost initrd]# cd
[root@localhost ~]# mkdir /root/iso/Custom
[root@localhost ~]# cp MegaCli-2.00.15-1.i386.rpm /root/iso/CentOS
[root@localhost ~]# cp /tmp/megasr/2.6.18-194.el5/megasr.ko /root/iso/Custom
[root@localhost ~]# cp nload-0.7.4.tar.gz /root/iso/Custom
10、安装上述定制的软件包,我们需要配置ks.cfg文件,具体ks.cfg的配置文件如下:
[root@localhost ~]#cd/root/iso
[root@localhost iso]#viks.cfg
1.# Kickstartgeneratedbyanaconda.
2.
3.install
4.cdrom
5.lang en_US.UTF-8
6.langsupport --default=en_AU.UTF-8 en_US.UTF-8zh_CN.UTF-8zh_HK.UTF-8zh_CN.UTF-8 zh_SG.UTF-8zh_TW.UTF-8en_AU.UTF-8
7.keyboard us
8.#Networkinformation
work--device=eth0 --bootproto=dhcp --onboot=on
10.rootpw 123456.
11.authconfig--enableshadow --enablemd5
12.firewall --disabled
13.selinux--disabled
14.timezone Asia/Shanghai
15.bootloader --location=mbr
16.#Thefollowingis thepartitioninformation yourequested
17.#Notethat anypartitionsyoudeletedarenotexpressed
18.#heresounless youclear allpartitionsfirst,thisis
19.# notguaranteed to work
20.clearpart--all--drives=sda
21.#part/boot--fstypeext3 --size=200
22.#parts
23.# part /--fstype ext3--size=50000
24.#part/movies--fstypeext3 --size=100 --grow
25.#Rebootafterinstallation
26.reboot
27.%packages
28.@base
29.@chinese-support
30.@core
31.@development-libs
32.@development-tools
33.@dialup
34.@editors
35.@
36.@legacy-network-server
37.@legacy-software-development
38.@legacy-software-support
39.@server-cfg
40.@system-tools
41.@text-internet
42.keyutils
43.trousers
44.fipscheck
45.device-mapper-multipath
46.perl-Convert-ASN1
47.imake
48.lsscsi
49.audit
50.net-snmp-utils
51.sysstat
52.iptraf
53.dstat
54.expect
55.MegaCli
56.gfs-utils
57.gfs2-utils
58.OpenIPMI-tools
59.
60.%post--nochroot
61.
62.#挂载光驱
63.mkdir -p/mnt/cdrom
64.mount -r-tiso9660/tmp/cdrom/mnt/cdrom
65.
66.#拷贝LogicMegaRAIDSAS1078raid卡驱动文件到系统驱动目录下
67.cp /mnt/cdrom/Custom/megasr.ko/mnt/sysimage/lib/modules/2.6.18-194.el5/updates/
68.
69.#拷贝自定制的第三方软件包
70.cp/mnt/cdrom/Custom/nload-0.7.4.tar.gz/mnt/sysimage/tmp/nload-0.7.4.tar.gz>/dev/null
71.
72.# 解压自定制的第三方软件包
73.cd/mnt/sysimage/tmp
74.tar-zxvf nload-0.7.4.tar.gz>/dev/null
75.
76.#卸载光驱
77.umount/mnt/cdrom
78.
79.%post
80.
81.#使安装后的系统支持LogicMegaRAIDSAS1078raid上的磁盘
82.echo"aliasscsi_hostadaptermegasr" >>/etc/modprobe.conf
83.depmod-v2.6.18-194.el5
84.mv /boot/initrd-2.6.18-194.el5.img/boot/initrd-2.6.18-194.el5.img.bak
85.mkinitrd--with=megasr/boot/initrd-2.6.18-194.el5.img 2.6.18-194.el5
86.
87.#安装自定制软件
88.cd/tmp/nload-0.7.4
89../configure>/dev/null2>&1
90.make>/dev/null2>&1
91.makeinstall >/dev/null2>&1
92.rm -rf/tmp/*> /dev/null2>&1
93.
94.#禁止ipv6协议
95.echo"aliasipv6off">>/etc/modprobe.conf
96.echo "alias net-pf-10off">>/etc/modprobe.conf
97.
98.#停止一些不常用的系统服务
99.forserviceinNetworkManager NetworkManagerDispatcheracpid anacronapmdatdauditd autofsbluetooth conmancpuspeedcupsdc_clientdc_serverdhcdbddundfirstbootgpmhaldaemonhidd ip6tablesirdairqbalance lm_sensors lvm2-monitormcstransmdmonitormdmpd messagebus microcode_ctlnetconsole netfsnetplugdnfslocknscdntpd pandpcscd portmappsacctrdiscreadahead_earlyreadahead_laterrestorecondrhnsd rpcgssdrpcidmapd rpcsvcgssdsaslauthdsmartdsnmptrapdwpa_supplicantypbind
100.do
101.chkconfig --level 35$serviceoff
102.done
103.
104.#开启一些常用的系统服务
105.for servicein ipmicrond
106.do
107. chkconfig--level 35$serviceon
108.done
109.
110.#系统安装完成,弹出光驱
111.eject
11、为了使用系统安装按照ks.cfg文件来执行安装,编辑/root/iso/isolinux目录下的isolinux.cfg文件,如下:
[root@localhost iso]# cd /root/iso/isolinux/
[root@localhost isolinux]# vi isolinux.cfg
1.default kickstart
2.prompt 1
3.timeout 60
4.display boot.msg
5.F1 boot.msg
6.F2 options.msg
7.F3 general.msg
8.F4 param.msg
9.F5 rescue.msg
10.label linux
11. kernel vmlinuz
12. append initrdinitrd=initrd.img
13.label text
14. kernel vmlinuz
15. append initrdinitrd=initrd.img text
16.label ks
17. kernel vmlinuz
18. append ks initrdinitrd=initrd.img
19.label local
20. localboot 1
21.label memtest86
22. kernel memtest
23. append -
24.label kickstart
25.kernel vmlinuz
26.append text initrdinitrd=initrd.img ks=cdrom:
/ks.cfg ramdisk_size=16384 ksdevice=eth0 console=tty0
ﻫ12、生成comps.xml文件
[root@localhost isolinux]# cd ..
[root@localhost iso]# createrepo -g repodata/*comps.xml /root/iso/
13、制作自定制CentOS 5.5系统镜像
[root@localhost iso]# mkisofs -o /root/CentOS-5.5-x86_64-bin-DVD.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /root/iso/
好了,这样在root根目录下就生成了我们制作的系统镜像CentOS-5.5-x86_64-bin-DVD.iso,到此为止,这样一个集成Logic MegaRAIDSAS1078raid卡的CentOS5.5系统盘已经定制完成了,下载下来刻盘就可以安装了!
~~~