cvs commit: hints initrd.txt

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Fri Oct 17 20:08:57 PDT 2003


tushar      03/10/17 21:08:57

  Modified:    .        initrd.txt
  Log:
  Updated Hint: initrd
  
  Revision  Changes    Path
  1.12      +127 -265  hints/initrd.txt
  
  Index: initrd.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/initrd.txt,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -u -r1.11 -r1.12
  --- initrd.txt	11 Oct 2003 00:52:47 -0000	1.11
  +++ initrd.txt	18 Oct 2003 03:08:57 -0000	1.12
  @@ -1,6 +1,6 @@
   AUTHOR:         Jim Gifford <lfs-hints at jg555.com>
   
  -DATE: 		2003-10-09
  +DATE: 		2003-10-17
   
   LICENSE: 	GNU Free Documentation License Version 1.2
   
  @@ -9,10 +9,15 @@
   DESCRIPTION: 	This hint will assist you in creating a initrd
   		for your LFS system
   
  -PREREQUISITES: SCSI and USB Modules must be in modules.conf
  -		Linux built with modules.
  -		Busybox-0.60
  -
  +PREREQUISITES:  SCSI and USB Modules must be in modules.conf
  +		Linux built with modules and the following options.
  +		<*> SCSI support
  +		<*> ATA/IDE/MFM/RLL support
  +		<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
  +		Root Filesystem must be compiled in
  +		Initrd FileSystem must be compiled in (romfs or ext2)
  +		Busybox-1.00-pre3
  +		genromfs 0.5.1
   HINT:
   
   Introduction to Initial RAMDisk
  @@ -21,10 +26,11 @@
   Which will allow you to add modules at start-up instead of compiling them
   into the kernel.
   
  -The script that is enclosed works with SCSI and USB modules only. IDE
  -devices are recommened to be built-in the kernel. The script will
  -auto-detect all SCSI and USB modules and add them to the initial ramdisk.
  -It will also detect the root from the fstab file
  +The script will auto-detect all SCSI, IDE and USB modules and add them
  +to the initial ramdisk. It will also detect the root from the fstab file
  +
  +The above items, upon research are best if configured into the kernel. 
  +You can look at the help of each of the items for more information.
   
   ---
   Assumptions Made in this document
  @@ -36,288 +42,140 @@
   Kernel Configuration
   
   	You will need to make sure the following items are configured
  -	in your kernel. With out these, the initrd will not work.
  +	in your kernel. With out these, the initrd will not work 
  +	properly.
   
  -	Block Devices
  -	
  -	Select Loopback Device Support this can be a module
  -	or built-in.
  +	Block devices  --->
  +		<M> Loopback device support (or <*>)
  +		<*> RAM disk support
  +		(4096)   Default RAM disk size
  +		[*]   Initial RAM disk (initrd) support
  +
  +	If IDE support
  +
  +	ATA/IDE/MFM/RLL support  ---> 
  +		<*> ATA/IDE/MFM/RLL support 
  +		<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
   
  -	Select RAM Disk Support this needs to be compiled as 
  -	built-in or the initrd will not show up.
  -
  -	Set Default RAM Disk size is 4096 which is the default
  +	If SCSI support
  +	
  +	SCSI support  --->
  +		<*> SCSI support
  +		<*>   SCSI disk support 
   
  -	Select Initial RAM Disk (initrd) support needs be selected.
  +	The root and initrd file systems must be compiled into
  +	the kernel.
  +	
  +	The default initrd file system for the script is
  +	romfs, but ext2, ext3, and cramfs also can be used.
   
   ---
  -Needed File System Changes
  -
  -	You will need to create a directory for initrd to use.
  -
  -	The default one that is looked for is /initrd.
  -
  -	To Create this directory use mkdir /initrd
  +File Systems
   
  -	Another change that needs to be made is due to a bug
  -	in busybox itself.
  +	The new script has 4 choices of file systems.
  +	ext2, ext3, romfs, and cramfs.
   
  -	You will need to create a symlink to init and call it
  -	linuxrc
  +	romfs and cramfs will give you a smaller initrd.
  +	My initrd with romfs was only 425k. Compressed
  +	with gzip -9.
  +	
  +	ext2 and ext3 are the most common file systems
  +	in use, but the initrd is usually bigger.
  +	My initrd with ext3 was only 439k. Compressed with
  +	gzip -9
   
  -	cd /sbin
  -	ln -sf init linuxrc
  +	The difference was on 14k, but if your trying to
  +	boot off of a floppy, 14k could save you you.
   
   ---
  -Needed Static Modules
  +Needed Programs
  +	
  +	genromfs 0.5.1
  +	----
   
  -	In order for the initrd to work properly during boot up
  -	you will need to create to static programs.
  +	Download From
  +	http://umn.dl.sourceforge.net/sourceforge/romfs/genromfs-0.5.1.tar.gz
   
  -	The first one being bash.
  +	Information
  +	http://romfs.sourceforge.net
   
  -	busybox
  -	----
  +	Build instructions
  +	
  +	make &&
  +	make install	
   
  -	Busybox has a Config.h file that needs the following options
  -	enabled to enable them remove the //
  +	busybox 1.00-pre3
  +	----
   
  -	#define BB_INSMOD
  -	#define BB_FEATURE_SH_STANDALONE_SHELL
  +	Download From
  +	http://busybox.net/downloads/busybox-1.00-pre3.tar.bz2	
   
  -	You can configure the rest as you need, but remember have at
  -	least the following enabled to make initrd to work properly.
  +	Information
  +	http://busybox.net
   	
  -	#define BB_ASH
  -	#define BB_CHROOT
  -	#define BB_ECHO
  -	#define BB_INSMOD
  -	#define BB_MKDIR
  -	#define BB_MODPROBE
  -	#define BB_MOUNT
  -	#define BB_PIVOT_ROOT
  -	#define BB_UMOUNT
  +	Busybox has changed the way the configure the shell. It now
  +	uses a menu driven option very similar to make menuconfig
  +	in linux.
  +
  +	Here is the list of the options needed. Anything else
  +	will add to the size of your initrd.
  +
  +	General Configuration --->
  +		[*] Support for devfs NOTE - only if you using devfs
  +	Build Options  --->
  +		[*] Build BusyBox as a static binary (no shared libs)
  +	Coreutils  --->
  +		[*] echo (basic SUSv3 version taking no options
  +	Linux Module Utilities  ---> 
  +		[*] insmod
  +	Another Bourne-like Shell  --->
  +		[*]     Enable alias support
  +		[*]     Optimize for size instead of speed
  +		(0) history size
   
  -	To create a static version of bash needed for initrd use
  -	the following commands.
  -	
  -	cd /usr/src
  -	tar zxvf /usr/src/busybox-*.tar.gz
  -	cd busy*
  -	make LDFLAGS=-static
  -	cp busybox /bin/busybox
  +	The build size on my system was 495k, considerably smaller than
  +	bash.
  +
  +	After running make menuconfig you will need to run the
  +	following commands.
   
  -	Busybox must be in the /bin directory or the links created 
  -	during the initrid will fail.
  +	make
  +	cp busybox /bin/busybox.static
   
   ---
   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
  +	http://cvs.jg555.com/viewcvs.cgi/scripts/system
   	
   	This script will create the initial RAM Disk image file.
  -	By default this script creates /boot/initrd.img
  +	By default this script creates /boot/initrd-{kernelversion}.img
   
  +	I have sent a mkinitrd file to be placed
  +	in the hints attachments at 
  +	http://www.linuxfromscratch.org/hints/downloads/attachments. 
  +	
   	The default location for this file is /sbin
   
  -#!/bin/bash
  -
  -# mkinitrd for LFS by Jim Gifford <giffordj at linkline.com>
  -# Release 2.1
  -
  -# Variables
  -TEMP="$1"
  -
  -KERNEL_VERSION=""
  -CONFIG_FILE="/etc/modules.conf"
  -
  -FSTAB="/etc/fstab"
  -ROOT_DEVICE=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB)
  -
  -SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[    ]*#' | awk '{ print $3 }'`"
  -NEEDED_SCSI="scsi_mod sd_mod"
  -
  -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-$$"
  -LINUXRC="$MOUNT_IMAGE/linuxrc"
  -
  -# Check for initrd Directory
  -
  -if ! [ -e /initrd ]
  -	then
  -		mkdir /initrd
  -fi
  -		
  -# Check for RAM Disk Device
  -
  -if [ -e /dev/.devfsd ]
  -	then
  -		RAM_DEVICE="rd"
  -	else
  -		RAM_DEVICE="ram0"
  -fi
  -
  -# Check for input
  -
  -if [ "$TEMP" == "" ]
  -	then
  -		KERNEL_VERSION="`uname -r`"
  -	else 
  -		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"
  -		echo "     : mkinitrd will automatically determin kernel version"
  -		exit 1
  -fi
  -
  -# Creating LoopBack Device
  -
  -dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
  -
  -for device_number in 0 1 2 3 4 5 6 7 8
  -	do
  -		if losetup /dev/loop$device_number $IMAGE 2>/dev/null
  -			then
  -				break
  -		fi
  -done
  -
  -if [ "$device_number" = "8" ]
  -	then
  -		rm -rf $MOUNT_POINT $IMAGE
  -		echo "All of your loopback devices are in use!" >&2
  -		exit 1
  -fi
  -
  -LOOP_DEVICE=/dev/loop$device_number
  -
  -echo y | mke2fs $LOOP_DEVICE $IMAGE_SIZE > /dev/null 2> /dev/null
  -
  -echo "Using loopback device $LOOP_DEVICE"
  -
  -mkdir -p $MOUNT_POINT
  -mount -t ext2 $LOOP_DEVICE $MOUNT_POINT || {
  -					     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
  -ln -s /bin $MOUNT_IMAGE/sbin
  -
  -rm -rf $MOUNT_POINT/lost+found
  -
  -# Copying Static Programs
  -
  -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/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
  -
  -for MODULE in $MODULES
  -	do
  -		echo "$MODULE" | {
  -		IFS=':' read module options
  -		module=$module
  -		options=$options
  -		DIR_SEARCH1="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers`"
  -		for DIR_1SEARCH in $DIR_SEARCH1
  -		do
  -			cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
  -			DIR_SEARCH2="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH`"
  -			for DIR_2SEARCH in $DIR_SEARCH2
  -				do
  -					cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$DIR_2SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
  -				done
  -		done
  -			           }
  -	done
  -
  -for i in console null $RAM_DEVICE tty[1234]
  -	do
  -		cp -a /dev/$i $MOUNT_IMAGE/dev
  -done
  -
  -# Creating linuxrc File
  -
  -echo "#!/bin/sh" > $LINUXRC
  -echo "" >> $LINUXRC
  -
  -echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
  -
  -for MODULE in $MODULES
  -	do
  -		echo "$MODULE" | {
  -		IFS=':' read module
  -		module=$module
  -
  -		echo "Loading module $module"
  -		echo "insmod /lib/$module.o" >> $LINUXRC
  -		}
  -done
  -
  -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 "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 "		mount -n -t devfs none dev" >> $LINUXRC
  -echo "fi" >> $LINUXRC
  -echo "if [ \$\$ = 1 ]" >> $LINUXRC
  -echo "	then" >> $LINUXRC
  -echo "		echo \"Running init...\"" >> $LINUXRC
  -echo "		exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
  -echo "	else" >> $LINUXRC
  -echo "		echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
  -echo "		exec chroot . sbin/linuxrc dev/console 2>&1" >> $LINUXRC
  -echo "fi" >> $LINUXRC
  -
  -chmod +x $LINUXRC
  -
  -(cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
  -
  -umount $MOUNT_POINT
  -losetup -d $LOOP_DEVICE
  -
  -gzip -9 < $IMAGE > $INITRD
  -rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
  +	There are options on the new script, it will not just create
  +	a initrd anymore. The kernel_version= is the only mandatory
  +	option
  +
  +	Options are the following:
  +
  +	Required
  +        --kernel_version={version} = use kernel version
  +
  +	Optional
  +	--ide = remove ide modules
  +	--scsi = remove scsi modules
  +	--usb = remove usb modules
  +	--cdrom = remove cdrom modules
  +	--ide-scsi = remove ide-scsi module
  +	--initrdfs={romfs|ext2|ext3|cramfs} = use either romfs,ext2,ext3, or cramfs
  +        --remove-module={module} = remove module
  +        --add-module={module} = add module
   
   ---
   initrd script
  @@ -367,7 +225,6 @@
   	label=test
   	initrd=/boot/initrd-2.4.18.img
   	read-only
  -	append="root=/dev/ram0 init=/linuxrc rw"
   
   	If you are just testing. You should make a separate
   	entry in lilo.conf. This will still allow you to boot.	
  @@ -403,12 +260,17 @@
   
   ---
   
  -VERSION:        1.5
  +VERSION:        2.3
   
  -CHANGELOG:     	1.5 Update CVS Information
  +CHANGELOG:     	2.3 Fixed Typos
  +		2.2 Fixed Typos
  +		2.1 Forget at add genromfs build information
  +		2.0 Did more Research - Found easier way to 
  +		    do things and smaller.
  +		1.5 Update CVS Information
   		1.4 Updated to New Hint Format
                   1.3 Updated Script
  -                1.2 Fixed Types
  +                1.2 Fixed Typos
                   1.1 Updated Script
                   1.0 Initial Version
   
  
  
  



More information about the hints mailing list