cvs commit: hints/ATTACHMENTS/initrd-diskcheck mkfsckinitrd

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Sun Feb 15 15:50:40 PST 2004


tushar      04/02/15 16:50:40

  Modified:    .        initrd-diskcheck.txt
               ATTACHMENTS/initrd-diskcheck mkfsckinitrd
  Log:
  Updated: initrd-diskcheck
  
  Revision  Changes    Path
  1.3       +42 -35    hints/initrd-diskcheck.txt
  
  Index: initrd-diskcheck.txt
  ===================================================================
  RCS file: /home/cvsroot/hints/initrd-diskcheck.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- initrd-diskcheck.txt	30 Oct 2003 15:10:10 -0000	1.2
  +++ initrd-diskcheck.txt	15 Feb 2004 23:50:40 -0000	1.3
  @@ -1,6 +1,6 @@
   AUTHOR:         Jim Gifford <lfs-hints at jg555.com>
   
  -DATE: 		2003-10-17
  +DATE: 		2004-02-14
   
   LICENSE: 	GNU Free Documentation License Version 1.2
   
  @@ -12,13 +12,11 @@
   		system errors
   
   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
  +		Linux built with modules.
  +			RAM Disk support built in
  +			initrd selected
  +			Root Filesystem must be compiled in
  +		Busybox-1.00-pre7
   		e2fsprogs 1.34
   HINT:
   
  @@ -41,7 +39,7 @@
   	Files have been downloaded.
   
   ---
  -Kernel Configuration
  +Kernel Configuration for 2.4
   
   	You will need to make sure the following items are configured
   	in your kernel. With out these, the initrd will not work 
  @@ -53,23 +51,24 @@
   		(4096)   Default RAM disk size
   		[*]   Initial RAM disk (initrd) support
   
  -	If IDE support
  +	The root and initrd file system must be compiled into the kernel.
  +	
  +---
  +Kernel Configuration for 2.6
  +
  +	You will need to make sure the following items are configured
  +	in your kernel. With out these, the initrd will not work
  +	properly.
   
  -	ATA/IDE/MFM/RLL support  ---> 
  -		<*> ATA/IDE/MFM/RLL support 
  -		<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
  +	Device Drivers  --->
  +		Block devices  --->
  +			<M> Loopback device support (or <*>)
  +			<*> RAM disk support
  +			(4096)   Default RAM disk size
  +			[*]   Initial RAM disk (initrd) support
   
  -	If SCSI support
  -	
  -	SCSI support  --->
  -		<*> SCSI support
  -		<*>   SCSI disk support 
  +	The root and initrd file system must be compiled into the kernel.
   
  -	The root and initrd file systems must be compiled into
  -	the kernel.
  -	
  -	The default initrd file system for the script is
  -	ext3, but ext2 also can be used.
   
   ---
   File Systems
  @@ -110,24 +109,28 @@
   	will add to the size of your initrd.
   
   	General Configuration --->
  -		[*] Support for devfs NOTE - only if you using devfs
  -	Build Options  --->
  +		[*] 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
   		[*] ln
  -	Linux Module Utilities  ---> 
  +	Linux Module Utilities  --->
   		[*] insmod
  +		[*]     Support version 2.1.x to 2.4.x Linux kernels
  +			NOTE - only if your using a 2.4 kernel
  +		[*]     Support version 2.6.x Linux kernels
  +			 NOTE - only if your using a 2.6 kernel
   	Another Bourne-like Shell  --->
   		[*]     Enable alias support
   		[*]     Optimize for size instead of speed
   		(0) history size
   	Linux System Utilities  --->
  +		[*] pivot_root
   		[*] mount
  -		[*] umount
  -		[*]     Support for a real /etc/mtab (instead of /proc/mounts
  -		(/etc/mtab)   mtab file location
  -	The build size on my system was 495k, considerably smaller than
  +
  +	The build size on my system was 502k, considerably smaller than
   	bash.
   
   	After running make menuconfig you will need to run the
  @@ -148,7 +151,7 @@
   
   	I have sent a mkinitrd file to be placed
   	in the hints attachments at 
  -	<http://www.linuxfromscratch.org/hints/downloads/attachmentsinitrd-diskcheck>. 
  +	http://www.linuxfromscratch.org/hints/downloads/attachments. 
   	
   	The default location for this file is /sbin
   
  @@ -165,6 +168,7 @@
   	--ide = remove ide modules
   	--scsi = remove scsi modules
   	--usb = remove usb modules
  +	--devfs = remove devfs settings from initrd
   	--initrdfs={ext2|ext3} = use either ext2 or ext3
           --remove-module={module} = remove module
           --add-module={module} = add module
  @@ -200,8 +204,9 @@
   		then
         		umount /initrd/dev
      	fi
  +	umount /initrd/proc
      	umount /initrd
  -   	/sbin/blockdev --flushbufs /dev/ram0
  +   	blockdev --flushbufs /dev/ram0
   
   # End $rc_base/init.d/initrd
   		
  @@ -244,7 +249,7 @@
   	In order to use the initrd.img file is to add the
   	following to syslinux.cfg file.
   
  -	append root=/dev/ram0 initrd=initrd-fsck-2.4.18.img
  +	append initrd=initrd-fsck-2.4.18.img
   
   	So your syslinux.cfg should look something like this.
   
  @@ -254,9 +259,11 @@
   
   ---
   
  -VERSION:        1.1
  +VERSION:        1.3
   
  -CHANGELOG:     	1.1 Fixed Typos
  +CHANGELOG:     	1.3 Updated Configurations
  +		1.2 Updated for 2.6 Kernel
  +		1.1 Fixed Typos
   		1.0 Initial Version
   
    New Version of this document can be viewed from http://cvs.jg555.com/viewcvs.cgi/lfs-hints
  
  
  
  1.2       +252 -110  hints/ATTACHMENTS/initrd-diskcheck/mkfsckinitrd
  
  Index: mkfsckinitrd
  ===================================================================
  RCS file: /home/cvsroot/hints/ATTACHMENTS/initrd-diskcheck/mkfsckinitrd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- mkfsckinitrd	30 Oct 2003 06:51:58 -0000	1.1
  +++ mkfsckinitrd	15 Feb 2004 23:50:40 -0000	1.2
  @@ -1,11 +1,11 @@
   #!/bin/bash
   
  -# mkfsckinitrd for LFS by Jim Gifford <scripts at j555.com>
  -# Release 3.0
  +# mkfsckinitrd for 2.4/2.6 Kernel by Jim Gifford <scripts at j555.com>
  +# Release 4.02
   
   # Define Swap and ZIP Drives
   #
  -REMOVE_PARTITIONS="SWAPDRIVE ZIPDRIVE"
  +REMOVE_PARTITIONS="/dev/sdd4"
   
   # Usage Menu
   #
  @@ -15,11 +15,13 @@
   	echo "  Required"
   	echo "	[--kernel_version={version} = use kernel version]"
   	echo "	Optional"
  -	echo "	[--ide = remove ide modules] [--scsi = remove scsi modules]"
  + 	echo "	[--ide = remove ide modules] [--scsi = remove scsi modules]"
   	echo "	[--usb = remove usb modules] "
  +	echo "	[--devfs = remove devfs settings from initrd]"
   	echo "	[--initrdfs={ext2|ext3} = use either ext2 or ext3]"
   	echo "	[--remove-module={module} = remove module]"
   	echo "	[--add-module={module} - add module]"
  +	echo "  [--root-device={device} - skips auto detection of the root device]"
   	exit
   }
   
  @@ -35,7 +37,7 @@
   while [ $# -gt 0 ]
   	do
   		case $1 in
  -		--ide)
  + 		--ide)
   			REMOVE_IDE="1"
   			echo "	Removing IDE Modules."
   			;;
  @@ -47,10 +49,19 @@
   			REMOVE_USB="1"
   			echo "	Removing USB Modules."
   			;;
  +		--devfs)
  +			REMOVE_DEVFS="1"
  +			echo "	Removing devfs settings."
  +			;;
   		--kernel_version=*)
   			KERNEL_VERSION="`echo $1 | awk -F= '{print $2;}'`"
   			echo "	Making image for kernel $KERNEL_VERSION."
  -			;;
  +			KER_VER_REL="`echo $KERNEL_VERSION | grep -o 2.6`"
  +			if [ "$KER_VER_REL" != "2.6" ]
  +				then
  +					KER_VER_REL="2.4"
  +			fi
  + 			;;
   		--initrdfs=*)
   			INITRDFS="`echo $1 | awk -F= '{print $2;}'`"
   			echo "	Initrd will be using $INITRDFS filesystem."
  @@ -78,6 +89,9 @@
   					ADD_MODULE="$ADD_MODULE $NEW_MODULE."
   			fi
   			;;
  +		--root-device=*)
  +			ROOT_DEVICE="`echo $1 | awk -F= '{print $2;}'`"
  +			;;
   		*)
   			usage
   			;;
  @@ -87,27 +101,64 @@
   
   echo "Setting up Parameters..."
   
  -# Files
  +# Show Root Device Information
  +#
  +if [ "$ROOT_DEVICE" == "" ]
  +	then
  +		ROOT_DEVICE="$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc/fstab)"
  +fi
  +
  +echo "	Root Device is $ROOT_DEVICE."
  +
  +# Get Disk Information
  +#
  +SD_DEVICE="`awk '/^[ \t]*[^#]/ { print $1; }' /etc/fstab | grep sd`"
  +HD_DEVICE="`awk '/^[ \t]*[^#]/ { print $1; }' /etc/fstab | grep hd`"
  +
  +# Module Files
   #
  -CONFIG_FILE="/etc/modules.conf"
  +if [ "$KER_VER_REL" == "2.4" ]
  +	then
  +		CONFIG_FILE="/etc/modules.conf"
  +		EXTENSION="o"
  +fi
  +
  +if [ "$KER_VER_REL" == "2.6" ]
  +	then
  +		CONFIG_FILE="/etc/modprobe.conf"
  +		EXTENSION="ko"
  +fi
  +
   rm -f /tmp/foundmodules
   rm -f /tmp/copiedmodules
   
   # Find Dependencies
   #
   finddep () {
  -echo "depfile=/lib/modules/$KERNEL_VERSION/modules.dep" > /tmp/config
   
   for module in $MODULES
   	do
  -		modprobe -C /tmp/config $module -v -n 2> /dev/null | \
  -		sed -ne 's#^/sbin/insmod.*/\(.*\)\.o.*#\1#p' >> /tmp/foundmodules
  -	done
  +		if [ "$KER_VER_REL" == "2.4" ]
  +			then
  +				echo "depfile=/lib/modules/$KERNEL_VERSION/modules.dep" > /tmp/config
  +				modprobe -C /tmp/config $module -v -n 2> /dev/null | \
  +				sed -ne "s#^/sbin/insmod.*/\(.*\)\.$EXTENSION.*#\1#p" >> /tmp/foundmodules
  +		fi
  +		if [ "$KER_VER_REL" == "2.6" ]
  +			then
  +				modprobe --set-version=$KERNEL_VERSION --show-depends $module 2> /dev/null | \
  +				sed -ne "s#^insmod.*/\(.*\)\.$EXTENSION.*#\1#p" >> /tmp/foundmodules
  +		fi
  + 	done
   }
   
  -# Set Root Device and File System
  +# Find Modules
   #
  -ROOT_DEVICE="$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' /etc/fstab)"
  +find_module() {
  +
  +	FIND_MOD=$1
  +	SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $FIND_MOD`"
  +}
   
   # Add or Remove IDE Modules
   #
  @@ -117,22 +168,13 @@
   		IDE_MODULES=""
   		POST_IDE=""
   	else
  -		PRE_IDE=""
  -		if [ -e /lib/modules/$KERNEL_VERSION/kernel/drivers/ide/pci ]
  -			then
  -				CHECK="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/ide/pci`"
  -				for check in $CHECK
  -					do	
  -						IDE_MODULE="`echo $check | cut -f1 -d'.'`"
  -						IDE_MODULES="$IDE_MODULES $IDE_MODULE"
  -					done
  -		fi
  -		if [ -e /lib/modules/$KERNEL_VERSION/kernel/drivers/ide/isa ]
  +		PRE_IDE="ide-probe-mod"
  +		if [ -e /proc/ide ]
   			then
  -				CHECK="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/ide/isa`"
  +				CHECK="`ls -1 /proc/ide`"
   				for check in $CHECK
   					do	
  -						IDE_MODULE="`echo $check | cut -f1 -d'.'`"
  +						IDE_MODULE="`echo $check`"
   						IDE_MODULES="$IDE_MODULES $IDE_MODULE"
   					done
   		fi
  @@ -174,6 +216,8 @@
   	 $PRE_USB $USB_MODULES $POST_USB
   	 $ADD_MODULE"
   
  +# Find the module Dependencies
  +#
   finddep
   
   # Set initrd name and size
  @@ -185,17 +229,75 @@
   LINUXRC="$MOUNT_IMAGE/linuxrc"
   INITRD="/boot/initrd-fsck-$KERNEL_VERSION.img"
   
  +# Check for Valid Kernel
  +#
  +if [ -e /lib/modules/$KERNEL_VERSION ]
  +	then
  +			echo "	/lib/modules/$KERNEL_VERSION does exist."
  +	else
  +			echo "	/lib/modules/$KERNEL_VERSION does not exist."
  +			exit 1
  +fi
  +
   # Getting Disk Information
   #
  -DISKS="`ls -1 /dev/discs`"
  -SWAP="`cat /etc/fstab | grep swap | cut -f1`"
  +if [ -e /dev/.devfsd ]
  +	then
  +		DISKS="`ls -1 /dev/discs`"
  +	else
  +		if [ -e /dev/sda ]
  +			then
  +				for drive in $SD_DEVICE
  +					do	
  +						DISKS="$DISKS $drive"
  +					done
  +		fi
  +		if [ -e /dev/hda ]
  +			then
  +				for drive in $HD_DEVICE
  +					do	
  +						DISKS="$DISKS $drive"
  +					done
  +		fi
  +fi
  +
  +SWAP="$(awk '/^[ \t]*[^#]/ { if ($2 == "swap") { print $1; }}' /etc/fstab)"
   
   # Check for filesystem for initrd
   #
   if [ "$INITRDFS" == "" ]
   	then
  -		echo "	Autoselecting ext3 File System for initrd."
  -		INITRDFS="ext3"
  +		FSYSCHECK="$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $3; }}' /etc/fstab)"
  +		if [ "$FSYSCHECK" == "ext2" ]
  +			then
  +				INITRDFS="ext2"
  +		fi
  +		if [ "$FSYSCHECK" == "ext3" ] && [ "$INITRDFS" == "" ]
  +			then
  +				INITRDFS="ext3"
  +		fi
  +		if [ "$FSYSCHECK" == "auto" ] && [ "$INITRDFS" == "" ]
  +			then
  +				find_module "ext3.$EXTENSION"
  +				if [ "$SEARCH" != "ext3.$EXTENSION" ]
  +					then
  +						INITRDFS="ext3"
  +				fi
  +				if [ "$INITRDFS" == "" ]
  +					then
  +						find_module "ext2.$EXTENSION"
  +						if [ "$SEARCH" != "ext2.$EXTENSION" ]
  +							then
  +								INITRDFS="ext2"
  +						fi
  +				fi
  +		fi
  +		if [ "$INITRDFS" == "" ]
  +			then
  +				echo "Cannot autodetect file system for initrd."
  +				exit 1
  +		fi
  +		echo "	Autoselecting $INITRDFS File System for initrd."
   fi
   
   # Check for initrd Directory
  @@ -205,14 +307,11 @@
   		mkdir /initrd
   fi
   		
  -# Check for RAM Disk Device
  +# Pivot Root Fixes
   #
  -if [ -e /dev/.devfsd ]
  -	then
  -		RAM_DEVICE="rd"
  -	else
  -		RAM_DEVICE="ram0"
  -fi
  +cd /sbin
  +ln -sf init linuxrc
  +cp /usr/sbin/chroot /sbin/chroot
   
   # Create Image and setup Loopback
   #
  @@ -248,7 +347,7 @@
   #
   if [ "$INITRDFS" == "ext2" ]
   	then
  -		SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $INITRDFS.o`"
  +		find_module "ext2.$EXTENSION"
   		if [ "$SEARCH" == "ext2" ]
   			then
   				echo "	$INITRDFS is compiled as a module."
  @@ -261,7 +360,7 @@
   
   if [ "$INITRDFS" == "ext3" ]
   	then
  -		SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $INITRDFS.o`"
  +		find_module "ext3.$EXTENSION"
   		if [ "$SEARCH" == "ext3" ]
   			then
   				echo "	$INITRDFS is compiled as a module."
  @@ -272,31 +371,6 @@
   		fi
   fi
   
  -if [ "$INITRDFS" == "romfs" ]
  -	then
  -		SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $INITRDFS.o`"
  -		if [ "$SEARCH" == "romfs" ]
  -			then
  -				echo "	$INITRDFS is compiled as a module."
  -				exit
  -			else
  -				echo "	$INITRDFS is compiled into the kernel."
  -		fi
  -fi
  -
  -if [ "$INITRDFS" == "cramfs" ]
  -	then
  -		SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $INITRDFS.o`"
  -		if [ "$SEARCH" == "cramfs" ]
  -			then
  -				echo "	$INITRDFS is compiled as a module."
  -				exit
  -			else
  -				echo "	$INITRDFS is compiled into the kernel."
  -
  -		fi
  -fi
  -
   echo "Creating Initrd..."
   
   # Creating initrd directory
  @@ -316,24 +390,33 @@
   #
   echo "	Creating Directories..."
   mkdir -p $MOUNT_IMAGE
  -mkdir -p $MOUNT_IMAGE/{lib,bin,etc,dev,proc}
  +mkdir -p $MOUNT_IMAGE/{bin,dev,etc,new_root,proc,lib}
   
   rm -rf $MOUNT_POINT/lost+found
   
   # Copying Static Programs
   #
  -cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
   cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
  -cp -a /sbin/e2fsck.static $MOUNT_IMAGE/bin/fsck
  -cp -a /sbin/busybox.static.fsck $MOUNT_IMAGE/bin/busybox
  -cp -a /sbin/busybox.static.fsck /bin/busybox
  +if [ "$KER_VER_REL" == "2.4" ]
  +	then
  +		cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
  +fi
  +if [ "$KER_VER_REL" == "2.6" ]
  +	then
  +		cp -a /etc/modprobe.conf $MOUNT_IMAGE/etc/modprobe.conf
  +fi
  +
  +cp -a /bin/e2fsck.static $MOUNT_IMAGE/bin/fsck
  +cp -a /bin/busybox.static.fsck $MOUNT_IMAGE/bin/busybox
  +cp -a /bin/busybox.static.fsck /bin/busybox
   cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
   ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
   ln -s /bin/busybox $MOUNT_IMAGE/bin/ln
  -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/bin/insmod
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
  +ln -s /bin/busybox $MOUNT_IMAGE/bin/[
   rm -rf /bin/busybox
   
   # Copying Modules
  @@ -346,12 +429,11 @@
   	do
   		echo "$MODULE" | {
   			IFS=':' read module
  -			module=$module
  -			SEARCH="`find /lib/modules/$KERNEL_VERSION/kernel -name $module.o`"
  +			find_module "$module.$EXTENSION"
   			REMOVE_MOD="0"
   			if ! [ "$SEARCH" == "" ]
   				then
  -					if ! [ -e $MOUNT_IMAGE/lib/$module.o ]
  +					if ! [ -e $MOUNT_IMAGE/lib/$module.$EXTENSION ]
   						then
   							for remove in $REMOVE_MODULE
   								do
  @@ -370,16 +452,35 @@
   	           }
   	done
   
  -for i in console null $RAM_DEVICE tty[1234]
  +for i in console null ram0 tty[1234]
   	do
   		cp -a /dev/$i $MOUNT_IMAGE/dev
   done
   
  +# Create non DEVFSD devices
  +#
  +if ! [ -e /dev/.devfsd ]
  +	then
  +		if [ -e /dev/sda ]
  +			then
  +				for drive in $SD_DEVICE
  +					do	
  +						cp -a $drive $MOUNT_IMAGE/dev
  +					done
  +		fi
  +
  +		if [ -e /dev/hda ]
  +			then
  +				for drive in $HD_DEVICE
  +					do	
  +						cp -a $drive $MOUNT_IMAGE/dev
  +					done
  +		fi
  +fi
  +
   # Creating linuxrc File
   #
   echo "#!/bin/sh" > $LINUXRC
  -echo "" >> $LINUXRC
  -
   echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
   
   MODULES="`cat /tmp/copiedmodules`"
  @@ -387,43 +488,84 @@
   	do
   		echo "$MODULE" | {
   		IFS=':' read module
  -		module=$module
   
  -		echo "	Adding $module to initrd."
  -		echo "insmod /lib/$module.o" >> $LINUXRC
  +		echo "		Module $module added to initrd."
  +		echo "insmod /lib/$module.$EXTENSION" >> $LINUXRC
   		}
   done
  +echo "echo \"Mounting proc...\"" >> $LINUXRC
   echo "mount -n -t proc none /proc" >> $LINUXRC
   echo "ln -s /proc/mounts /etc/mtab" >> $LINUXRC
  -for disc in $DISKS
  -        do
  -		if [ -e /dev/discs/$disc/part1 ]
  -			then
  -				PARTITIONS="`ls -1 /dev/discs/$disc/part*`"
  -				
  -				for partition in $PARTITIONS
  -					do
  -						REMOVE_PART="0"
  -						for remove in $REMOVE_PARTITIONS
  -							do
  -								if [ "$partition" = "$remove" ]
  -									then
  -										REMOVE_PART="1"
  -								fi
  -								if [ "$REMOVE_PART" != "1" ]
  -									then
  -										TEST="`cat $LINUXRC | grep $partition`"
  -										if [ "$TEST" == "" ]
  -											then
  -												echo "echo \"Checking Partition $partition...\"" >> $LINUXRC
  -												echo "fsck -f -y $partition" >> $LINUXRC
  -										fi
  -								fi
  -							done
  -					done
  -		fi
  -        done
  -echo "umount /proc" >> $LINUXRC
  +if [ -e /dev/.devfsd ]
  +	then
  +		for disc in $DISKS
  +        		do
  +			if [ -e /dev/discs/$disc/part1 ]
  +				then
  +					PARTITIONS="`ls -1 /dev/discs/$disc/part*`"
  +					
  +					for partition in $PARTITIONS
  +						do
  +							REMOVE_PART="0"
  +							for remove in $REMOVE_PARTITIONS
  +								do
  +									if [ "$partition" == "$remove" ]
  +										then
  +											REMOVE_PART="1"
  +									fi
  +									if [ "$REMOVE_PART" != "1" ]
  +										then
  +											TEST="`cat $LINUXRC | grep $partition`"
  +											if [ "$TEST" == "" ]
  +												then
  +													echo "echo \"Checking Partition $partition...\"" >> $LINUXRC
  +													echo "fsck -f -y $partition" >> $LINUXRC
  +											fi
  +									fi
  +								done
  +						done
  +			fi
  +        	done
  +	else
  +		for disc in $DISKS
  +        		do
  +				REMOVE_PART="0"
  +				for remove in $REMOVE_PARTITIONS
  +						do
  +							if [ "$disc" == "$remove" ]
  +								then
  +									REMOVE_PART="1"
  +							fi
  +						done
  +						if [ "$REMOVE_PART" != "1" ]
  +							then
  +								echo "echo \"Checking Partition $disc...\"" >> $LINUXRC
  +								echo "fsck -f -y $disc" >> $LINUXRC
  +						fi
  +			done
  +fi
  +
  +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 "echo \"Running pivot_root...\"" >> $LINUXRC
  +echo "pivot_root /new_root /new_root/initrd" >> $LINUXRC
  +if [ "$REMOVE_DEVFS" == "1" ]
  +	then
  +		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
  +fi
  +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
   
  
  
  



More information about the hints mailing list