cvs commit: hints initrd.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Mon Jan 6 05:10:14 PST 2003


timothy     03/01/06 08:10:14

  Modified:    .        initrd.txt
  Log:
  Updates by author.
  
  Revision  Changes    Path
  1.7       +61 -93    hints/initrd.txt
  
  Index: initrd.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/initrd.txt,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- initrd.txt	24 Oct 2002 13:25:17 -0000	1.6
  +++ initrd.txt	6 Jan 2003 13:10:14 -0000	1.7
  @@ -6,7 +6,7 @@
           How to setup initrd for LFS.
   
   HINT:
  -$Revision: 1.6 $
  +$Revision: 1.7 $
   
   Introduction to Initial RAMDisk
   
  @@ -18,7 +18,7 @@
   Assumptions Made in this document
   
   	I have made the following assumptions in this document.
  -	File have been downloaded.
  +	Files have been downloaded.
   
   ---
   Kernel Configuration
  @@ -79,6 +79,7 @@
   	#define BB_CHROOT
   	#define BB_ECHO
   	#define BB_INSMOD
  +	#define BB_MODPROBE
   	#define BB_MOUNT
   	#define BB_PIVOT_ROOT
   	#define BB_UMOUNT
  @@ -96,53 +97,6 @@
   	during the initrid will fail.
   
   ---
  -initrd.conf
  -
  -	This is the configuration file that lists the modules
  -	that need to be included in the Initial RAM Disk.
  -
  -	Important note: The order you put the files in is
  -	very important. If you do not have the modules in 
  -	the correct order, your will get Unresolved Symbols.
  -
  -	The easiest way to see what order to load modules is
  -	to look use lsmod. Look at the modules you are using
  -	and see if they have an order to them.
  -
  -	Here is an example
  -
  -	scsi_mod               87064   4  [sd_mod aic7xxx]
  -	
  -	In this case scsi_mod is the first file to be loaded.
  -	aic7xxxx is the second file to be loaded.
  -	sd_mod is the third file to be loaded.
  -	
  -# Begin /etc/initrd.conf
  -#
  -# This is a file that is used to create an initrd image.
  -# The only items need to be listed in this file are ones that
  -# you need to boot up. IE a SCSI controller that has hard drives
  -# on it.
  -# 
  -# If you use this to create a initial ram disk for scsi you
  -# must include the following modules
  -# scsi_mod sd_mod
  -#
  -# File format is as follows
  -# module:options_for_module
  -# Example
  -# aic7xxx:io=0xc00
  -# Example without options
  -# aic7xxx:
  -
  -# SCSI
  -scsi_mod:
  -aic7xxx:
  -sd_mod:
  -
  -# End /etc/initrd.conf
  -	
  ----
   mkinitrd
   
   	For those who do not want to type out the script. It is
  @@ -155,19 +109,28 @@
   	You will need to modify the ROOT_DEVICE="" to match
   	your fstab.
   
  +	The default location for this file is /sbin
  +
   #!/bin/bash
   
   # mkinitrd for LFS by Jim Gifford <giffordj at linkline.com>
  -# Release 1.5
  +# $Revision: 1.7 $
   
   # Variables
   TEMP="$1"
   
   KERNEL_VERSION=""
  -CONFIG_FILE="/etc/initrd.conf"
  -MODULES="`echo | cat | sed -e '/#/d' -e '/ /d' $CONFIG_FILE`"
  +CONFIG_FILE="/etc/modules.conf"
  +
  +SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[    ]*#' | awk '{ print $3 }'`"
  +NEEDED_SCSI="scsi_mod sd_mod"
   
  -IMAGE_SIZE=1500
  +USB_MODULES="`grep usb-controller $CONFIG_FILE | grep -v '^[    ]*#' | awk '{ print $3 }'`"
  +NEEDED_USB="usbcore"
  +
  +MODULES="$NEEDED_SCSI $SCSI_MODULES $NEEDED_USB $USB_MODULES"
  +
  +IMAGE_SIZE=3000
   MOUNT_IMAGE="/tmp/initrd.$$"
   IMAGE="/tmp/initrd.img-$$"
   MOUNT_POINT="/tmp/initrd.mnt-$$"
  @@ -176,7 +139,7 @@
   # This needs to be your root. This must match what
   # you have in fstab
   
  -ROOT_DEVICE="/dev/scsi/host1/bus0/target0/lun0/part1"
  +ROOT_DEVICE="/dev/discs/disc0/part2"
   
   # Check for initrd Directory
   
  @@ -250,7 +213,7 @@
   mkdir -p $MOUNT_IMAGE/etc
   mkdir -p $MOUNT_IMAGE/dev
   mkdir -p $MOUNT_IMAGE/proc
  -mkdir -p $MOUNT_IMAGE/sbin
  +ln -s /bin $MOUNT_IMAGE/sbin
   
   rm -rf $MOUNT_POINT/lost+found
   
  @@ -259,11 +222,14 @@
   cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
   ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
   ln -s /bin/busybox $MOUNT_IMAGE/bin/mount
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/modprobe
   ln -s /bin/busybox $MOUNT_IMAGE/bin/mkdir
   ln -s /bin/busybox $MOUNT_IMAGE/bin/sh
   ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
  -ln -s /bin/busybox $MOUNT_IMAGE/sbin/insmod
  -ln -s /bin/busybox $MOUNT_IMAGE/sbin/pivot_root
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
  +cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
  +cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
   
   # Copying Modules
   
  @@ -296,54 +262,42 @@
   echo "#!/bin/sh" > $LINUXRC
   echo "" >> $LINUXRC
   
  -echo "/bin/echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
  +echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
   
   for MODULE in $MODULES
   	do
   		echo "$MODULE" | {
  -		IFS=':' read module options
  +		IFS=':' read module
   		module=$module
  -		options=$options
  -
  -		if [ "$options" = "" ]
  -			then
  -				echo "Loading module $module"
  -			else
  -				echo "Loading module $module with options $options"
   
  -		fi
  -
  -		if [ "$options" = "" ]
  -			then
  -				echo "/sbin/insmod /lib/$module.o" >> $LINUXRC
  -			else
  -				echo "/sbin/insmod /lib/$module.o $options" >> $LINUXRC
  -		fi
  -		                  }
  +		echo "Loading module $module"
  +		echo "insmod /lib/$module.o" >> $LINUXRC
  +		}
   done
   
  -echo "/bin/echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
  -echo "/bin/mkdir /new_root" >> $LINUXRC
  -echo "/bin/echo \"Mounting proc...\"" >> $LINUXRC
  -echo "/bin/mount -n -t proc none /proc" >> $LINUXRC
  -echo "/bin/echo \"Mounting real root dev...\"" >> $LINUXRC
  -echo "/bin/mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
  -echo "/bin/umount /proc" >> $LINUXRC
  +echo "echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
  +echo "mkdir /new_root" >> $LINUXRC
  +echo "echo \"Mounting proc...\"" >> $LINUXRC
  +echo "mount -n -t proc none /proc" >> $LINUXRC
  +echo "echo 0x0100 > /proc/sys/kernel/real-root-dev" >> $LINUXRC
  +echo "echo \"Mounting real root dev...\"" >> $LINUXRC
  +echo "mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
  +echo "umount /proc" >> $LINUXRC
   echo "cd /new_root" >> $LINUXRC
  -echo "/bin/echo \"Running pivot_root...\"" >> $LINUXRC
  -echo "/new_root/sbin/pivot_root . initrd" >> $LINUXRC
  +echo "echo \"Running pivot_root...\"" >> $LINUXRC
  +echo "pivot_root . initrd" >> $LINUXRC
   echo "if [ -c initrd/dev/.devfsd ]" >> $LINUXRC
   echo "	then" >> $LINUXRC
   echo "		echo \"Mounting devfs...\"" >> $LINUXRC
  -echo "		/new_root/bin/mount -n -t devfs none dev" >> $LINUXRC
  +echo "		mount -n -t devfs none dev" >> $LINUXRC
   echo "fi" >> $LINUXRC
   echo "if [ \$\$ = 1 ]" >> $LINUXRC
   echo "	then" >> $LINUXRC
   echo "		echo \"Running init...\"" >> $LINUXRC
  -echo "		exec /usr/sbin/chroot . sbin/init dev/console 2>&1" >> $LINUXRC
  +echo "		exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
   echo "	else" >> $LINUXRC
   echo "		echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
  -echo "		exec /usr/sbin/chroot . linuxrc dev/console 2>&1" >> $LINUXRC
  +echo "		exec chroot . linuxrc dev/console 2>&1" >> $LINUXRC
   echo "fi" >> $LINUXRC
   
   chmod +x $LINUXRC
  @@ -357,16 +311,30 @@
   rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
   
   lilo -v
  -	
  +
   ---
  -Trouble-Shooting
  +initrd script
   
  -	If you get errors with the script change the
  -	IMAGE_SIZE=1500 to IMAGE_SIZE=2000. If that doesn't work
  -	keep increasing it until it works. 
  +	The following script needs to placed in /etc/rc.d/init.d.
  +
  +#!/bin/bash
  +# Begin $rc_base/init.d/initrd
   
  -	Basically 1500 is equal to 1500k. 1000 is equal to 2000k
  +# Based on sysklogd script from LFS-3.1 and earlier.
  +# Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
   
  +source /etc/sysconfig/rc
  +source $rc_functions
  +
  +echo "Clearing Initial RAM Disk..."
  +   if [ -e /initrd/dev/.devfsd ]; then
  +      umount /initrd/dev
  +   fi
  +   umount /initrd
  +   /sbin/blockdev --flushbufs /dev/ram0
  +
  +# End $rc_base/init.d/initrd
  +		
   ---
   For Lilo
   
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe hints' in the subject header of the message



More information about the hints mailing list