Linux 编译到内核
编译到内核:
+++++++++++++
1) Create a directory named megasr under /usr/src/linux/drivers/scsi
2) Extract contents of release package /megasr
3) Cd /usr/src/linux/drivers/scsi/megasr
4) Copy Makefile and megasr-lib.a from the /megasr/shim/library/sles10-64 (last directory is architecture/OS dependent)
5) Modify the Makefile to:
OPEN =open_source
EXTRA_CFLAGS += -DLSI_LINUX -DLSI_RAID5_SUPPORT
obj-$(CONFIG_MEGASR) += megasr.o
megasr-objs := ${OPEN}/oss/lin/lin_oss.o ${OPEN}/osl/lin/osl_char.o ${OPEN}/osl/lin/linux_osl.o megasr-lib.a
6) Copy /megasr/shim/open_source/* to the current directory
7) Copy open_source directory to the current directory
8) Now the current directory should have all of the files (cmn_defs.h, cmn_list.h, swr5_pciids.h, Makefile, megasr-lib.a, directories named external, hal, osl, oss and open_source)
9) Create a file named Kconfig.megasr and type the following content and save the file
config MEGASR
bool “LSI MegaRAID Software RAID Module”
depends on PCI && SCSI
help
Module for LSI MegaRAID Software RAID Module
10) go to one directory up by typing the command “cd ..”
11) edit Makefile file and add the following line after obj-$(CONFIG_MEGARAID_SAS) += megaraid/
obj-$(CONFIG_MEGASR) += megasr/
12) edit Kconfig file and add the following line after the source “drivers/scsi/megaraid/Kconfig.megaraid”
source “drivers/scsi/megasr/Kconfig.megasr”
13) Go to /usr/src/linux
cp /boot/config-xxx-smp /usr/src/linux-xxx/.config
14) make menuconfig
Select SCSI device support; SCSI disk support; SCCSI generic support, megasr to be part of the kernel
15) make bzImage
++++++++++++++++++++
zcat modules/modules.cgz | cpio -ivd
CC drivers/scsi/megaraid/megaraid_mm.o
CC drivers/scsi/megaraid/megaraid_mbox.o
CC drivers/scsi/megaraid/megaraid_sas.o
LD drivers/scsi/megaraid/built-in.o
LD drivers/scsi/pcmcia/built-in.o
CC drivers/scsi/qla2xxx/qla_os.o
关于FackRAID的驱动的编译和若干问题,但实际上编译后的megasr.ko文件被insmod后并不能真实被使用,使用 lsmod | grep megasr后会发现其中的值为0,此时是可以将该模块卸载的,因此这种情况可以理解为在Windows下的该驱动已被安装加载,但是并未被使用,重新启 动该服务器,该驱动就掉了不可用。
实 际原因是kernel依然使用了以前的sata_mv这个驱动,如何让其使用真正的驱动呢?,需要重新生成initrd文件即可,首先使用新的 kernel启动内核,然后将megasr.ko拷贝到/lib/modules/2.6.18-028stab060.8/updates/目录,更改 好权限和属主,备份在/boot下的相应img文件,然后删除,执行:
depmod -a 2.6.18-028stab060.8
mkinitrd /boot/initrd-2.6.18-028stab060.8.img 2.6.18-028stab060.8
之后重新启动,执行lsmod | grep megasr
[root@localhost ~]# lsmod | grep megasr
megasr 500164 4
scsi_mod 189240 4 sg,megasr,libata,sd_mod
可见其值为4,说明加载成功。
但是实际上在此之前RAID1内部数据是否会出现不同步也还不好说,还需要进一步观察,但是磁盘识别出来的已经正常了:
[root@localhost redhat-el5-x64]# fdisk -l
Disk /dev/sda: 248.0 GB, 248034361344 bytes
255 heads, 63 sectors/track, 30155 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 208813+ 83 Linux
/dev/sda2 27 1939 15366172+ 83 Linux
/dev/sda3 1940 2450 4104607+ 82 Linux swap / Solaris
Disk /dev/sdb: 998.5 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 121403 975169566 83 Linux
ake: *** 没有规则可以创建“include/config/kernel.release”需要的目标“include/config/auto.conf”。 停止。
root@ubuntu-T61:/usr/src/linux-2.6.18# make config
scripts/kconfig/conf arch/i386/Kconfig
drivers/scsi/megasr/Kconfig.megasr:2: invalid option
make[1]: *** [config] 错误 1
make: *** [config] 错误 2
root@ubuntu-T61:/usr/src/linux-2.6.18#
config MEGASR
bool “LSI MegaRAID Software RAID Module”
depends on PCI && SCSI
help
Module for LSI MegaRAID Software RAID Module
drivers/scsi/megasr/Kconfig.megasr (END)
安装的centos5.0,因为是sas硬盘,安装时加载了megasr-09.21.0914.2007-1-rhel50-ga-all- raid5.img驱动
安装完毕以后,运行了yum -y update
之后内核由2.6.18-8.el5升级为2.6.18-53.1.13.el5
用2.6.18-53.1.13.el5就加载不上megasr驱动找不到硬盘了
用2.6.18-8.el5可以启来,用2.6.18-53.1.13.el5启动不起来
我执行了下列步骤还是不行:
#cp /lib/modules/2.6.18-8.el5/updates/megasr.ko /lib/modules/2.6.18-53.1.13.el5/updates/megasr.ko
#mv /boot/initrd-2.6.18-53.1.13.el5.img /boot/initrd-2.6.18-53.1.13.el5.img.bak
#mkinitrd /boot/initrd-2.6.18-53.1.13.el5.img 2.6.18-53.1.13.el5
You need the driver source code to compile a matching module for your new kernel.
Please contact your vendor.
在 mkinitrd 之前 执行 depmod -a 2.6.18-53.1.13.el5 试试。
- 最新评论