Re: Linux 2.2.17 broken with initrd

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Wed Sep 13 2000 - 16:08:45 EST


On Wed, 13 Sep 2000, Joseph Carter wrote:

> I've been fighting with this for a couple of days now. I've been trying
> under lilo, syslinux, and grub to get the kernel to follow the documented
> behavior of executing /linuxrc if you tell it to load an initrd as it did
> back in 2.0.35 (which was the last time I actually tried to use an initrd
> for anything..)
>
> The 2.4.0test kernels work fine. For the record:
>
> -­8<-- /usr/src/linux-2.2.17
> :
> CONFIG_BLK_DEV_RAM=y
> CONFIG_BLK_DEV_RAM_SIZE=4096
> CONFIG_BLK_DEV_INITRD=y
> :
> --8<--
>
> Any ideas why this isn't working? More importantly, if this is known not
> to work right, how are distributions coping with the inability to use
> /linuxrc? Documentation other than that in the kernel tree which was
> written in 1996 seems to be scarce.
>

First, see if this works. This makes a simple boot-through RAMDISK and
therefore tests it without all the other things that can go wrong.

This should help to isolate problems.

#!/bin/sh
#
#
export VER=$1
RAMDISK_IMAGE=/tmp/RamImage-${VER}
RAMDISK=/tmp/Ramdisk
TMPC=/tmp/Temp.c
TMPF=/tmp/TmpExe
DISKSIZE=2048
SYS=/usr/src/linux-${VER}/arch/i386/boot/bzImage
if [ "$1" = "" ] ;
   then
       echo "Usage:"
       echo "make_ramdisk <version>"
       exit 1
fi
if [ ! -f ${SYS} ] ;
   then
    echo "File not found, ${SYS}"
    exit 1
fi
if ! dd if=/dev/fd0 of=/dev/null bs=1k count=1 2>/dev/null ;
    then
       echo "Floppy drive error!"
       echo "Maybe no diskette in the drive?"
       exit 1
