定制CentOS 5.5精简版操作系统(支持 Logic MegaRAID

CentOS 5.5操作系统本来不支持  Logic MegaRAID SAS 1078驱动,安装UIT ContEx 1800时会找不到小盘安装系统,现特制定支持此raid卡的镜像系统盘,直接在isolinux.cfg中dd=cdrom:/raid驱动.img文件,提示选择设备驱动器,没有达到自动安装的目的,现改变方式来制作镜像盘,总结大致需要二步走,第一步,把驱动导入到initrd.img文件中,第二步,需要编辑ks.cfg的kickstart文件,将驱动文件中的.ko文件导入到/lib/modules/`uname -r`/updates/目录下,mkinitrd来实现,具体步骤如下:

1、挂载光驱
mount /dev/cdrom /mnt

2、创建临时目录
mkdir -p /root/iso/CentOS

3、提取需要的RPM包,正常安装好操作系统在/root目录下会有install.log文件,这个就是操作系统安装RPM包的记录,我们从这些记录中,将所需的RPM包从/mnt/CentOS中复制到/root/iso/CentOS里面去
 
#!/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

4、把原镜像除了CentOS目录外的文件全部复制至/root/iso目录下
rsync -av --exclude=CentOS /mnt/  /root/iso

5、解开initrd.img文件(file /root/iso/isolinux/initrd.img查看是gzip文件)
mkdir /tmp/initrd
cd /tmp/initrd
gzip -dc /root/iso/isolinux/initrd.img | cpio -ivd
cd modules
gzip -dc modules.cgz | cpio -ivd

modules子目录中的modules.cgz是经过gzip压缩过的cpio包,将其解开。

6、解压raid卡驱动文件megasr-15.00.0120.2012-1-rhel50-U5-64.img文件(file megasr-15.00.0120.2012-1-rhel50-U5-64.img是dos软盘文件)
mkdir /tmp/megasr
mount -o loop /root/megasr-15.00.0120.2012-1-rhel50-U5-64.img /media
cp /media/*  /tmp/megasr
cd /tmp/megasr/
gzip -dc modules.cgz | cpio -ivd
cp 2.6.18-194.el5/megasr.ko /tmp/initrd/modules/2.6.18-194.el5/x86_64/
cat modules.alias >> /tmp/initrd/modules/modules.alias
 

7、生成新的initrd.img文件
就像我们以前所做的,修改了源码包中的内容就势必再次打包恢复,这里我们需要把修改过的内容打包成一个initrd.img文件,不过这里要注意打包时的压缩格式,modules.cgz文件用的是crc格式,而initrd.img文件用的是newc格式,命令参数不要弄错。
cd /tmp/initrd/modules
find 2.6.18-53.el5 | cpio -o -H crc | gzip -9 > modules.cgz
rm -rf 2.6.18-53.el5
cd ..
find . | cpio -o -H newc | gzip -9 > /tmp/initrd.img

8、将打包好的initrd.img文件复制到 /root/iso/isolinux 目录
cp /tmp/initrd.img /root/iso/isolinux

9、在/root/iso目录下,并根据自己实际需要修改安装要求编辑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

# Mount CDROM
mkdir -p /mnt/cdrom
mount -r -t iso9660 /tmp/cdrom /mnt/cdrom

# Copy our raid driver file
cp /mnt/cdrom/Custom/megasr.ko /mnt/sysimage/lib/modules/2.6.18-194.el5/updates/

# Copy our custom file
cp /mnt/cdrom/Custom/nload-0.7.4.tar.gz /mnt/sysimage/tmp/nload-0.7.4.tar.gz > /dev/null

# Uncompress our custom file
cd /mnt/sysimage/tmp
tar -zxvf nload-0.7.4.tar.gz > /dev/null

# Mount CDROM
umount /mnt/cdrom

%post

#support megasr driver
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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22029.html