cvs commit: hints initrd.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Fri Jul 26 09:36:41 PDT 2002


timothy     02/07/26 09:36:41

  Modified:    .        initrd.txt
  Log:
  Updates by author.
  
  Revision  Changes    Path
  1.2       +106 -41   hints/initrd.txt
  
  Index: initrd.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/initrd.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- initrd.txt	14 Jul 2002 17:53:50 -0000	1.1
  +++ initrd.txt	26 Jul 2002 16:36:41 -0000	1.2
  @@ -6,7 +6,7 @@
           How to setup initrd for LFS.
   
   HINT:
  -v0.1
  +v1.0
   
   Introduction to Initial RAMDisk
   
  @@ -46,35 +46,39 @@
   
   	The first one being bash.
   
  -	bash.static
  +	busybox
   	----
  +
  +	Busybox has a Config.h file that needs the following options
  +	enabled to enable them remove the //
  +
  +	#define BB_INSMOD
  +	#define BB_PIVOT_ROOT
  +
  +	You can configure the rest as you need, but remember have at
  +	least the following enabled to make initrd to work properly.
   	
  +	#define BB_ASH
  +	#define BB_ECHO
  +	#define BB_MOUNT
  +	#define BB_UMOUNT
  +	#define BB_CHROOT
  +	#define BB_INSMOD
  +	#define BB_MODPROBE
  +	#define BB_PIVOT_ROOT
  +	
  +
   	To create a static version of bash needed for initrd use
   	the following commands.
   	
   	cd /usr/src
  -	tar zxvf /usr/src/bash-2*.tar.gz
  -	cd bash*
  -	./configure --quiet --enable-static-link
  -	make -s
  -	strip bash
  -	cp bash /bin/bash.static
  -	rm -rf /usr/src/bash*
  +	tar zxvf /usr/src/busybox-*.tar.gz
  +	cd busy*
  +	make LDFLAGS=-static
  +	cp busybox /bin/busybox
   
  -	insmod.static
  -	---
  -
  -	To create a static version of lsmod for initrd use the
  -	following commands.
  -	
  -	tar jxvf /usr/src/modutils-*.tar.bz2
  -	cd mod*
  -	./configure --enable-insmod-static
  -	make -s
  -	cd insmod
  -	strip insmod.static
  -	cp insmod.static /sbin/insmod.static
  -	rm -rf /usr/src/modutils*
  +	Busybox must be in the /bin directory or the links created 
  +	during the initrid will fail.
   
   ---
   initrd.conf
  @@ -125,6 +129,10 @@
   	
   ---
   mkinitrd
  +
  +	For those who do not want to type out the script. It is
  +	available on my CVS server at 
  +	http://www.jg555.com/cvs/cvsweb.cgi/scripts/mkinitrd-lfs
   	
   	This script will create the initial RAM Disk image file.
   	By default this script creates /boot/initrd.img
  @@ -132,7 +140,7 @@
   #!/bin/bash
   
   # mkinitrd for LFS by Jim Gifford <giffordj at linkline.com>
  -# Release 0.1
  +# Release 0.4
   
   # Variables
   TEMP="$1"
  @@ -140,14 +148,22 @@
   KERNEL_VERSION=""
   CONFIG_FILE="/etc/initrd.conf"
   MODULES="`echo | cat | sed -e '/#/d' -e '/ /d' $CONFIG_FILE`"
  -INITRD="/boot/initrd.img"
   
  -IMAGE_SIZE=2000
  +IMAGE_SIZE=1500
   MOUNT_IMAGE="/tmp/initrd.$$"
   IMAGE="/tmp/initrd.img-$$"
   MOUNT_POINT="/tmp/initrd.mnt-$$"
   LINUXRC="$MOUNT_IMAGE/linuxrc"
   
  +# Check for RAM Disk Device
  +
  +if [ -e /dev/.devfsd ]
  +	then
  +		RAM_DEVICE="rd"
  +	else
  +		RAM_DEVICE="ram0"
  +fi
  +
   # Check for input
   
   if [ "$TEMP" == "" ]
  @@ -157,13 +173,15 @@
   		KERNEL_VERSION="$TEMP"
   fi
   
  +INITRD="/boot/initrd-$KERNEL_VERSION.img"
  +
   if [ "$TEMP" == "-h" ] || [ "$TEMP" == "--h" ] || [ "$TEMP" == "-help" ] || [ "$TEMP" == "--help" ]
   	then
   		echo "usage: mkinitrd kernel_version"
   		exit 1
   fi
   
  -# Start Creation on Image
  +# Creating LoopBack Device
   
   dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
   
  @@ -193,18 +211,31 @@
   					     echo "Can't get a loopback device"
   					     exit 1
   					   }
  +# Creating Directories
  +
   mkdir -p $MOUNT_IMAGE
   mkdir -p $MOUNT_IMAGE/lib
   mkdir -p $MOUNT_IMAGE/bin
   mkdir -p $MOUNT_IMAGE/etc
   mkdir -p $MOUNT_IMAGE/dev
  +mkdir -p $MOUNT_IMAGE/proc
  +mkdir -p $MOUNT_IMAGE/sbin
   
   rm -rf $MOUNT_POINT/lost+found
   
  -# Copying Static Shell and Insmod
  +# Copying Static Programs
   
  -cp -a /bin/bash.static $MOUNT_IMAGE/bin/sh
  -cp -a /sbin/insmod.static $MOUNT_IMAGE/bin/insmod
  +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/sh
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
  +ln -s /bin/busybox $MOUNT_IMAGE/sbin/chroot
  +ln -s /bin/busybox $MOUNT_IMAGE/sbin/insmod
  +ln -s /bin/busybox $MOUNT_IMAGE/sbin/modprobe
  +ln -s /bin/busybox $MOUNT_IMAGE/sbin/pivot_root
  +
  +# Copying Modules
   
   for MODULE in $MODULES
   	do
  @@ -225,7 +256,7 @@
   			           }
   	done
   
  -for i in console null tty[1234]
  +for i in console null $RAM_DEVICE tty[1234]
   	do
   		cp -a /dev/$i $MOUNT_IMAGE/dev
   done
  @@ -234,7 +265,9 @@
   
   echo "#!/bin/sh" > $LINUXRC
   echo "" >> $LINUXRC
  -					
  +
  +echo "/bin/echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
  +
   for MODULE in $MODULES
   	do
   		echo "$MODULE" | {
  @@ -245,22 +278,22 @@
   		if [ "$options" = "" ]
   			then
   				echo "Loading module $module"
  -				echo "echo \"Loading $module\"" >> $LINUXRC
   			else
   				echo "Loading module $module with options $options"
  -				echo "echo \"Loading $module with options $options\"" >> $LINUXRC
   
   		fi
   
   		if [ "$options" = "" ]
   			then
  -				echo "insmod /lib/$module.o" >> $LINUXRC
  +				echo "/sbin/insmod /lib/$module.o" >> $LINUXRC
   			else
  -				echo "insmod /lib/$module.o $options" >> $LINUXRC
  +				echo "/sbin/insmod /lib/$module.o $options" >> $LINUXRC
   		fi
   		                  }
   done
   
  +echo "/bin/echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
  +
   chmod +x $LINUXRC
   
   (cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
  @@ -269,27 +302,59 @@
   losetup -d $LOOP_DEVICE
   
   gzip -9 < $IMAGE > $INITRD
  -# rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
  +rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
  +
  +lilo -v
   
   ---
  -lilo.conf
  +For Lilo
   
   	In order to use the initrd.img file is to add the
  -	following entry to you lilo.conf file
  +	following entry to you lilo.conf file.
   
   	initrd=/boot/initrd.img
   
  -	So you lilo.conf should look something like this.
  +	So your lilo.conf should look something like this.
   
   	image=/boot/vmlinuz-2.4.18
   	label=test
  -	initrd=/boot/initrd.img
  +	initrd=/boot/initrd-2-4-18.img
   	read-only
   	root=/dev/discs/disc0/part2
   
   	If you are just testing. You should make a separate
   	entry in lilo.conf. This will still allow you to boot.	
   
  +---
  +For Grub
  +
  +	In order to use the initrd.img file is to add the
  +	following entry to you menu.lst file.
  +
  +	initrd /boot/initrd-2.4.18.img
  +
  +	So your menu.lst should look something like this.
  +
  +	title test
  +	root (hd0,1)
  +	kernel /boot/vmlinuz-2.4.18
  +	initrd /boot/initrd-2.4.18.img
  +
  +---
  +For Syslinux
  +
  +	In order to use the initrd.img file is to add the
  +	following to syslinux.cfg file.
  +
  +	append initrd=initrd-2.4.18.img
  +
  +	So your syslinux.cfg should look something like this.
  +
  +	label test
  +	kernel vmlinuz
  +	append root=/dev/discs/disc0/part2 initrd=initrd.img
  +
  +---
   Mail suggestions to giffordj at linkline.com
   
   New Version of this document can be viewed from
  
  
  
-- 
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