歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 定制CentOS 5.5精簡版操作系統(支持 Logic MegaRAID SAS 1078驅動)

定制CentOS 5.5精簡版操作系統(支持 Logic MegaRAID SAS 1078驅動)

日期:2017/2/28 15:51:22   编辑:Linux教程

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

# Install custom file
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

# System setting
echo "alias ipv6 off" >> /etc/modprobe.conf
echo "alias net-pf-10 off" >> /etc/modprobe.conf

# Stop some not usually use service

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

# Start some ususally use service

for service in ipmi crond
do
chkconfig --level 35 $service on
done

eject

Copyright © Linux教程網 All Rights Reserved