Broken Initial RAM Disk support

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Thu Jan 13 2000 - 16:53:59 EST


I finally got my main machine back up after Linux-2.3.39 trashed
all file-systems as previously reported.

The last 3 kernels have problems with initial ramdisk support. I
read that those who are capable of testing this sort of thing do
not want to go through all the trouble of creating an initial
ram-disk for testing.

The following script will make an initial ramdisk to boot from
a floppy "/dev/fd0". It does not touch your hard disk nor in any
way mess up your present configuration.

If this was called "make_ramdisk", you would put a floppy into the first
drive and execute `make_ramdisk 2.3.39`
                                |_________ Kernel version number.

This script presumes that you have initial ramdisk support compiled into
your kernel and that the loop device is either installed as a module, or
otherwise working. It also presumes that the kernel you want to use
is /usr/src/linux-VERSION/arch/i386/boot/bzImage, where you enter
the version number. Additionally, it presumes that your /boot/boot.b
exists.

Once a boot-floppy is created, reboot from the floppy. Once initial
ramdisk support is again working, it will print a moving message on
the screen. If it doesn't work (currently), you will see the panic
and resulting crash. I don't presently have any way of capturing
this crash data.

#
#!/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.
#
echo "#include <stdio.h>">${TMPC}
echo "int main(){">>${TMPC}
echo "for(;;){">>${TMPC}
echo "printf(\"It works!\");fflush(stdout);usleep(200000);">>${TMPC}
echo "printf(\"\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\");">>${TMPC}
echo "fflush(stdout);printf(\" \");fflush(stdout);">>${TMPC}
echo "printf(\"\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D\033[D \");}}">>${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.
#
df ${RAMDISK}
umount ${RAMDISK}
rmdir ${RAMDISK}
#
# 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
#

Cheers,
Dick Johnson

Penguin : Linux version 2.3.36 on an i686 machine (800.63 BogoMips).

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



This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:23 EST