Introduction
------------
	The purpose of this document is to provide clear instructions on how to build MegaIDEal Soft RAID driver images for different kernels using shim driver source.

	LSI Logic's Shim driver has its raid intelligence as binary file megaide_lib.o and the rest of the driver is open. megaide_lib.o can be build with the open source to get driver image megaide.o/megaide.ko. Source tree is also provided with the Make file for the same. The following instruction explains how to build the driver module.


Procedure To build MegaIDE driver Module
----------------------------------------

	To build MegaIDE driver module you should have a system with kernel development packages installed. If not you may need to install compilers and make files as and when you see those are missing.

(1) Prepare Errata kernel Source Tree for the required kernel

	a. Install the required errata kernel source rpm and binary rpm
		#rpm -ivh kernel-source<version>.rpm
		#rpm -ivh kernel-<version>.rpm

	b. Clean the kernel souce by running following commands
		#cd /usr/src/linux<kernel>
		#make clean
		#make mrproper

	c. Copy apropriate config file depending on cpu (Eg. i686) and kernel type (Eg. smp) from  /usr/src/linux<version>/configs directory to /usr/src/linux<version>/.config

		Eg:
		# cd /usr/src/linux<version>
		# cp configs/kernel-2.4.9-i686-smp.config .config

		Note: In suse linux versions config file can be found at /boot/config<version> 

	d. Run following commands
		#make oldconfig
		#make dep <only for 2.4 kernel based linux distributions >

	e. Prepare Kernel Makefiel 
		Avoid this section if you are using a 2.6 kernel based system

		# cd /usr/src/linux<version>
		# vi Makefile

		Add following lines to end of Makfile
	
		megaide:
			$(MAKE) -C drivers/scsi/megaide

(2) copy shim-source<driver-version>.tgz to linux source tree in the following folder

	#cp megaide_<driver-version>.tgz /usr/src/linux<version>/drivers/scsi
	#cd /usr/src/linux<version>/drivers/scsi
	#tar  -xvzf shim_<driver-version>.tgz

	This will create a subfolder megaide and you can see shim driver source file in megaide directory.

(3) Find out the gcc compiler that system uses
	You may need to check the your gcc version before proceeding the next steps

	Following command will give you the version.
	#gcc -version r
	
	Please make a note of this and it may be required when you run buil_shim_driver script

(4) Build driver for 2.6 kernel based linux distributions

	#cd /usr/src/linux<version>/drivers/scsi/megaide

	Use buil_shim_driver script to build the driver image  	
	#./build_shim_driver /usr/src/linux<version>

	This will generate a driver image(megaide.ko). Remember in 2.6 kernel driver image file has .ko extension instead of .o extension as in 2.4 kernel
	

Procedure To Load Driver Module
-------------------------------
	
Load as a stand alone Module
----------------------------

	User can load megaide driver module by just uding insmod command. This is useful if megaide controller is used as a secondary controller.  To achieve this follow the steps below

(1)	Load SCSI Sub system 
	# modprobe scsi_mod 

(2)	Load megaide Driver module 
	# cd /usr/src/linux<version>/drivers/scsi/megaide
	# insmod megaide.[o/ko]

Note:	For each reboot user need to load megaide driver manually. To avoid this user has to have megaide driver in initrd image. Following section explains that.


Procdure to Load MegaIDE driver as a part of initrd Image 
---------------------------------------------------------

	MegaIDE driver can be made as the part of init RAM disc Image. For that user need to build a new initrd image with megaide driver and create a lilo/grub entry for the new initrd image created and update boot loader. Follow the given steps to do this 

(1) 	Install megaide driver module that created 
	#cp /usr/src/linux<version>/drivers/scsi/megaide/megaide.[o/ko] /lib/modules/<version>/kernel/drivers/scsi/megaide.[o/ko]

(2)	Create MegaIDE driver Entry in Configuration file 

	For a RedHat installation
	-------------------------
	Add following line at the end of /etc/modules.conf if megaide entry is not present 
	alias scsi_hostadapter megaide

	For a SuSE/United Linux installation 
	------------------------------------
	Add megaide with INITRD_MODULES list  in /etc/sysconfig/kernel file.
	After adding megaide  driver entry the INIRD_MODULES List should look like 	INITRD_MODULES="megaide" or INITRD_MODULES="other_drivers megaide"


(3)	Create new initrd image 

	For a RedHat installation
	-------------------------
	#cd /boot
	#mkinitrd new_initrd.img <kernel>

	note:-	See mkinitrd man page for more information (#man mkinitrd)

	For a SuSE/United Linux installation 
	------------------------------------
	SuSE installation uses mkinitrd command to create inird images mk_initrd over write /boot/initrd and  boot/initrd.suse. So you need to specify the kernel versions you are using and the initrd image name u want to have.

	Use following command will create the initrd image 
	#cd /boot
	#mkinitrd k vmlinuz-<version> -i new-initrd.img
	
	
(4)	Modify lilo/grub
	Add new_initrd.img as a new entry in the boot loaded configuration file. If you are using the lilo as boot loader your configuration file will be /etc/lilo.conf. If the user using grub boot loader the config file would be /boot/grub/menu.lst

	The best suggested option is to copy an existing entry in the boot configuration file and make a new entry by pasting the same and modify the initrd image name and title name.

	Sample Lilo Entry
	-----------------
	image=/boot/vmlinux-2.4.18-14
		label=linux-new
		initrd=/boot/new_initrd.img
		read-only
		root=/dev/sda1

	Sample Grub Entry
	-----------------
	title Red Hat Linux (2.4.18-14 with megaide driver)
		kernel (sda0,0) /vmlinuz-2.4.18-14 root=/dev/sda3  
		initrd (sda0,0)/new_initrd.img


(5)	Update boot loader

	If boot loader is lilo user need to run lilo to bring all lilo changes in to effect. 

	Following command will do the same.
	#lilo








 