fi
#
# Make a little program called modprobe. This just returns 0.
#
echo "int main(){">${TMPC}
echo "return 0;}">>${TMPC}
gcc -O2 -o modprobe ${TMPC} -static
strip modprobe
rm ${TMPC}
#
# Make a little program called init. This just prints a moving message and
# waits forever.
#
echo "#include <stdio.h>">${TMPC}
echo "main(){">>${TMPC}
echo "int r, c;">>${TMPC}
echo "for(;;){">>${TMPC}
echo "r=rand()%25;c=rand()%68;printf(\"\033[%d;%dH Working! \", r, c);">>${TMPC}
echo "fflush(stdout);usleep(500000);">>${TMPC}
echo "printf(\"\033[%d;%dH \",r,c);fflush(stdout);">>${TMPC}
echo "}}">>${TMPC}
gcc -O2 -o init ${TMPC} -static
strip init
rm ${TMPC}
#
# Make a RAM Disk file and mount it using the loop device.
# Remove the lost+found directory to save space.
#
umount ${RAMDISK} 2>/dev/null
rm -rf ${RAMDISK} 2>/dev/null
mkdir ${RAMDISK} 2>/dev/null
dd if=/dev/zero of=${RAMDISK_IMAGE} bs=1k count=${DISKSIZE}
/sbin/mke2fs -Fq ${RAMDISK_IMAGE} ${DISKSIZE}
mount -o loop -t ext2 ${RAMDISK_IMAGE} ${RAMDISK}
rmdir ${RAMDISK}/lost+found
#
# Make the required directories in the RAM Disk.
#
mkdir -m 777 ${RAMDISK}/dev
mkdir -m 777 ${RAMDISK}/etc
mkdir -m 777 ${RAMDISK}/lib
mkdir -m 777 ${RAMDISK}/usr
mkdir -m 777 ${RAMDISK}/usr/local
mkdir -m 777 ${RAMDISK}/bin
mkdir -m 777 ${RAMDISK}/sbin
mkdir -m 777 ${RAMDISK}/tmp
mkdir -m 777 ${RAMDISK}/proc
#
# Make the required devices.
#
mknod ${RAMDISK}/dev/null c 1 3
mknod ${RAMDISK}/dev/ram0 b 1 0
mknod ${RAMDISK}/dev/ram1 b 1 1
mknod ${RAMDISK}/dev/mem c 1 1
mknod ${RAMDISK}/dev/ttyS0 c 4 64
mknod ${RAMDISK}/dev/tty0 c 4 0
mknod ${RAMDISK}/dev/tty1 c 4 1
mknod ${RAMDISK}/dev/tty2 c 4 2
mknod ${RAMDISK}/dev/tty3 c 4 3
mknod ${RAMDISK}/dev/tty4 c 4 4
mknod ${RAMDISK}/dev/tty c 5 0
mknod ${RAMDISK}/dev/ttyp0 c 3 0
mknod ${RAMDISK}/dev/ttyp1 c 3 1
mknod ${RAMDISK}/dev/ttyp2 c 3 2
mknod ${RAMDISK}/dev/ttyp3 c 3 3
mknod ${RAMDISK}/dev/ttyp4 c 3 4
mknod ${RAMDISK}/dev/ttyp5 c 3 5
mknod ${RAMDISK}/dev/ptyp0 c 2 0
mknod ${RAMDISK}/dev/ptyp1 c 2 1
mknod ${RAMDISK}/dev/ptyp2 c 2 2
mknod ${RAMDISK}/dev/ptyp3 c 2 3
mknod ${RAMDISK}/dev/ptyp4 c 2 4
mknod ${RAMDISK}/dev/ptyp5 c 2 5
mknod ${RAMDISK}/dev/zero c 1 5
#
# Set some compatibility links.
#
ln -s /dev/tty0 ${RAMDISK}/dev/systty
ln -s /dev/tty0 ${RAMDISK}/dev/console
ln -s /dev/ram1 ${RAMDISK}/dev/ram
ln -s /lib ${RAMDISK}/usr/lib
ln -s /lib ${RAMDISK}/usr/local/lib
#
#
# Copy the files and libraries. All of the files are stripped
# to save space.
#
cp modprobe ${RAMDISK}/sbin/modprobe
cp init ${RAMDISK}/sbin/init
#
#
# Unmount the RAM Disk. Remove its mount-point but save the file itself.
#
sync
df ${RAMDISK}
umount ${RAMDISK}
rmdir ${RAMDISK}
sync
#
# Make an ext2 file-system on a floppy and mount it. Remove the
# lost+found directory to save space.
#
umount /mnt 2>/dev/null
/sbin/mke2fs -q /dev/fd0
mount -t ext2 /dev/fd0 /mnt
rmdir /mnt/lost+found
#
# Compress the RAM Disk image into a file on the mounted file-system.
# Remove the original RAM Disk image, then copy the required boot
# files to the mounted file-system also.
#
gzip < ${RAMDISK_IMAGE} >/mnt/initrd-${VER}
rm ${RAMDISK_IMAGE}
cp ${SYS} /mnt/vmlinuz-${VER}
cp /boot/boot.b /mnt/boot.b
#
# Now execute lilo to install the boot-loader onto the mounted file-
# system. Lilo allows its configuration to be taken from standard input.
#
/sbin/lilo -C - <<EOF
#
# Lilo boot-configuration script.
#
boot = /dev/fd0
map = /mnt/map
backup = /dev/null
compact
vga = normal # force sane state
 install = /mnt/boot.b
 image = /mnt/vmlinuz-${VER}
 initrd = /mnt/initrd-${VER}
 root = /dev/ram0
 label = Test-RAMDISK
EOF
#
# Show the results and unmount the file-system.
#
df /dev/fd0
umount /dev/fd0
#

If this works, then there is just an incompatibility between your
`mkinitrd` or `mk_initrd` or whatever that your distribution uses
to make the ramdisk image. Therefore, not a kernel problem. However,
if this fails to make or mount the ramdisk upon boot, tell us what
the error message are. Note that the usual distributions also
require the loop device to be working in order to make a RAM Disk.
If this isn't built into the kernel (or a module), this script will
fail so you can find that problem also.

Note that you CAN make a Ram Disk using only /dev/ram0 and not the
loop device at all. You would have to modify scripts to do it though.

Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:22 EST