User:JonathonBlumenthal/Handy Patches

From FAIWiki
Jump to navigation Jump to search

More robust hardware detection

On install add support for all known hard drives. This is useful if installing on new hard drive controllers such as HPs SAS controllers. This is taken from the Debian hardware detections system that is run when doing a netinstall.

@@ -1,10 +1,33 @@
 #! /bin/bash
 
 # (c) Thomas Lange, 2002-2005, lange@informatik.uni-koeln.de
+# 2006/12/19 15:53:08 - Modified by Jonathon Blumenthal
+#    * Added more rubust probing of modules to load all nessicary modules. 
 
 # NOTE: Files named *.source will be evaluated, but their output ignored and instead 
 # the contents of $newclasses will be added to the list of defined classes.
 
+is_not_loaded() {
+        ! ((cut -d" " -f1 /proc/modules | grep -q "^$1\$") || \
+           (cut -d" " -f1 /proc/modules | sed -e 's/_/-/g' | grep -q "^$1\$"))
+}
+
+list_modules_dir() {
+        if [ -d "$1" ]; then
+                find $1 -type f | sed -e 's/\.k\?o$//' -e 's/.*\///'
+        fi
+}
+
+list_disk_modules() {
+        # FIXME: not all of this stuff is disk driver modules, find a way
+        # to separate out only the disk stuff.
+        list_modules_dir /lib/modules/*/kernel/drivers/ide
+        list_modules_dir /lib/modules/*/kernel/drivers/scsi
+        list_modules_dir /lib/modules/*/kernel/drivers/block
+        list_modules_dir /lib/modules/*/kernel/drivers/message/fusion
+        list_modules_dir /lib/modules/*/kernel/drivers/message/i2o
+}
+
 echo 0 > /proc/sys/kernel/printk
 
 # load all IDE drivers
@@ -21,11 +44,10 @@
 
 # load additional kernel modules (from old 11modules.source)
 # this order should also enable DMA for all IDE drives
-kernelmodules="rtc floppy usbkbd ide-disk ide-cd"
+kernelmodules="rtc floppy usbkbd ide-disk ide-cd 3w_9xxx aic97xx sata_sil sata_nv"
 case $(uname -r) in
     2.4*) kernelmodules="$kernelmodules keybdev mousedev hid ide-detect isa-pnp" ;;
-    2.6*) kernelmodules="$kernelmodules ehci-hcd ohci-hcd uhci-hcd usbhid usbmouse ide-generic mptspi ata_piix" ;;
-
+    2.6*) kernelmodules="$kernelmodules usbhid usbmouse ide-generic" ;;
 esac
 
 for mod in $kernelmodules; do
@@ -34,26 +56,28 @@
 done
 
 # let discover do most of the job
-[ -x /etc/init.d/discover ] && /etc/init.d/discover start
+/etc/init.d/discover start
 
 # now we can mount the usb file system
 mount -t usbfs  usbfs /proc/bus/usb
 
 modprobe -a sd_mod sr_mod
 
+for mod in $(list_disk_modules | sort); do
+        modprobe -a $mod
+done
+
 echo 6 > /proc/sys/kernel/printk
 
 # try to detect graphics card
 # the variable videodrv may be used to generate the XF86config file
-[ -x "$(which discover)" ] && {
-    if discover --version | grep "discover \(version \)*1\." ; then
-	videodrv=$(discover --xdriver video 2> /dev/null)
-    else
-	videodrv=$(discover --data-path=xfree86/server/device/driver display)
-    fi
-    [ -n "$videodrv" ] && echo "videodrv=$videodrv" >> $LOGDIR/additional.var
-    echo "Video card detected: $videodrv"
-}
+if discover --version | grep "discover \(version \)*1\." ; then
+    videodrv=$(discover --xdriver video 2> /dev/null)
+else
+    videodrv=$(discover --data-path=xfree86/server/device/driver display)
+fi
+[ -n "$videodrv" ] && echo "videodrv=$videodrv" >> $LOGDIR/additional.var
+echo "Video card detected: $videodrv"
 
 set_disk_info  # calculate number of available disks
 save_dmesg     # save new boot messages (from loading modules)