cvs commit: hints initrd.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Mon Sep 16 06:11:32 PDT 2002


timothy     02/09/16 06:11:32

  Modified:    .        initrd.txt
  Log:
  Updates by author.
  
  Revision  Changes    Path
  1.4       +70 -7     hints/initrd.txt
  
  Index: initrd.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/initrd.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- initrd.txt	9 Aug 2002 04:03:53 -0000	1.3
  +++ initrd.txt	16 Sep 2002 13:11:32 -0000	1.4
  @@ -6,7 +6,7 @@
           How to setup initrd for LFS.
   
   HINT:
  -v1.1
  +v1.5
   
   Introduction to Initial RAMDisk
   
  @@ -47,6 +47,15 @@
   
   	To Create this directory use mkdir /initrd
   
  +	Another change that needs to be made is due to a bug
  +	in busybox itself.
  +
  +	You will need to create a symlink to init and call it
  +	linuxrc
  +
  +	cd /sbin
  +	ln -sf init linuxrc
  +
   ---
   Needed Static Modules
   
  @@ -67,8 +76,12 @@
   	least the following enabled to make initrd to work properly.
   	
   	#define BB_ASH
  +	#define BB_CHROOT
   	#define BB_ECHO
   	#define BB_INSMOD
  +	#define BB_MOUNT
  +	#define BB_PIVOT_ROOT
  +	#define BB_UMOUNT
   
   	To create a static version of bash needed for initrd use
   	the following commands.
  @@ -138,11 +151,14 @@
   	
   	This script will create the initial RAM Disk image file.
   	By default this script creates /boot/initrd.img
  -	
  +
  +	You will need to modify the ROOT_DEVICE="" to match
  +	your fstab.
  +
   #!/bin/bash
   
   # mkinitrd for LFS by Jim Gifford <giffordj at linkline.com>
  -# Release 1.0
  +# Release 1.5
   
   # Variables
   TEMP="$1"
  @@ -151,12 +167,24 @@
   CONFIG_FILE="/etc/initrd.conf"
   MODULES="`echo | cat | sed -e '/#/d' -e '/ /d' $CONFIG_FILE`"
   
  -IMAGE_SIZE=1200
  +IMAGE_SIZE=1500
   MOUNT_IMAGE="/tmp/initrd.$$"
   IMAGE="/tmp/initrd.img-$$"
   MOUNT_POINT="/tmp/initrd.mnt-$$"
   LINUXRC="$MOUNT_IMAGE/linuxrc"
   
  +# This needs to be your root. This must match what
  +# you have in fstab
  +
  +ROOT_DEVICE="/dev/scsi/host1/bus0/target0/lun0/part1"
  +
  +# Check for initrd Directory
  +
  +if ! [ -e /initrd ]
  +	then
  +		mkdir /initrd
  +fi
  +		
   # Check for RAM Disk Device
   
   if [ -e /dev/.devfsd ]
  @@ -230,8 +258,12 @@
   
   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/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
   
   # Copying Modules
   
  @@ -291,6 +323,28 @@
   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 "cd /new_root" >> $LINUXRC
  +echo "/bin/echo \"Running pivot_root...\"" >> $LINUXRC
  +echo "/new_root/sbin/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 "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 "	else" >> $LINUXRC
  +echo "		echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
  +echo "		exec /usr/sbin/chroot . linuxrc dev/console 2>&1" >> $LINUXRC
  +echo "fi" >> $LINUXRC
   
   chmod +x $LINUXRC
   
  @@ -303,6 +357,15 @@
   rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
   
   lilo -v
  +	
  +---
  +Trouble-Shooting
  +
  +	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. 
  +
  +	Basically 1500 is equal to 1500k. 1000 is equal to 2000k
   
   ---
   For Lilo
  @@ -318,7 +381,7 @@
   	label=test
   	initrd=/boot/initrd-2-4-18.img
   	read-only
  -	root=/dev/discs/disc0/part2
  +	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.	
  @@ -344,13 +407,13 @@
   	In order to use the initrd.img file is to add the
   	following to syslinux.cfg file.
   
  -	append initrd=initrd-2.4.18.img
  +	append root=/dev/ram0 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
  +	append root=/dev/ram0 initrd=initrd.img
   
   ---
   Mail suggestions to giffordj at linkline.com
  
  
  
-- 
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