集成raid驱动下CentOS 5.5系统盘的定制 推荐
2012-05-17 18:00
627 查看
由于CentOS 5.5操作系统自身没有集成Logic MegaRAID SAS 1078驱动,所以在标配有此类raid卡的服务器需要安装CentOS 5.5时,需要我们用软驱或者U盘的方式来加载raid驱动,进而完成系统的安装。针对此种情况,本人突发奇想,想自定制一套满足此类raid卡的CentOS 5.5系统盘,此系统盘除了只需手动分区外(由于分区会因业务的不同会有所变化,故此处不定制),其余所有要实现自动安装之目的,而且需增加一些第三方的软件包与做一些系统安全方面的设置,从而达到真正自动运维之目的,为了这个梦想,本人找遍谷歌与百度,网上都能难找到一篇完全的教程与文档来实现我的这个想法。紧接着...下面就有了我自己艰难的定制之路。
在定制之前,本人开始直接想尝试修改光盘根目录下的isolinux目录下的引导文件isolinux.cfg,直接在引导选项加入Logic MegaRAID SAS 1078卡的驱动文件megasr.img,即操作方式:dd=cdrom:/megasr.img文件,可是事与愿违,启动安装过程中,提示让我们再次选择设备驱动器来加载第三方驱动,故只有另辟蹊径,重谋对策。考虑到系统安装识别驱动是靠initrd.img这个镜像来实现的,需initrd.img这个文件解开,把Logic MegaRAID SAS 1078 raid卡驱动文件中的.ko文件导入到initrd.img文件,进行再次打包,以实现系统的顺利安装;同时为了实现安装好的系统顺利启动,我们再次需要编辑ks.cfg这个kickstart文件,将Logic MegaRAID SAS 1078 raid卡驱动文件中的.ko文件导入到/lib/modules/`uname -r`/updates/目录下,mkinitrd重新制作initrd文件来实现安装后系统的引导,具体步骤如下:
1、挂载光驱
2、创建临时目录
3、提取安装好系统需要RPM包
正常安装好操作系统在/root目录下会有install.log文件,这个就是操作系统安装RPM包的记录,我们从这些记录中,将所需的RPM包从/mnt/CentOS中复制到/root/iso/CentOS里面去,这里我们编写脚本package.sh。
运行package.sh脚本,会筛选出我们需要的一些rpm包,rpm包放置在我们定制系统盘的/root/iso目录下的CentOS目录中。
4、把原镜像除了CentOS目录外的文件全部复制至/root/iso目录下
5、解开initrd.img文件(file /root/iso/isolinux/initrd.img查看是gzip文件)
modules子目录中的modules.cgz是经过gzip压缩过的cpio包,将其解开。
6、解压Logic MegaRAID SAS 1078 raid卡驱动文件megasr.img文件(这里以附件的形式上传到博文后面,请自行解压,导入)
7、生成新的initrd.img文件
就像我们以前所做的,修改了源码包中的内容就势必再次打包恢复,这里我们需要把修改过的内容打包成一个initrd.img文件,不过这里要注意打包时的压缩格式,modules.cgz文件用的是crc格式,而initrd.img文件用的是newc格式,命令参数不要弄错。
8、将打包好的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工具附件,请自行解压开来,上传到服务器上)
10、安装上述定制的软件包,我们需要配置ks.cfg文件,具体ks.cfg的配置文件如下:
11、为了使用系统安装按照ks.cfg文件来执行安装,编辑/root/iso/isolinux目录下的isolinux.cfg文件,如下:
12、生成comps.xml文件
13、制作自定制CentOS 5.5系统镜像
好了,这样在root根目录下就生成了我们制作的系统镜像CentOS-5.5-x86_64-bin-DVD.iso,到此为止,这样一个集成Logic MegaRAID SAS 1078 raid卡的CentOS 5.5系统盘已经定制完成了,下载下来刻盘就可以安装了!~~~
附件:http://down.51cto.com/data/2360596
在定制之前,本人开始直接想尝试修改光盘根目录下的isolinux目录下的引导文件isolinux.cfg,直接在引导选项加入Logic MegaRAID SAS 1078卡的驱动文件megasr.img,即操作方式:dd=cdrom:/megasr.img文件,可是事与愿违,启动安装过程中,提示让我们再次选择设备驱动器来加载第三方驱动,故只有另辟蹊径,重谋对策。考虑到系统安装识别驱动是靠initrd.img这个镜像来实现的,需initrd.img这个文件解开,把Logic MegaRAID SAS 1078 raid卡驱动文件中的.ko文件导入到initrd.img文件,进行再次打包,以实现系统的顺利安装;同时为了实现安装好的系统顺利启动,我们再次需要编辑ks.cfg这个kickstart文件,将Logic MegaRAID SAS 1078 raid卡驱动文件中的.ko文件导入到/lib/modules/`uname -r`/updates/目录下,mkinitrd重新制作initrd文件来实现安装后系统的引导,具体步骤如下:
1、挂载光驱
[root@localhost ~]# mount /dev/cdrom /mnt
2、创建临时目录
[root@localhost ~]# mkdir -p /root/iso/CentOS
3、提取安装好系统需要RPM包
正常安装好操作系统在/root目录下会有install.log文件,这个就是操作系统安装RPM包的记录,我们从这些记录中,将所需的RPM包从/mnt/CentOS中复制到/root/iso/CentOS里面去,这里我们编写脚本package.sh。
[root@localhost ~]# vi package.sh #!/bin/bash cd /root awk '/Installing/{print $2}' install.log | sed 's/^[0-9]*://g' >package.txt DVD='/mnt/CentOS' PACKDIR='/root/package.txt' NEW_DVD='/root/iso/CentOS/' while read LINE do cp ${DVD}/${LINE}*.rpm /${NEW_DVD} || echo "$LINE don't cp......." done < package.txt rm -f package.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文件(file /root/iso/isolinux/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、解压Logic MegaRAID SAS 1078 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]# vi ks.cfg # Kickstart file automatically generated by anaconda. install cdrom lang en_US.UTF-8 langsupport --default=en_AU.UTF-8 en_US.UTF-8 zh_CN.UTF-8 zh_HK.UTF-8 zh_CN.UTF-8 zh_SG.UTF-8 zh_TW.UTF-8 en_AU.UTF-8 keyboard us # Network information network --device=eth0 --bootproto=dhcp --onboot=on rootpw 123456. authconfig --enableshadow --enablemd5 firewall --disabled selinux --disabled timezone Asia/Shanghai bootloader --location=mbr # 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 --drives=sda # part /boot --fstype ext3 --size=200 # part swap --size=8196 # part / --fstype ext3 --size=50000 # part /movies --fstype ext3 --size=100 --grow # Reboot after installation reboot %packages @base @chinese-support @core @development-libs @development-tools @dialup @editors @ftp-server @legacy-network-server @legacy-software-development @legacy-software-support @server-cfg @system-tools @text-internet keyutils trousers fipscheck device-mapper-multipath perl-Convert-ASN1 imake lsscsi audit net-snmp-utils sysstat iptraf dstat expect MegaCli gfs-utils gfs2-utils OpenIPMI-tools %post --nochroot # 挂载光驱 mkdir -p /mnt/cdrom mount -r -t iso9660 /tmp/cdrom /mnt/cdrom # 拷贝Logic MegaRAID SAS 1078 raid卡驱动文件到系统驱动目录下 cp /mnt/cdrom/Custom/megasr.ko /mnt/sysimage/lib/modules/2.6.18-194.el5/updates/ # 拷贝自定制的第三方软件包 cp /mnt/cdrom/Custom/nload-0.7.4.tar.gz /mnt/sysimage/tmp/nload-0.7.4.tar.gz > /dev/null # 解压自定制的第三方软件包 cd /mnt/sysimage/tmp tar -zxvf nload-0.7.4.tar.gz > /dev/null # 卸载光驱 umount /mnt/cdrom %post # 使安装后的系统支持Logic MegaRAID SAS 1078 raid上的磁盘 echo "alias scsi_hostadapter megasr" >> /etc/modprobe.conf depmod -v 2.6.18-194.el5 mv /boot/initrd-2.6.18-194.el5.img /boot/initrd-2.6.18-194.el5.img.bak mkinitrd --with=megasr /boot/initrd-2.6.18-194.el5.img 2.6.18-194.el5 # 安装自定制软件 cd /tmp/nload-0.7.4 ./configure > /dev/null 2>&1 make > /dev/null 2>&1 make install > /dev/null 2>&1 rm -rf /tmp/* > /dev/null 2>&1 # 禁止ipv6协议 echo "alias ipv6 off" >> /etc/modprobe.conf echo "alias net-pf-10 off" >> /etc/modprobe.conf # 停止一些不常用的系统服务 for service in NetworkManager NetworkManagerDispatcher acpid anacron apmd atd auditd autofs bluetooth conman cpuspeed cups dc_client dc_server dhcdbd dund firstboot gpm haldaemon hidd ip6tables irda irqbalance lm_sensors lvm2-monitor mcstrans mdmonitor mdmpd messagebus microcode_ctl netconsole netfs netplugd nfslock nscd ntpd pand pcscd portmap psacct rdisc readahead_early readahead_later restorecond rhnsd rpcgssd rpcidmapd rpcsvcgssd saslauthd smartd snmptrapd wpa_supplicant ypbind do chkconfig --level 35 $service off done # 开启一些常用的系统服务 for service in ipmi crond do chkconfig --level 35 $service on done # 系统安装完成,弹出光驱 eject
11、为了使用系统安装按照ks.cfg文件来执行安装,编辑/root/iso/isolinux目录下的isolinux.cfg文件,如下:
[root@localhost iso]# cd /root/iso/isolinux/
[root@localhost isolinux]# vi isolinux.cfg default kickstart prompt 1 timeout 60 display boot.msg F1 boot.msg F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label linux kernel vmlinuz append initrdinitrd=initrd.img label text kernel vmlinuz append initrdinitrd=initrd.img text label ks kernel vmlinuz append ks initrdinitrd=initrd.img label local localboot 1 label memtest86 kernel memtest append - label kickstart kernel vmlinuz 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 MegaRAID SAS 1078 raid卡的CentOS 5.5系统盘已经定制完成了,下载下来刻盘就可以安装了!~~~
附件:http://down.51cto.com/data/2360596
相关文章推荐
- 基于centos 5.5定制版集成ispconfig,webmin虚拟主机管理系统
- 基于CentOS 5.5,集成LAMP、LNMP精简定制版应用服务器
- 如何为系统盘集成SATA驱动
- 最新基于CentOS 5.5 ,集成lamp,lnmp终级安装版
- (3)制作windows 2003自动安装盘-集成补丁/Raid及硬件驱动
- CentOS 5.5升级网卡驱动
- U盘安装Centos 更新raid驱动
- CentOS 6.2 LAMP系统集成与安全 推荐
- CentOS 5.5 高可用性群集配置 推荐
- 最新基于CentOS 5.5 ,集成lamp,lnmp终级安装版
- (4)制作windows 2003自动安装盘-集成补丁/Raid及硬件驱动
- 在VMware Workstation 9下安装CentOS 5.5 推荐
- 在vmware中模拟使用raid 1 安装centos 5.5
- (5)制作windows 2003自动安装盘-集成补丁/Raid及硬件驱动
- windows server 2008 R2 wim镜像怎么集成驱动(网卡,raid)
- Vmware Esxi 5.5 不能别硬件驱动的ISO Custom方法 推荐
- 【Linux】CentOS5.5系统定制2安装特定rpm
- centos 5.5 下的nis设置(server client) 推荐
- CentOs5.5使用G4L克隆磁盘更换坏盘 推荐
- (转)LSI SAS 1068E Raid CentOS 5.5 安装实例浪潮NF5220系列 分类: linux